arrterian / nix-env-selector

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

Empty string value for attr results in Command failed: `nix-shell -A --run env error: ... ` #39

Closed matobet closed 3 years ago

matobet commented 3 years ago

Describe the bug Having edited the value and removing it (setting it to empty string) the extension tries to spawn nix-shell with -A argument but no (empty string) value which fails. The only workaround is to set the value to '' which is quite ugly/non-intuitive.

To Reproduce Steps to reproduce the behavior:

  1. Fresh install of plugin
  2. Go to plugin settings
  3. Set "Nix Shell Config Attr" to some value
  4. Save settings
  5. Clear "Nix Shell Config Attr" setting
  6. Restart vscode
  7. Command failed: nix-shell -A --run env error: ...

Expected behavior After restart the attr should be interpreted as empty string and plain nix-shell should be used.

Screenshots image

Environment:

matobet commented 3 years ago

Created a simple PR https://github.com/arrterian/nix-env-selector/pull/40 to fix this. Also I wonder what is the expected behavior when the other config option - path - is empty. Should it just attempt to load the default.nix?

davidB commented 3 years ago

@matobet Thanks for the PR (I hope it will be merged and included into a release soon) and the workaround

  "nixEnvSelector.nixShellConfigAttr": "''",
arrterian commented 3 years ago

@matobet @davidB new version of the extension is coming very soon. The version will contains a bunch bug fixes and improvements (including this one). @matobet Thanks for the contribution but the PR will incompatible with future changes. So, I can't merge it now.

arrterian commented 3 years ago

Fixed in #44 Released in v1.0.0

davidB commented 3 years ago

Thank you, the version 1.0.1 works on my env