Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarting doesn't remove deleted environment variables in rbenv-vars #2511

Open
husam212 opened this issue Nov 21, 2023 · 1 comment
Open

Comments

@husam212
Copy link

Removing an environment variable in .rbenv-vars file then restarting the app with passenger-config restart doesn't work, the variable with its old value persists in ENV.

The file attached below contains a test Sinatra app to reproduce the issue.

test.zip

Reproduction Steps

  1. Run the app with passenger, passenger start --daemonize --load-shell-envvars.
  2. Test a request, curl http://localhost:3000 returns foo, which is expected.
  3. Edit the environment variable FOO value in .rbenv-vars file.
  4. Restart the app with passenger-config restart-app and test another request, it returns the new value, that's expected.
  5. Remove the environment variable FOO in rbenv-vars file.
  6. Restart the app again and test another request, it returns the old value foo, that's not expected.

Passenger version: 6.0.19
OS: Ubuntu 22.04.2 LTS

@CamJN
Copy link
Contributor

CamJN commented Nov 21, 2023

I'm not 100% sure that I agree that this is wrong behaviour in general, though it is certainly unexpected in this case.

When you start passenger with passenger start you are doing so in the dir with the rbenv-vars file, presumably using rbenv in your shell to run the correct ruby, so rbenv will load the initial env var into your shell env. Then when you start passenger it inherits the env vars from your shell, it then starts your app, using a child shell which loads rbenv and rbenv-vars which overrides the inherited env var from the parent shell. When you change the value of the env var in the file the changed value is what overrides the inherited env var so that still works as expected, however when you delete the env var from the rbenv-vars file, and restart the app, loading the env vars from rbenv-vars by the child shell doesn't clobber the inherited env var and thus you get the value from when the parent shell read the file and then started passenger.

This is certainly unexpected when you want the env to be managed by the rbenv-vars file but being able to inherit env vars from the parent process is also an expected capability for passenger. I'd recommend using the env utility to be sure passenger starts with only the env vars that are necessary to start the child shell which loads your app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants