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

[Bug]: Makefile incorrectly creates and uses values stored in .env #14787

Closed
1 task done
KevinMind opened this issue May 15, 2024 · 0 comments · Fixed by mozilla/addons-server#22246
Closed
1 task done

Comments

@KevinMind
Copy link
Contributor

KevinMind commented May 15, 2024

What happened?

When you are working locally, we save some values to .env and some values are inferred or derived from variables defined in the makefile, sometimes both. This exposes weird edge cases where IF you have a value defined in .env the value might be different in the make context.

Example:

kmeinhardt@kevins-mbp addons-server % make create_env_file
echo "HOST_UID=501" >> .env
echo "SUPERUSER_EMAIL=kmeinhardt@mozilla.com" >> .env
echo "SUPERUSER_USERNAME=Kevin Meinhardt" >> .env
kmeinhardt@kevins-mbp addons-server % HOST_UID=1 make create_env_file
echo "HOST_UID=501" >> .env
echo "SUPERUSER_EMAIL=kmeinhardt@mozilla.com" >> .env
echo "SUPERUSER_USERNAME=Kevin Meinhardt" >> .env
kmeinhardt@kevins-mbp addons-server % HOST_UID=1 make create_env_file HOST_UID=2
echo "HOST_UID=2" >> .env
echo "SUPERUSER_EMAIL=kmeinhardt@mozilla.com" >> .env
echo "SUPERUSER_USERNAME=Kevin Meinhardt" >> .env
kmeinhardt@kevins-mbp addons-server % make create_env_file           
echo "HOST_UID=501" >> .env
echo "SUPERUSER_EMAIL=kmeinhardt@mozilla.com" >> .env
echo "SUPERUSER_USERNAME=Kevin Meinhardt" >> .env
kmeinhardt@kevins-mbp addons-server % 

HOST_UID is set to either the default value or the argument. Setting it on the environment or setting it via the .env is meaningless.

This could result in commands run via make having radically different behavior than commands run outside of make and is an inconsistent and confusing behavior.

What did you expect to happen?

I expected the value to be defined according to 4 possible values in order of precedence.

  1. default value, defined in the makefile
  2. value currently in the .env if it exists
  3. value in the shell environment where the make command is run
  4. value in the make argument if it is passed.

This is a rank ordered list, so you might define the same variable in multiple ways, the method with the highest number wins.

Is there an existing issue for this?

  • I have searched the existing issues

┆Issue is synchronized with this Jira Task

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

Successfully merging a pull request may close this issue.

1 participant