Panfactum / stack

The Panfactum Stack
https://panfactum.com
Other
16 stars 5 forks source link

[Bug]: Issue setting variables in .env when migrating from previous iteration of the stack #10

Closed jlevydev closed 8 months ago

jlevydev commented 8 months ago

Prior Search

What happened?

When migrating from the non-flake version of the stack and attempting to set environment variables it seems as if there are conflicts from an unknown file. Potentially as a result of a previous devenv set up in the same file location Screenshot from 2024-03-10 16-05-02

Version

main (development branch)

What primary components of the stack are you seeing the problem on?

nix

Relevant log output

No response

Code of Conduct

fullykubed commented 8 months ago

This sounds like an issue potentially with migrating from non-flake to flake version of devenv. I don't see any documentation on their site around making this migration, but please ensure you have removed all local cache files before making this transition (.devenv, .direnv, etc.).

Can you share your .envrc, flake.nix, flake.lock, and devenv.nix?

jlevydev commented 8 months ago

I tried clearing my caches but to no avail. See the files attached (saved as txt files since Github couldn't attach them as is).

devenv.nix.txt flake.lock.txt flake.nix.txt .envrc.txt

Also, should .direnv/ be added to the .gitignore. Wasn't covered in the local/repo set up docs but seems wise.

fullykubed commented 8 months ago

All of your files look normal, so this is unexpected.

The only reference to LOCAL_DEV_NAMESPACE within the stack is here and this appears to be the "unknown file" that the error message is warning about. However, as you can see, the mkDefault function is being used which is what the error message suggests should be the remedy to this problem.

Also, you can see that other locations where environment variables are set in this same pattern (such as here) work without any issue.

I will need to investigate further as nothing sticks out to me immediately. Do you have any other environment variables in your .env set (e.g., VAULT_ADDR, CI, etc.)?

Regarding .gitignore, yes the .direnv and .devenv (among others) should be ignored. I am in the process of adding a command pf-gitignore-update to automatically add panfactum-specific lines to the main .gitignore, but this has not been implemented yet.

fullykubed commented 8 months ago

I have identified the issue.

Conflicting settings values in nix are merged based on the concept of priority. mkDefault assigns a low priority (1000). Trying to merge two values with the same priority will result in an error.

I had thought that mkDefault would be sufficient for setting variables in the panfactum devenv. However, according to these docs, the variables read in from the .env file are also assigned the mkDefault priority. This creates the conflict you have witnessed.

The fix is to change all of the panfactum default variables to an even lower priority (1001). Should be a simple enough change that I can release tomorrow.

fullykubed commented 8 months ago

This should be resolved on the latest update.

jlevydev commented 8 months ago

I'm still seeing the issue. I cleared my cache and attempted a rebuild. I'm pinned to main, is there something else I'd have to do to consume the update?

fullykubed commented 8 months ago

You cannot be pinned to main, only a specific commit. Please update your flake.lock. See the versioning / upgrading docs for specific instructions and best practices.

fullykubed commented 8 months ago

I think this provides a good summary of the functionality you are looking for if you just need a quick primer on flakes, inputs, pinning, and upgrades.

jlevydev commented 8 months ago

Yup, it was user error, I pulled in the latest changes and I'm all good!