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

Asking for nvm to be installed, when it is already #133521

Closed
DOHere opened this issue Sep 21, 2021 · 33 comments
Closed

Asking for nvm to be installed, when it is already #133521

DOHere opened this issue Sep 21, 2021 · 33 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Milestone

Comments

@DOHere
Copy link

DOHere commented Sep 21, 2021

macOS Big Sur 11.5.2
VSCode 1.60.1

.vscode/launch.json:

{    "configurations": [
    {
        "runtimeVersion": "10.16.3",
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "skipFiles": [
            "<node_internals>/**"
        ],
        "program": "${workspaceFolder}/engineRun.js",
        "args": ["3000"],
        "console": "integratedTerminal"
    }
]}

This used to run before. And note that terminal run: "node engineRun.js 3000" works.
But when I run VSCode's "Launch program", with the launch file above, I get:

Attribute 'runtimeVersion' requires Node.js version manager 'nvs' or 'nvm' to be installed.

I do have nvm installed + that node version

@Jkovarik
Copy link

Confirming I'm also having this issue after updating to 1.60.1.

@roblourens roblourens assigned connor4312 and unassigned roblourens Sep 21, 2021
@connor4312
Copy link
Member

What's the value of the NVM_HOME environment variable, and does it exist?

@connor4312 connor4312 added the info-needed Issue requires more information from poster label Sep 21, 2021
@DOHere
Copy link
Author

DOHere commented Sep 22, 2021

What's the value of the NVM_HOME environment variable, and does it exist?

Hi! There's no NVM_HOME, but there is an NVM_DIR (I run that at the end here):

my.acc~/Desktop/myRepo$ echo $NVM_HOME

my.acc~/Desktop/myRepo$ nvm --version
0.34.0

my.acc~/Desktop/myRepo$ nvm -v

Node Version Manager

Note: refers to any version-like string nvm understands. This includes:

  • full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
  • default (built-in) aliases: node, stable, unstable, iojs, system
  • custom aliases you define with nvm alias foo

Any options that produce colorized output should respect the --no-colors option.

