arrterian / nix-env-selector

Allows switch environment for Visual Studio Code using Nix Package Manager.
MIT License
220 stars 29 forks source link

rust-analyzer can't detect environment variables #89

Closed TheAwesome98-Real closed 3 months ago

TheAwesome98-Real commented 3 months ago

Describe the bug when using rust-analyzer, if i define an environment variable in shell.nix, it can't be used in rust with env!("VAR_NAME").

To Reproduce Steps to reproduce the behavior:

  1. create a rust project with a shell.nix that defines an environment variable
  2. load the shell.nix using the extension
  3. open a command-line and write nix-shell
  4. echo $VAR_NAME - it works!
  5. go to src/main.rs
  6. type env!("VAR_NAME") - and save
  7. notice that it complains about a missing variable at compile time

Expected behavior there should be no error because the variable is defined

Screenshots a compile error me showing that the variable exists

Environment:

TheAwesome98-Real commented 3 months ago

oops, restarting rust-analyzer fixed it, sorry!