nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
79.11k stars 7.92k forks source link

Operation not permitted after installed nodejs #3420

Closed ct24p closed 1 week ago

ct24p commented 1 week ago

Operating system and version:

AWS EC2 Rocky 8.9

nvm debug output:

```sh node -v -bash: /home/ec2-user/.nvm/versions/node/v20.10.0/bin/node: Operation not permitted nvm --version 0.40.1 ```

nvm ls output:

```sh nvm list v20.10.0 default -> v20.10.0 iojs -> N/A (default) unstable -> N/A (default) node -> stable (-> v20.10.0) (default) stable -> 20.10 (-> v20.10.0) (default) lts/* -> lts/iron (-> N/A) lts/argon -> v4.9.1 (-> N/A) lts/boron -> v6.17.1 (-> N/A) lts/carbon -> v8.17.0 (-> N/A) lts/dubnium -> v10.24.1 (-> N/A) lts/erbium -> v12.22.12 (-> N/A) lts/fermium -> v14.21.3 (-> N/A) lts/gallium -> v16.20.2 (-> N/A) lts/hydrogen -> v18.20.4 (-> N/A) lts/iron -> v20.17.0 (-> N/A) ```

How did you install nvm?

What steps did you perform?

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source .bashrc
nvm install 20

What happened?

node -v
-bash: /home/ec2-user/.nvm/versions/node/v20.10.0/bin/node: Operation not permitted

What did you expect to happen?

node -v should show v20.17.0

Is there anything in any of your profile files that modifies the PATH?

.bashrc

ljharb commented 1 week ago

What's the output of nvm debug?

ct24p commented 1 week ago

nvm --version: v0.40.1 $SHELL: /bin/bash $SHLVL: 1 whoami: 'ec2-user' ${HOME}: /home/ec2-user ${NVM_DIR}: '${HOME}/.nvm' ${PATH}: ${NVM_DIR}/versions/node/v20.17.0/bin:${HOME}/.local/bin:${HOME}/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin $PREFIX: '' ${NPM_CONFIG_PREFIX}: '' $NVM_NODEJS_ORG_MIRROR: '' $NVM_IOJS_ORG_MIRROR: '' shell version: 'GNU bash, version 4.4.20(1)-release (x86_64-redhat-linux-gnu)' uname -a: 'Linux 4.18.0-553.5.1.el8_10.x86_64 #1 SMP Thu Jun 6 09:41:19 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux' checksum binary: 'sha256sum' OS version: ****WARNING****WARNING*WARNING*** awk: /usr/bin/awk, GNU Awk 4.2.1, API: 2.0 (GNU MPFR 3.1.6-p2, GNU MP 6.1.2) curl: /usr/bin/curl, curl 7.61.1 (x86_64-redhat-linux-gnu) libcurl/7.61.1 OpenSSL/1.1.1k zlib/1.2.11 brotli/1.0.6 libidn2/2.2.0 libpsl/0.20.2 (+libidn2/2.2.0) libssh/0.9.6/openssl/zlib nghttp2/1.33.0 wget: not found git: not found ls: cannot access 'alias'$'\n''/usr/bin/grep': No such file or directory grep: alias grep='grep --color=auto' /usr/bin/grep (grep --color=auto), grep (GNU grep) 3.1 sed: /usr/bin/sed, sed (GNU sed) 4.5 cut: /usr/bin/cut, cut (GNU coreutils) 8.30 basename: /usr/bin/basename, basename (GNU coreutils) 8.30 rm: /usr/bin/rm, rm (GNU coreutils) 8.30 mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.30 xargs: /usr/bin/xargs, xargs (GNU findutils) 4.6.0 nvm current: none which node: ${NVM_DIR}/versions/node/v20.17.0/bin/node which iojs: /usr/bin/which: no iojs in (${NVM_DIR}/versions/node/v20.17.0/bin:${HOME}/.local/bin:${HOME}/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin) which npm: ${NVM_DIR}/versions/node/v20.17.0/bin/npm npm config get prefix: -bash: ${NVM_DIR}/versions/node/v20.17.0/bin/npm: /usr/bin/env: bad interpreter: Operation not permitted npm root -g: -bash: ${NVM_DIR}/versions/node/v20.17.0/bin/npm: /usr/bin/env: bad interpreter: Operation not permitted

BTW: if git is installed (git version 2.43.5) before nvm installation, install nvm will got error below: => Cloning into '/home/ec2-user/.nvm'... fatal: cannot copy '/usr/share/git-core/templates/hooks/fsmonitor-watchman.sample' to '/home/ec2-user/.nvm/.git/hooks/fsmonitor-watchman.sample': Operation not permitted Failed to clone nvm repo. Please report this!

ljharb commented 1 week ago

Googling suggests this is a common Mac OS error, or https://chipcullen.com/fixing-bad-interpreter-error-aws-python-3_7/ - but either way I'm not sure how I can debug it from here.

What happens if you chmod a+x /home/ec2-user/.nvm/versions/node/v20.10.0/bin/node?

ct24p commented 1 week ago

thanks for your helps. it's 700, i tried to chmod to 777/755, same error, Not MacOS, it's AWS Rocky 8.9 AMI. However, if i run: `sudo /home/ec2-user/.nvm/versions/node/v20.10.0/bin/node -v', it printed v20.17.0 (correct). The installation was under non-root user.

ljharb commented 1 week ago

Assuming that nvm is installed under ec2-user, can you run other things you install as ec2-user? or does AWS only let you run your own programs as root?

ct24p commented 1 week ago

@ljharb: Thanks very much for the helps. I finally figured it out that the issue was caused by fapolicyd, Without updating or remove it, all chmod commands have no effects at all in Rocky linux.