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

nvm: command not found #1342

Closed
ryanpcmcquen opened this issue Oct 30, 2017 · 16 comments
Closed

nvm: command not found #1342

ryanpcmcquen opened this issue Oct 30, 2017 · 16 comments
Labels
bug 🐛 Bugs with Chromebrew itself question 🙋 Questions about Chromebrew or related from a user (consider opening a discussion instead)

Comments

@ryanpcmcquen
Copy link
Contributor

I've just installed Chromebrew on a fresh machine and ran crew install nvm. Even after opening a new shell, the nvm command is not found. Is this the expected behavior?

@uberhacker
Copy link
Collaborator

@ryanpcmcquen: Try exiting the shell and then log back in. I'm guessing ~/.bashrc wasn't sourced and was causing the nvm command not to execute.

@uberhacker uberhacker added question 🙋 Questions about Chromebrew or related from a user (consider opening a discussion instead) bug 🐛 Bugs with Chromebrew itself labels Oct 30, 2017
@ryanpcmcquen
Copy link
Contributor Author

ryanpcmcquen commented Oct 30, 2017

Nope. The fix was setting NVM_DIR="/usr/local/.nvm", then running /usr/local/share/nvm/install.sh.

@ryanpcmcquen
Copy link
Contributor Author

The install should have a hook to run that script, with the correct NVM_DIR, because the default is $HOME which will not have the correct write permissions.

@uberhacker
Copy link
Collaborator

Just out of curiosity, what is the output of your ~/.bashrc?

@ryanpcmcquen
Copy link
Contributor Author

# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
        # Shell is non-interactive.  Be done now!
        return
fi


# Put your fun stuff here.

export NVM_DIR="/usr/local/.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

cd ~/Downloads/

@mjackson
Copy link

Thanks for the fix, @ryanpcmcquen. Worked well for me.

Do you know why $HOME doesn't have the correct write permissions? Seems weird that chronos isn't able to write stuff to /home/chronos/user.

@ryanpcmcquen
Copy link
Contributor Author

@mjackson, I think that is a Google thing (in other words, outside of Chromebrew's control), but I bet @jam7 would know more.

@mjackson
Copy link

Just found this gem in a crouton issue:

sudo mount -i -o remount,exec /home/chronos/user

Looks like $HOME doesn't have exec by default, but adding that line to ~/.bashrc fixes it.

@ryanpcmcquen
Copy link
Contributor Author

@uberhacker, @cstrouse, @jam7, and @skycocker, what do you think about rolling that into the Chromebrew ~/.bashrc (#1342 (comment)).

@uberhacker
Copy link
Collaborator

Hey @ryanpcmcquen: I have mixed feelings. I'm not a big fan of installing anything package related in the home directory. I know a lot of GitHub projects do it this way, including nvm, but IMHO I don't think it's the most elegant approach in Chrome OS. It looks like this package needs reworked to install correctly in /usr/local/share/nvm instead of ~/.nvm. Since /usr/local is already mounted exec and the chronos user has write access, I believe that is the more appropriate location. I'm completely open to what others have to say about this issue, however.

@mjackson
Copy link

IMO $HOME should have exec by default, just because so much stuff relies on it. nvm and yarn are 2 that come to mind. Adding that line to my ~/.bashrc has fixed a bunch of issues for me.

@uberhacker
Copy link
Collaborator

uberhacker commented Nov 27, 2017

The issue here appears to be the binary is corrupt. If you install via crew install nvm -s, that works fine. We'll need to fix the binary in the future.

@minektur
Copy link
Contributor

minektur commented Dec 5, 2017

I think we ought to document, and tell users to make sure to add /usr/local/bin to their path, but I do not think we should be in the business of modifying people's PATH by default. I'm also somewhat philosophically opposed to remounting ~ with execute perms... My main reasoning is that I like to keep my chromebook as close to what is delivered by google as possible - the less modifications we have to make to get things running the better. I can see why having +x on ~ would be nice, and have occasionally been inconvenienced by it. Now I have just gotten used to making myself a /usr/local/fred directory that I do all my normal work/development in... not idea, but I prefer that over removing yet another protection that chromeos has. That is the other benefit of not changing the mount options. It is done as an extra layer of security feature for normal chromeos usage - my making the place where things get downloaded by the browser -x, it removes a whole class of exploits. Similarly, I go out of my way not to disable the secure boot loader etc.

You can read about the security design of chromeos here:

https://www.chromium.org/chromium-os/chromiumos-design-docs/security-overview

In particular, having the root partion be readonly, and having user home directories be -x is a designe feature I'd like to keep.

All that said, I woudn't be against giving people the option, but I'd be leary of making it an automatic default.

@ryanpcmcquen
Copy link
Contributor Author

Is the binary fixed?

@uberhacker
Copy link
Collaborator

@ryanpcmcquen: We don't have binaries now for this package. It's probably wise to keep it that way. Do you have any problems with the current release?

@ryanpcmcquen
Copy link
Contributor Author

No, I just wanted to verify it was fixed. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Bugs with Chromebrew itself question 🙋 Questions about Chromebrew or related from a user (consider opening a discussion instead)
Projects
None yet
Development

No branches or pull requests

4 participants