rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] incorrect Node.js version detection

Open gomain opened this issue 3 years ago • 2 comments

Summary

Any rush command fails, because of node.js version validation.

$ node --version
v14.20.0

$ rush --debug update


Rush Multi-Project Build Tool 5.56.0 - https://rushjs.io
Node.js version is 16.16.0 (LTS)



ERROR: Your dev environment is running Node.js version v16.16.0 which does not meet the requirements for building this repository.  (The rush.json configuration requires nodeSupportedVersionRange=">=12.13.0 <13.0.0 || >=14.15.0 <15.0.0")

Repro steps

Using Nixos:

  1. Enter a nix-shell where nodejs is v16.16.0.
  2. Then enter another nix-shell where nodejs is v14.20.0
  3. Run any rush command.

Details

Rush is not detecting nodejs verison by actually running node --version.

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/rush globally installed version? 5.76.1
rushVersion from rush.json? 5.56.0
useWorkspaces from rush.json? Yes
Operating system? Linux:Nixos
Would you consider contributing a PR? No
Node.js version (node -v)? 16.16.0 then 14.20.0

gomain avatar Sep 05 '22 05:09 gomain

How is Rush installed globally? What is the contents of the file at the path that gets printed when you run which rush?

My suspicion is that the bin script for Rush is pointing at a different version of Node.

iclanton avatar Sep 12 '22 18:09 iclanton

Rush is globally installed via nix-shell & node2nix. At the time of running node2nix, node version is specified (as 16). This somehow constraints the node versions when spawned by rush. Regardless of the node version available in the user's shell.

gomain avatar Sep 14 '22 06:09 gomain

I'm also getting this. In my case, I used devbox to create a development shell which specifies node and rush to be globally installed in the shell. Devbox is also a nix shell, so I believe my issue is the same as this one.

In my config for devbox, I initially specified the latest version of node, but it was not compatible, so I re-created the shell with older version of node, but it's still pointing to the wrong node version.

@gomain Did you figure out how to fix this?

ekawatani avatar Mar 11 '24 19:03 ekawatani

@iclanton When I do which rush, I get this:

/home/<username>/<path-to-project-dir>/.devbox/nix/profile/default/bin/rush

When I see the content of the file, I see this.

#!/nix/store/vz13mi0w75q96sfjxz2ylnv8812hvf34-nodejs-20.11.1/bin/node
require('../lib/start.js');

Running /nix/store/vz13mi0w75q96sfjxz2ylnv8812hvf34-nodejs-20.11.1/bin/node -v returns a wrong version. This may not be a rush related issue, but it's odd that it's referring to a wrong node.

ekawatani avatar Mar 11 '24 20:03 ekawatani

Rush just uses whichever version of Node it was Invoked with, so if it's getting an unexpected version, I'd guess it's because either the package manager that installed it generated an incorrect bin file, or it was installed with under a different version of node in a location that's available to all versions of node.

Given that this seems to be happening on/with nix, I bet nix doesn't isolate globally installed packages from between node versions. I'd consider this a flaw with nix, since packages that have native bindings often need those bindings to match a specific version of Node. You should be able to mitigate this by reinstalling Rush globally.

iclanton avatar Mar 12 '24 10:03 iclanton

nix ensures runtime dependencies. executable node packages (such as rush) executables aren't plain scripts run by the node available at the shell, but a node specified by its derivative. this is particularly true when derivatives were generated via node2nix. you could install rush without installing node and it will still run. this is not a bug. you need tobe explicit of what you want.

gomain avatar Mar 13 '24 17:03 gomain

@gomain Got it. That's a good point. I'm still fairly new to nix, but I understand what you mean.

@iclanton I suppose this ticket can be closed since it's not a problem with rush.

ekawatani avatar Mar 17 '24 09:03 ekawatani