arrterian / nix-env-selector

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

Command 'Nix-Env: Select environment' resulted in an error (command 'extension.selectEnv' not found) #32

Closed InLaw closed 3 years ago

InLaw commented 4 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. install extension
  2. Cmd + Shift + P) and type Select environment
  3. See error Command 'Nix-Env: Select environment' resulted in an error (command 'extension.selectEnv' not found)

Expected behavior show .nix files in from the folder

Screenshots If applicable, add screenshots to help explain your problem.

Environment: nix-shell -p nix-info --run "nix-info -m"

 - system: `"x86_64-linux"`
 - host os: `Linux 5.7.10, NixOS, 20.03.2652.076c67fdea6 (Markhor)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20200622_334e26b`
 - channels(ae): `"home-manager-20.03, home-manager-unstable, nixos-20.03.2652.076c67fdea6, nixpkgs-20.03.2652.076c67fdea6, unstableNix-20.09pre235652.7d557a5d1b3, unstableOS-20.09pre235279.5717d9d2f7c"`
 - nixpkgs: `/home/user/.nix-defexpr/channels/nixpkgs`

Additional context

MaxGabriel commented 3 years ago

I ran into this as well.

 - system: `"x86_64-darwin"`
 - host os: `Darwin 19.2.0, macOS 10.15.2`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.2`
 - channels(maximiliantagher): `"nixpkgs-20.03pre207249.7e8454fb856"`
 - nixpkgs: `/Users/maximiliantagher/.nix-defexpr/channels/nixpkgs`
Version: 1.49.1
Commit: 58bb7b2331731bf72587010e943852e13e6fd3cf
Date: 2020-09-16T23:21:17.533Z (1 wk ago)
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.2.0
drewrisinger commented 3 years ago

One person I was helping troubleshoot a similar issue resolved it by first opening a workspace (i.e. folder) in VSCode, then trying to select a Nix environment.

arrterian commented 3 years ago

I's expected behavior. The extension can't work if there no workspace.

joneshf-cn commented 3 years ago

Sorry, I'm getting this same bug and I'm in a workspace. This only started happening today after I updated from 0.1.2 to 1.0.2. Any idea what might be the problem?

Also, if I downgrade to 0.1.2 I get a different problem:

Command failed: nix-shell  /Users/hjones/programming/citizennet/orders/default.nix --run env /bin/sh: nix-shell: command not found

Though that seems to be related to https://github.com/arrterian/nix-env-selector/issues/38

joneshf-cn commented 3 years ago

FWIW, I was able to work around this by installing the rubymaniac.vscode-direnv Extension, downgrading this extension to 0.1.2, reload everything, then uninstall rubymaniac.vscode-direnv. Something is definitely amiss, but I've no clue what.

arrterian commented 3 years ago

@joneshf-cn I have couple of questions that can help me figure it out

joneshf-cn commented 3 years ago
  • Does the error appears when you has already selected nix file in your config and want to select new one or only for blank config? (Or both?)

Both.

  • Will the error still appear if you will wait for a minute before running the command?

Yes.

hedefalk commented 3 years ago

I just installed this extension, got an automatic detection picker, selected my shell.nix. Then nothing happened, I read the readme stating "restart vscode". I tried by just reloading. Still nothing, so I tried the command and now it always gives me:

image

arrterian commented 3 years ago

Can you guys share the installed extensions list? Maybe there is some conflict. I should reproduce the bug in my system to be able to fix it.

arrterian commented 3 years ago

@hedefalk what OS do you use?

hedefalk commented 3 years ago

@hedefalk what OS do you use?

MacOS

andoriyu commented 3 years ago

I have the same error. Used to work a week ago. My setup: VS Code running in windows, remoting to nixos via SSH.

Not letting me select a environment, folder with shell.nix is open (the same way it was before). I've tried downgrading the extension - the same issue. I take the regression is after VSCode update and not the extension update. Downgrading to 0.1.2 works.

My remote env:

 - system: `"x86_64-linux"`
 - host os: `Linux 5.11.0, NixOS, 21.05pre272380.f6b5bfdb470 (Okapi)`                                                                                 
 - multi-user?: `yes`             
 - sandbox: `yes`   
 - version: `nix-env (Nix) 2.3.10` 
 - channels(andoriyu): `"home-manager"`
 - channels(root): `"nixos-21.05pre274338.102eb68ceec"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`              

VSCode version: 1.54.1

arrterian commented 3 years ago

@andoriyu Do you still get the error on v1.0.4?

andoriyu commented 3 years ago

@andoriyu Do you still get the error on v1.0.4?

Somehow 20 minutes later it started working on 1.0.4.

jmatsushita commented 3 years ago

I chose a flake.nix file and the extension seem stuck with it, not allowing to change (displaying the same error as OP). The developer tools show the following:

abstractExtensionService.ts:718 Activating extension 'arrterian.nix-env-selector' failed: Command failed: nix-shell "/Users/.../flake.nix" --run export
error: --- UsageError --- nix-shell
nix-shell requires a single derivation
Try 'nix-shell --help' for more information.
.
_logMessageInConsole @ abstractExtensionService.ts:718
localProcessExtensionHost.ts:265 Extension Host
localProcessExtensionHost.ts:266 error: --- UsageError --- nix-shellnix-shell requires a single derivationTry 'nix-shell --help' for more information.
jmatsushita commented 3 years ago

Maybe you could make the current chosen environment accessible in the extension settings? USers could then switch manually and maybe workaround the error?

jmatsushita commented 3 years ago

Since the extension is stuck on my flake.nix file, I've been modifying it and I now run into this error:

Activating extension 'arrterian.nix-env-selector' failed: Command failed: nix-shell "/Users/../my_repo/flake.nix" --run export
warning: Git tree '/Users/...my_repo' is dirty
.
_logMessageInConsole @ abstractExtensionService.ts:718
_logOrShowMessage @ abstractExtensionService.ts:732
$onExtensionActivationError @ mainThreadExtensionService.ts:64
_doInvokeHandler @ rpcProtocol.ts:417
_invokeHandler @ rpcProtocol.ts:402
_receiveRequest @ rpcProtocol.ts:318
_receiveOneMessage @ rpcProtocol.ts:245
(anonymous) @ rpcProtocol.ts:110
fire @ event.ts:622
fire @ ipc.net.ts:468
_receiveMessage @ ipc.net.ts:821
(anonymous) @ ipc.net.ts:660
fire @ event.ts:622
acceptChunk @ ipc.net.ts:241
(anonymous) @ ipc.net.ts:202
I @ ipc.net.ts:32
emit @ events.js:315
addChunk @ _stream_readable.js:295
readableAddChunk @ _stream_readable.js:271
Readable.push @ _stream_readable.js:212
onStreamRead @ internal/stream_base_commons.js:186
localProcessExtensionHost.ts:265 Extension Host
localProcessExtensionHost.ts:266 warning: Git tree '/Users/../my_repo' is dirty

Then when trying to select the nix shell:

notificationsAlerts.ts:40 Command 'Nix-Env: Select environment' resulted in an error (command 'nixEnvSelector.selectEnv' not found)

Maybe warnings make the extension loading fail and results in the selectEnv to not exist?

arrterian commented 3 years ago

@jmatsushita seems that I know what is wrong now. It because unproper error handling for sync operation on extension load. Thanks a lot for your comment. I think I will fix it when will have I time soon.

arrterian commented 3 years ago

@jmatsushita @InLaw added proper error handling. The problem should disappear in v1.0.6

InLaw commented 3 years ago

@arrterian thanks, in my case it is working

jmatsushita commented 3 years ago

Same here @arrterian it works. Thanks a ton!

joneshf-cn commented 3 years ago

1.0.6 also seemed to fix it for me. Thanks!

arobertn commented 2 years ago

I just experienced this on a remote linux host on 1.0.7, then downgraded to 1.0.6 and it's working. EDIT: 1.0.6 worked for a remote-over-SSH situation but is failing locally. Problem seems to have come up starting from the recent 1.62.1 VS Code release (continuing on 1.62.2). If there's some info that would help pinpoint the issue please let me know.

arobertn commented 2 years ago

If it helps, I also got success downgrading to 0.1.2. Then right away the chemical flask appears in the status bar and when I invoke the selectEnv it works. The chemical flask NEVER appears on the status bar in 1.0.6+. So maybe still a startup sequence error.

InLaw commented 2 years ago

Hello it is back as well on my (new) setup,

202204-19_1935_18__ 202204-19_1935_31__


Any idea to fix this?

InLaw commented 1 year ago

continuous on 22.11:

Version: 1.73.1 Commit: 6261075646f055b99068d3688932416f2346dd3b Date: 2022-11-09T03:54:53.913Z Electron: 19.0.17 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 OS: Linux x64 5.15.86 Sandboxed: No