Hi there,
I need to run a command with sudo
. Not the issue is that the secrets are added to the user env, and not the root env that the command prefaced with sudo is run in.
- Need to run:
doppler run -- sudo some-cmd
- does not work because the env vars are in my users env
- tried
sudo doppler run -- sudo some-cmd
(does not work)
- tried running as root
doppler run -- some-cmd
(does work)
I had a look at the flags, and did not notice a way to do this.
Did I miss something?
Thank you.
Hi @dkdoppler!
Welcome to the Doppler Community!
The issue you’re running into here is that sudo
literally switches the context of the command it executes. So, the Doppler CLI is setting the environment for the sudo command itself, which then runs the command you pass it in a different shell with different permissions (and without the environment variables Doppler injected). Unfortunately, there’s not really a great way to pass these through. If you have to run the process in the root context, then your best bet would be to run the doppler
command itself with sudo
:
sudo doppler run -p YOUR_PROJECT -c YOUR_CONFIG -- some-cmd
There’s no need to prefix some-cmd
with sudo
in that situation because doppler
is already being executed as root. You’ll need to do a sudo doppler login
beforehand to make sure the root environment is setup for this to work properly though.
As a complete aside, would you mind elaborating a bit about what you’re trying to do here? It could be that there’s a better way that I could recommend.
Regards,
-Joel