Open ORESoftware opened 5 years ago
I’m not sure what “hashing disabled” means - is nixOS posix compliant?
It looks like this can happen if you’ve set +h
. Have you done that?
I havent actively set +h, but maybe thats the default in the shell, idk if nixos is posix compliant, i just started using it at work b/c I have to
nvm requires posix; but i'm not familiar with the h
option.
@ljharb from a google search it appears to be posix compliant, but not 100% sure
Can you try set -h
prior to running nvm?
sort of worked at first, but failure happened later? see complete linear history:
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# set -h
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# nvm install 11
nvm: command not found
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13226 100 13226 0 0 187k 0 --:--:-- --:--:-- --:--:-- 187k
=> Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
remote: Enumerating objects: 278, done.
remote: Counting objects: 100% (278/278), done.
remote: Compressing objects: 100% (249/249), done.
remote: Total 278 (delta 33), reused 88 (delta 16), pack-reused 0
Receiving objects: 100% (278/278), 142.36 KiB | 6.19 MiB/s, done.
Resolving deltas: 100% (33/33), done.
=> Compressing and cleaning up git repository
=> Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
=> Create one of them and run this script again
OR
=> Append the following lines to the correct file yourself:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# export NVM_DIR="$HOME/.nvm"
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# nvm install 11
Downloading and installing node v11.15.0...
Downloading https://nodejs.org/dist/v11.15.0/node-v11.15.0-linux-x64.tar.xz...
####################################################################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
nvm is not compatible with the npm config "prefix" option: currently set to "/nix/store/rhikjv5vlpa6vq4qkrszinwsaz1mda7p-nodejs-8.15.1"
Run `npm config delete prefix` or `nvm use --delete-prefix v11.15.0` to unset it.
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# nvm use 11
nvm is not compatible with the npm config "prefix" option: currently set to "/nix/store/rhikjv5vlpa6vq4qkrszinwsaz1mda7p-nodejs-8.15.1"
Run `npm config delete prefix` or `nvm use --delete-prefix v11.15.0` to unset it.
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# npm config delete prefix
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# nvm use 11
nvm is not compatible with the npm config "prefix" option: currently set to "/nix/store/rhikjv5vlpa6vq4qkrszinwsaz1mda7p-nodejs-8.15.1"
Run `npm config delete prefix` or `nvm use --delete-prefix v11.15.0` to unset it.
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# node -v
v8.15.1
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# nvm use --delete-prefix v11.15.0
Now using node v11.15.0 (npm v6.7.0)
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# node -v
-bash: /root/.nvm/versions/node/v11.15.0/bin/node: No such file or directory
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# set +h
[root@ec2-xxx-xxx-92-143:/var/lib/backend]# node -v
-bash: /root/.nvm/versions/node/v11.15.0/bin/node: No such file or directory
That’s very strange.
I don’t think anyone’s reported trying on nix before; I’m not sure how to debug it.
I bet it is because NixOS doesn't have a standard /lib
folder in the root of the filesystem.
And because libs aren't in a standard place in NixOS, this generic Linux issue happens: https://unix.stackexchange.com/questions/18061/why-does-sh-say-not-found-when-its-definitely-there
Here's a similar issue I opened on the n
package: https://github.com/tj/n/issues/603
I haven't found a workaround yet, but I bet it involves somehow telling binaries (binaries that aren't installed the standard NixOS-way) where to find library files, perhaps by setting LD_LIBRARY_PATH
to some value that I'm not sure of yet.
Per https://github.com/tj/n/issues/603#issuecomment-573132830, it seems like NixOS doesn’t have the typical kind of filesystem in a POSIX system, and so there’s a workaround needed.
@trusktr would you be willing to close this by PRring into the docs a section on NixOS?
I looked at README on GitHub, then realized I had to clone it and run stuff. I'll just leave something here:
The suggestion in https://github.com/tj/n/issues/603#issuecomment-573132830 is doable (I'd have to try it to figure the details), but it will be fighting against the grain of NixOS.
I've realized in NixOS it is far better to manage anything installed in the system by embracing NixOS's nix
package manager.
I recommend not faking an FHS filesystem: one would have to stick all their projects in this faked environment, then they'd need to stick any other dependencies in there as well when the need arrises. In the end they may as well not use NixOS and just switch to a traditional linux distro. This approach is a last resort.
Instead, nix
can be used to package and install different versions of node
(though I haven't done that yet, so I don't have the exact steps needed to do so). It'll take a learning curve to learn how to package arbitrary things with nix
, but it'll be worth the effort (in a similar vain as learning Vim makes it worth the effort for those who do).
If you could edit and make a PR in the web UI i can easily clean that up for you :-)
As for packaging up node with nix, one of the major reasons nvm is so widely used is that it uses the only official distribution channel, nodejs.org. Packaging up node makes it just as problematic as apt and yum repos hosting node versions.
I got the same issue running python virtual env
source /home/mudrii/src/github/.venv/bin/activate
bash: hash: hashing disabled
bash: hash: hashing disabled
Sems activate using hash -r
# This should detect bash and zsh, which have a hash command that must
# be called to get it to forget past commands. Without forgetting
# past commands the $PATH changes we made may not be respected
if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
hash -r
fi
https://github.com/nvm-sh/nvm/issues/2065#issuecomment-573140907
Altough you said it should be the last resort to fake a fhs fs in nixos, i think its a valid option and depents on peoples use case.
I use nvm
primarily for work and dependent of the project type - i dont need a globaly working instance - and i came across the nix-shell
command which is kind of exactly what i needed. You don't need to create one fhs filesystem for everything, you can create different nix-shells for different projects. This is really awesome for keeping your base system tidy, since you can specify environment dependencies (e.g. python, node, libs etc..) on a project basis in a shell.nix
and login to that shell by calling nix-shell
I personally find this a lot better than going back to a regular distro since nixos solves alot of other problems for me :slightly_smiling_face:
Btw. using nix
to manage node versions is no real option here, at least not for me. The nix pkgs are sometimes kind of outdated and incomplete (e.g. some node versions are missing)
Weirdly enough, I've been using nvm with nix (on macOS) for a while without issues. Just jumped onto nixOS and I'm seeing problems (but not the same as @ORESoftware).
I assumed everything would "just work" because the installation is to the home directory but I'm guessing it's not as simple as this.
Installation works fine which is what I would expect given installation is in the home directory
$ nvm install 15
Downloading and installing node v15.14.0...
Local cache found: ${NVM_DIR}/.cache/bin/node-v15.14.0-linux-x64/node-v15.14.0-linux-x64.tar.xz
Checksums match! Using existing downloaded archive ${NVM_DIR}/.cache/bin/node-v15.14.0-linux-x64/node-v15.14.0-linux-x64.tar.xz
Now using node v15.14.0 (npm v)
Adopting the installed nvm package also works fine
$ nvm use 15
Now using node v15.14.0 (npm v)
$ which node
/home/andy/.nvm/versions/node/v15.14.0/bin/node
It's only at execution time where this starts to become a problem.
$ node
zsh: command not found: node
$ npm
/usr/bin/env: ‘node’: No such file or directory
$ which node
/home/andy/.nvm/versions/node/v15.14.0/bin/node
$ /home/andy/.nvm/versions/node/v15.14.0/bin/node
zsh: no such file or directory: /home/andy/.nvm/versions/node/v15.14.0/bin/node
$ ls /home/andy/.nvm/versions/node/v15.14.0/bin/node
/home/andy/.nvm/versions/node/v15.14.0/bin/node
The node binary is definitely there, it's in the path, ls
confirms it exists, but for some reason I'm getting reports that it isn't there when trying to execute it.
Sorry I don't have much to contribute - let me know if you have any suggestions!
I'm using zsh-nvm
@andyrichardson it's to the home dir, but it still requires POSIX compliance.
This seems like a zsh-nvm issue, since invoking node
is attempting to invoke zsh
- that's not how normal node works.
Prebuilt Node.js binaries will never work out of the box on NixOS, because of non-standard libraries paths, as it was mentioned here before. On macOS its fine, because system libraries are in place where they're expected.
One workaround what nvm could do on NixOS, is to invoke patchelf
or nixpkgs' autoPatchelf on downloaded Node.js binary, but it's tricky to set up.
I have a very WIP Node.js versions overlay which patches Node.js as mentioned above - https://github.com/mikroskeem/node-overlay
Bug/something when install node version on NixOS NVM seemed to install fine on NixOS but when:
nvm debug
output:So I did this:
See
here is where it got weird
above