I'm not sure what the deal is, but I keep getting a Permission denied error when trying to use nvm on Chrome OS.
Operating system and version: Chrome OS 62
nvm debug output:
chronos@localhost ~ $ whoami
chronos
chronos@localhost ~ $ nvm debug
nvm --version: v0.33.6
$SHELL: /bin/bash
$HOME: /home/chronos/user
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 4.3.42(1)-release (x86_64-cros-linux-gnu)'
uname -a: 'Linux 4.4.79-11654-g7e0f59a105a1 #1 SMP PREEMPT Mon Nov 13 16:37:19 PST 2017 x86_64 Intel(R) Core(TM) i5-7Y57 CPU @ 1.20GHz GenuineIntel GNU/Linux'
OS version: Developer Console
curl: /usr/bin/curl, curl 7.55.1 (x86_64-cros-linux-gnu) libcurl/7.55.1 OpenSSL/1.0.2k zlib/1.2.11
wget: /usr/bin/wget, GNU Wget 1.19.1 built on linux-gnu.
git: /usr/local/bin/git, git version 2.14.1
grep: /bin/grep (grep --colour=auto), grep (GNU grep) 2.21
awk: not an option: --version
awk: /usr/bin/awk,
sed: /bin/sed, sed (GNU sed) 4.2.2
cut: /usr/bin/cut, cut (GNU coreutils) 8.25
basename: /usr/bin/basename, basename (GNU coreutils) 8.25
rm: /bin/rm, rm (GNU coreutils) 8.25
mkdir: /bin/mkdir, mkdir (GNU coreutils) 8.25
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.4.2
nvm current:
which node: $NVM_DIR/versions/node/v8.9.1/bin/node
which iojs: which: no iojs in ($NVM_DIR/versions/node/v8.9.1/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin)
which npm: $NVM_DIR/versions/node/v8.9.1/bin/npm
npm config get prefix: bash: $NVM_DIR/versions/node/v8.9.1/bin/npm: Permission denied
npm root -g: bash: $NVM_DIR/versions/node/v8.9.1/bin/npm: Permission denied
nvm ls output:chronos@localhost ~ $ nvm ls
v8.9.1
default -> 8 (-> v8.9.1)
node -> stable (-> v8.9.1) (default)
stable -> 8.9 (-> v8.9.1) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.9.1)
lts/argon -> v4.8.6 (-> N/A)
lts/boron -> v6.12.0 (-> N/A)
lts/carbon -> v8.9.1
How did you install nvm? (e.g. install script in readme, homebrew): nvm README install script
What steps did you perform?
chronos@localhost ~ $ nvm use 8
bash: /home/chronos/user/.nvm/versions/node/v8.9.1/bin/npm: Permission denied
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v8.9.1` to unset it.
chronos@localhost ~ $ nvm use --delete-prefix 8
bash: /home/chronos/user/.nvm/versions/node/v8.9.1/bin/npm: Permission denied
bash: /home/chronos/user/.nvm/versions/node/v8.9.1/bin/npm: Permission denied
I got a Permission denied error.
No error.
.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?No.
curl -I --compressed -v https://nodejs.org/dist/ print out?chronos@localhost ~ $ curl -I --compressed -v https://nodejs.org/dist/
* Trying 104.20.22.46...
* TCP_NODELAY set
* Connected to nodejs.org (104.20.22.46) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: /etc/ssl/certs
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use http/1.1
* Server certificate:
* subject: OU=Domain Control Validated; OU=PositiveSSL Wildcard; CN=*.nodejs.org
* start date: Aug 14 00:00:00 2017 GMT
* expire date: Nov 20 23:59:59 2019 GMT
* subjectAltName: host "nodejs.org" matched cert's "nodejs.org"
* issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO RSA Domain Validation Secure Server CA
* SSL certificate verify ok.
> HEAD /dist/ HTTP/1.1
> Host: nodejs.org
> User-Agent: curl/7.55.1
> Accept: */*
> Accept-Encoding: deflate, gzip
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Date: Mon, 27 Nov 2017 01:35:36 GMT
Date: Mon, 27 Nov 2017 01:35:36 GMT
< Content-Type: text/html
Content-Type: text/html
< Connection: keep-alive
Connection: keep-alive
< Set-Cookie: __cfduid=dcb9686cb6c5014486b1940867273d47f1511746536; expires=Tue, 27-Nov-18 01:35:36 GMT; path=/; domain=.nodejs.org; HttpOnly
Set-Cookie: __cfduid=dcb9686cb6c5014486b1940867273d47f1511746536; expires=Tue, 27-Nov-18 01:35:36 GMT; path=/; domain=.nodejs.org; HttpOnly
< CF-Cache-Status: HIT
CF-Cache-Status: HIT
< Vary: Accept-Encoding
Vary: Accept-Encoding
< Expires: Mon, 27 Nov 2017 05:35:36 GMT
Expires: Mon, 27 Nov 2017 05:35:36 GMT
< Cache-Control: public, max-age=14400
Cache-Control: public, max-age=14400
< Server: cloudflare-nginx
Server: cloudflare-nginx
< CF-RAY: 3c415a0b7c919829-LAX
CF-RAY: 3c415a0b7c919829-LAX
< Content-Encoding: gzip
Content-Encoding: gzip
<
* Connection #0 to host nodejs.org left intact
Hmm, it looks like $HOME doesn't have exec by default in Chrome OS. I found a solution that works for me in a crouton issue:
sudo mount -i -o remount,exec /home/chronos/user
I just put that in my ~/.bashrc and now $HOME has the correct permissions.
Thanks, I'd have had no idea how to debug that :-)
@mjackson I've been searching for a solution to this for hours. Thank you so much for posting it here.
Hi @mjackson, just wanted to thank you very much. I was about to abandon developing on my Chromebook, because I could not run any npm commands! Hmm, I wander a bit how people are expected to develop on Chrome OS, whith such basic bugs...
There is another way to do this that is way worse but i cant remember it... Thank you so much this is so clean and perfecto.
but yeah for serious dev, which i once did when it first came out i found ubuntu chroot much more useful than crew, and it can run nvm, node easy.
Most helpful comment
Hmm, it looks like
$HOMEdoesn't haveexecby default in Chrome OS. I found a solution that works for me in a crouton issue:I just put that in my
~/.bashrcand now$HOMEhas the correct permissions.