basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
10.6k stars 407 forks source link

`kamal app exec -i cmd` has no access to clear ENV variables #794

Closed jwald1 closed 4 months ago

jwald1 commented 4 months ago

I attempted to run the command kamal app exec -i 'bin/rails c', but I noticed that the clear environment variables returned nil ENV["CLEAR_VAR"] => nil, while the secret environment variables were accessible. However, when I added the --reuse option to the command, like this: kamal app exec -i --reuse 'bin/rails c', I was able to access the clear environment variables.

djmb commented 4 months ago

I'm not seeing that myself - are you running the latest version of Kamal?

You could double-check by comparing the output of kamal app exec -i env | sort and kamal app exec -i --reuse env | sort.

If you run the non-interactive version on the primary host you'll be able to see the docker run command being run: kamal app exec -p env | sort. I'd expect to see the env variables being passed as part of that.

jwald1 commented 4 months ago

After upgrading to the latest version 1.5.2, the problem was fixed. Although I deploy with GitHub Actions, I run rails c from my Mac. Hence, I didn't realize I was still using an old version (1.4). Thanks, @djmb.

djmb commented 4 months ago

Ah great!

BTW you can set minimum_version: 1.5.2 in your deploy.yml file to ensure that it doesn't regress.