Usage:
nvm --help Show this message
nvm --version Print out the installed version of nvm
nvm install [-s] Download and install a , [-s] from source. Uses .nvmrc if available
--reinstall-packages-from= When installing, reinstall packages installed in <node|iojs|node version number>
--lts When installing, only select from LTS (long-term support) versions
--lts= When installing, only select from versions for a specific LTS line
--skip-default-packages When installing, skip the default-packages file if it exists
--latest-npm After installing, attempt to upgrade to the latest working npm on the given node version
--no-progress Disable the progress bar on any downloads
nvm uninstall Uninstall a version
nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias lts/*, if available.
nvm uninstall --lts= Uninstall using automatic alias for provided LTS line, if available.
nvm use [--silent] Modify PATH to use . Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias lts/*, if available.
--lts= Uses automatic alias for provided LTS line, if available.
nvm exec [--silent] [] Run on . Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias lts/*, if available.
--lts= Uses automatic alias for provided LTS line, if available.
nvm run [--silent] [] Run node on with as arguments. Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias lts/*, if available.
--lts= Uses automatic alias for provided LTS line, if available.
nvm current Display currently activated version of Node
nvm ls List installed versions
nvm ls List versions matching a given
nvm ls-remote List remote versions available for install
--lts When listing, only show LTS (long-term support) versions
nvm ls-remote List remote versions available for install, matching a given
--lts When listing, only show LTS (long-term support) versions
--lts= When listing, only show versions for a specific LTS line
nvm version Resolve the given description to a single local version
nvm version-remote Resolve the given description to a single remote version
--lts When listing, only select from LTS (long-term support) versions
--lts= When listing, only select from versions for a specific LTS line
nvm deactivate Undo effects of nvm on current shell
nvm alias [] Show all aliases beginning with
nvm alias Set an alias named pointing to
nvm unalias Deletes the alias named
nvm install-latest-npm Attempt to upgrade to the latest working npm on the current node version
nvm reinstall-packages Reinstall global npm packages contained in to current version
nvm unload Unload nvm from shell
nvm which [current | ] Display path to installed node version. Uses .nvmrc if available
nvm cache dir Display path to the cache directory for nvm
nvm cache clear Empty cache directory for nvm

Example:
nvm install 8.0.0 Install a specific version number
nvm use 8.0 Use the latest available 8.0.x release
nvm run 6.10.3 app.js Run app.js using node 6.10.3
nvm exec 4.8.3 node app.js Run node app.js with the PATH pointing to node 4.8.3
nvm alias default 8.1.0 Set default node version on a shell
nvm alias default node Always default to the latest available node version on a shell

Note:
to remove, delete, or uninstall nvm - just remove the $NVM_DIR folder (usually ~/.nvm)

my.acc~/Desktop/myRepo$ echo $NVM_DIR
/Users/my.acc/.nvm

@connor4312
Copy link
Member

Hm, ok. If you remove the runtimeVersion and console so that the node script is run as a subprocess of the extension host, is NVM_DIR set there? I'm wondering if the environment variable isn't getting applied to VS Code.

If that isn't set, where do you have nvm configured? (Which .rc file?)

@DOHere
Copy link
Author

DOHere commented Sep 23, 2021

Hm, ok. If you remove the runtimeVersion and console so that the node script is run as a subprocess of the extension host, is NVM_DIR set there? I'm wondering if the environment variable isn't getting applied to VS Code.

If that isn't set, where do you have nvm configured? (Which .rc file?)

If I remove runtime version and console from the launch file again, it still won't run (with the same error).

my.acc~/Desktop/myRepo$ nvm which
No .nvmrc file found

Node Version Manager

Note: refers to any version-like string nvm understands. This includes:

  • full or partial version numbers, starting with an optional "v" (0.10, v0.1.2, v1)
  • default (built-in) aliases: node, stable, unstable, iojs, system
  • custom aliases you define with nvm alias foo

Any options that produce colorized output should respect the --no-colors option.

Usage:
nvm --help Show this message
nvm --version Print out the installed version of nvm
nvm install [-s] Download and install a , [-s] from source. Uses .nvmrc if available
--reinstall-packages-from= When installing, reinstall packages installed in <node|iojs|node version number>
--lts When installing, only select from LTS (long-term support) versions
--lts= When installing, only select from versions for a specific LTS line
--skip-default-packages When installing, skip the default-packages file if it exists
--latest-npm After installing, attempt to upgrade to the latest working npm on the given node version
--no-progress Disable the progress bar on any downloads
nvm uninstall Uninstall a version
nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias lts/*, if available.
nvm uninstall --lts= Uninstall using automatic alias for provided LTS line, if available.
nvm use [--silent] Modify PATH to use . Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias lts/*, if available.
--lts= Uses automatic alias for provided LTS line, if available.
nvm exec [--silent] [] Run on . Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias lts/*, if available.
--lts= Uses automatic alias for provided LTS line, if available.
nvm run [--silent] [] Run node on with as arguments. Uses .nvmrc if available
--lts Uses automatic LTS (long-term support) alias lts/*, if available.
--lts= Uses automatic alias for provided LTS line, if available.
nvm current Display currently activated version of Node
nvm ls List installed versions
nvm ls List versions matching a given
nvm ls-remote List remote versions available for install
--lts When listing, only show LTS (long-term support) versions
nvm ls-remote List remote versions available for install, matching a given
--lts When listing, only show LTS (long-term support) versions
--lts= When listing, only show versions for a specific LTS line
nvm version Resolve the given description to a single local version
nvm version-remote Resolve the given description to a single remote version
--lts When listing, only select from LTS (long-term support) versions
--lts= When listing, only select from versions for a specific LTS line
nvm deactivate Undo effects of nvm on current shell
nvm alias [] Show all aliases beginning with
nvm alias Set an alias named pointing to
nvm unalias Deletes the alias named
nvm install-latest-npm Attempt to upgrade to the latest working npm on the current node version
nvm reinstall-packages Reinstall global npm packages contained in to current version
nvm unload Unload nvm from shell
nvm which [current | ] Display path to installed node version. Uses .nvmrc if available
nvm cache dir Display path to the cache directory for nvm
nvm cache clear Empty cache directory for nvm

Example:
nvm install 8.0.0 Install a specific version number
nvm use 8.0 Use the latest available 8.0.x release
nvm run 6.10.3 app.js Run app.js using node 6.10.3
nvm exec 4.8.3 node app.js Run node app.js with the PATH pointing to node 4.8.3
nvm alias default 8.1.0 Set default node version on a shell
nvm alias default node Always default to the latest available node version on a shell

Note:
to remove, delete, or uninstall nvm - just remove the $NVM_DIR folder (usually ~/.nvm)

So I added a .nvmrc file to my repo:

my.acc~/Desktop/myRepo$ node -v > .nvmrc

my.acc~/Desktop/myRepo$ cat .nvmrc
v10.15.0

Still the same error when I run VsCode debugging tho:(. Btw, this is my .bashrc config:

my.acc~/Desktop/myRepo$ cat $HOME/.bashrc
npm set prefix ~/.npm
PATH="$HOME/.npm/bin:$PATH"
PATH="./node_modules/.bin:$PATH"

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion" # This loads nvm bash_completion

@connor4312
Copy link
Member

connor4312 commented Sep 23, 2021

@bpasero how does environment variable resolution for the extension host work now? Could the NVM_DIR in their bashrc not be picked up for some reason or another?

@bpasero
Copy link
Member

bpasero commented Sep 24, 2021

@connor4312 via this service call:

@Anshorei
Copy link

Encountered this problem as well. It was introduced in v1.60.0, and I have found no solution other than to downgrade to v1.59.1

@connor4312
Copy link
Member

connor4312 commented Oct 6, 2021

Do you happen to have nvs also installed?

I'm not able to reproduce this on my machine, and the code js-debug uses is almost identical to the old debugger. It would be super helpful if someone could step through the code here to see what's happening on their machine and why it's not being detected: https://github.com/microsoft/vscode-js-debug/blob/db286867c4d6b797304a5a0ef05cce01c3c35b08/src/targets/node/nvmResolver.ts#L51. Contributing guide here for setup info.

@dcastellanos-r7
Copy link

I have the same issue and nvs is not installed on my system.
$NVM_DIR is set to /Users/my_user/.nvm

@DOHere
Copy link
Author

DOHere commented Oct 7, 2021

Do you happen to have nvs also installed?

I'm not able to reproduce this on my machine, and the code js-debug uses is almost identical to the old debugger. It would be super helpful if someone could step through the code here to see what's happening on their machine and why it's not being detected: https://github.com/microsoft/vscode-js-debug/blob/db286867c4d6b797304a5a0ef05cce01c3c35b08/src/targets/node/nvmResolver.ts#L51. Contributing guide here for setup info.

I also don't have nvs installed. And I'm not using Windows(as that code mentions), but a MacOS.

@Anshorei
Copy link

  • nvs is not installed
  • $NVM_DIR is not set
  • I'm on Linux (PopOS latest release)

@connor4312
Copy link
Member

$NVM_DIR is not set

That is the issue for you. I'm not sure why 1.60 started failing as both the old and new debuggers depend on NVM_DIR.

@DOHere
Copy link
Author

DOHere commented Oct 18, 2021

$NVM_DIR is not set

That is the issue for you. I'm not sure why 1.60 started failing as both the old and new debuggers depend on NVM_DIR.

I have NVM_DIR set up and it's still failing

@DOHere
Copy link
Author

DOHere commented Oct 18, 2021

@dcastellanos-r7 @Anshorei @Jkovarik are you guys also on MacOS or what operating system is this issue showing on for you?

@theRealPadster
Copy link

I'm having this issue with macOS Big Sur 11.6 and VS Code 1.61.1. I have nvm installed and $NVM_DIR set up.

@BFuhry
Copy link

BFuhry commented Oct 21, 2021

I have the same issue with the following setup:

  • VSCode 1.61.1
  • nvs is not installed
  • $NVM_DIR is set to /home/my_user/.nvm
  • Ubuntu 20.04 running in WSL2

@FabioYamada
Copy link

FabioYamada commented Nov 1, 2021

I was able to make it work using macOS BigSur V11.6 (VSCode June 2021 (version 1.58))

  1. Install nvs as per git repo instructions
  2. Install the desired node version using nvs install: i.e. nvs add node/12
  3. Update Vscode launch.json to point to the nvs version. (without node/ prefix) i.e. "runtimeVersion": "12.22.7/x64"

Since the reported behavior is suddenly happening on different versions, the bug trigger should rely somewhere else. I was debugging normally until 2021-10-29. On 2021-10-31 I experienced the issue. Checking the System Information -> Software -> Logs there is no registry of updates in between the dates.

Apparently, NPM is being ignored and only the NVS is accepted to resolve the runtimeVersion property in the launch.json file.

@rainabba
Copy link

rainabba commented Nov 1, 2021

So am I understanding that despite the error itself saying "nvm or nvs", we must now migrate from NVM to NVS (even if just a "work-around")?

Windows 10, 20H2
nvm 0.38.0
NVM_DIR=~/.nvm
NVM_HOME not set

@connor4312
Copy link
Member

Since I have been unable to reproduce this on any of my machines, I'm once again asking for a volunteer to debug through the detection logic to see where nvm detection is failing in their environment: #133521 (comment)

@rainabba
Copy link

rainabba commented Nov 1, 2021

Since I have been unable to reproduce this on any of my machines, I'm once again asking for a volunteer to debug through the detection logic to see where nvm detection is failing in their environment: #133521 (comment)

I have the nightly extension installed and I tried to add breakpoints by function name ( resolveNvmVersionPath ), but it's not hit when I try to launch and I'm not sure how to locate/open the appropriate file to put a breakpoint there. More guidance would be appreciated. I'm also available for real-time (zoom, teams, slack, twitter, etc..) and for a bit at: https://prod.liveshare.vsengsaas.visualstudio.com/join%3FCE7985D1F49CC05A1DC9CB0E585D381CE9AD

@connor4312
Copy link
Member

connor4312 commented Nov 1, 2021

@rainabba the steps are:

  1. Install the nightly extension
  2. git clone git@github.com:microsoft/vscode-js-debug.git
  3. cd vscode-js-debug
  4. npm install
  5. npm run watch
  6. Now, open vscode-js-debug. Set the breakpoint, and run the "Extension" launch config from the debug view (or ctrl+p and type debug extension)
  7. Now try to debug something with a runtimeExecutable set. The breakpoint should be hit.

If you have an email and preferred time I could also set up a 15 minute teams call to help debug and get to the bottom of it 🙂

@rainabba
Copy link

rainabba commented Nov 1, 2021

Steps I've completed:

  • cloned vscode-js-debug and vscode-js-debug-companion then did npm i for each
  • opened vscode-js-debug
  • set a breakpoint on nvmResolver.ts:51
  • run "Extension" launch config which opens a new instance of vscode
  • In the new instance, I opened my workspace and tried to run my launch config

After that, my breakpoint shows as unbound (empty circle) and if I try to launch my config as before, I get the same error about nvs or nvm.

Here's what I get in the debug console of the vscode-js-debug instance:

Note: Using the "preview" debug extension
(node:25796) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `Code - Insiders --trace-deprecation ...` to show where the warning was created)
c:\Program Files\Microsoft VS Code Insiders\resources\app\out\bootstrap-fork.js:5
logFile for SqlToolsResourceProviderService.exe is c:\Users\{{userName}}\AppData\Roaming\Code - Insiders\logs\20211101T083406\exthost7\ms-mssql.mssql\resourceprovider.log
c:\Program Files\Microsoft VS Code Insiders\resources\app\out\bootstrap-fork.js:5
This process (ui Extenstion Host) is pid: 25796
c:\Program Files\Microsoft VS Code Insiders\resources\app\out\bootstrap-fork.js:5
Old log files deletion report: {}
c:\Program Files\Microsoft VS Code Insiders\resources\app\out\bootstrap-fork.js:5
Initialized vscode-mssql storage.
c:\Program Files\Microsoft VS Code Insiders\resources\app\out\bootstrap-fork.js:5
Message Unavailable in region didn't get externalized correctly.
c:\Program Files\Microsoft VS Code Insiders\resources\app\out\bootstrap-fork.js:5
Message {0} Toolkit didn't get externalized correctly.
c:\Program Files\Microsoft VS Code Insiders\resources\app\out\bootstrap-fork.js:5
Message {0} Remote Invocations didn't get externalized correctly.
c:\Program Files\Microsoft VS Code Insiders\resources\app\out\bootstrap-fork.js:5

I'm available for the next few hours if you'd like to connect. I'll try to keep on top of gmail, but I'm available on chat and duo with the same address.

@connor4312
Copy link
Member

Please send a mail over to connor@xbox.com and I'll make a Teams invite for you 🙂

@connor4312
Copy link
Member

@bpasero do you know whether there was a change in 1.61 that adjusted how variables are loaded?

What we saw with @rainabba is that he had a somewhat weird shell setup that he booted into zshrc manually (if I recall). Launching code from zsh once loaded worked, but opening the WSL workspace via Recently Opened from a Windows-launched didn't. This would make sense with what I'm seeing where a properly-installed nvm in, for example, a fresh Linux VM works just fine and follows the code paths that have been almost identical for a long time.

@rainabba
Copy link

rainabba commented Nov 1, 2021

@connor4312 is very politely saying that my shell is broken and so launching vscode from a Windows shortcut (even if to a workspace that "opens in wsl"), the environment was different than if I start a terminal, run bash and THEN code . I've been meaning to fix my shell, but haven't found the solution yet (by default, Ubuntu18.04 starts in a bash shell, but without parsing .bash_rc until I explicitly run bash.

I think the takeaway for me was: Make sure vscode is launched from a properly loaded environment BEFORE trying to launch a debug config. This both preventing debugging, AND debugging the debugging hehe.

@bpasero
Copy link
Member

bpasero commented Nov 2, 2021

@connor4312 one change that comes to mind is that on macOS we launch VS Code via the open command when you open from the command line. Is this macOS?

@connor4312
Copy link
Member

Yes, this user was on macOS. We also have a couple reports from Linux further up in the thread, but I'm not sure how representative Michael's case is of the overall issue.

A workaround would just be to check for the default install directory ~/.nvm if a runtimeVersion is configured and there's no other NVM_HOME environment. That would work in 99% of cases where nvm is installed in the default directory, regardless of whether or not the user's dotfiles are set up nicely for us.

@bpasero
Copy link
Member

bpasero commented Nov 2, 2021

If you can distill a bug with steps how to reproduce, we can look into and see if it is related to the change to use open command.

@connor4312 connor4312 added bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues and removed info-needed Issue requires more information from poster labels Nov 4, 2021
@connor4312 connor4312 added this to the November 2021 milestone Nov 4, 2021
@zipzit
Copy link

zipzit commented Nov 6, 2021

I was totally stuck here on MacOS with NVM installed. Same error as above. Updated VSCode to Version: 1.62.0 and restart VSCode. Not sure what you guys did, but issue is resolved here. Many thanks.

Version: 1.62.0
Commit: b3318bc
Date: 2021-11-03T15:24:41.297Z (4 days ago)
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 20.6.0

Note, I added the details from VSCode after seeing the post from yaronlevi.

@yaronlevi
Copy link

Happens here also:

Version: 1.62.0
Commit: b3318bc
Date: 2021-11-03T15:24:41.297Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 19.6.0

@zipzit
Copy link

zipzit commented Nov 7, 2021

@yaronlevi Not clear at all what you are saying. I have no clue what you mean by "Happens here also:" Is that
"the fix happens here" or is that the "the nvm trouble (Attribute 'runtimeVersion' requires Node.js version manager 'nvs' or 'nvm' to be installed.) happens here? What exactly do you mean?

@connor4312
Copy link
Member

Fyi this is fixed in the nightly build: https://github.com/microsoft/vscode-js-debug#nightly-extension

@roblourens roblourens added the verified Verification succeeded label Dec 1, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests