Can I "override" a variable when using Doppler run?

Hi there.

I have a variable called DEBUG in my Doppler project (and all configs).

When I start my project like this locally; doppler run -- npm run dev, would it be possible to let any locally defined DEBUG take precedence?

Extra context:
You might wonder why I even would like the DEBUG variable to be part of Doppler. The reason here is pretty simple. I’m trying to prepare for the near future where our project is moving to the edge (instead of node.js runtime) on the Vercel platform. We are using Sveltekit, and reading env secrets from ‘$env/static/private’.

Hi @alexbjorlig!

Yep, we do have something like that! What you’re looking for is probably the --preserve-env flag:

doppler run --preserve-env=DEBUG -- npm run dev

That will preserve any variable you specify that’s already set in your local environment. You can pass in multiple variable names using a comma-delimited list:

doppler run --preserve-env=FOO,BAR,BAZ -- YOUR_COMMAND

For this particular flag, it does require the format above (i.e., using --preserve-env FOO,BAR,BAZ won’t work).

Give that a shot and let me know if it works for what you’re after

Regards,
-Joel

1 Like