Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

nvm: copied nvm-exec doesn't work, etc #43795

Closed
apjanke opened this issue Sep 10, 2015 · 4 comments
Closed

nvm: copied nvm-exec doesn't work, etc #43795

apjanke opened this issue Sep 10, 2015 · 4 comments

Comments

@apjanke
Copy link
Contributor

apjanke commented Sep 10, 2015

(A couple issues I ran in to with the nvm formula. I can do a PR for any/all of these if you're interested.)

In the caveats for nvm, it tells you to copy nvm-exec to your ~/.nvm "working directory".

Add NVM's working directory to your $HOME path (if it doesn't exist):

  mkdir ~/.nvm

Copy nvm-exec to NVM's working directory

  cp $(brew --prefix nvm)/nvm-exec ~/.nvm/

The copied nvm-exec doesn't work, at least under the current version of NVM. From what I can tell, nvm-exec expects to live in NVM's runtime/installation dir and have nvm.sh immediately next to it; not to be in the data/working $NVM_DIR directory.

[~]
$ brew install nvm
Warning: nvm-0.26.1 already installed
[~]
$ mkdir .nvm
[~]
$ cp $(brew --prefix nvm)/nvm-exec ~/.nvm/
[~]
$ export NVM_DIR=~/.nvm
[~]
$ source $(brew --prefix nvm)/nvm.sh
[~]
$ ~/.nvm/nvm-exec echo "Hello world"
/Users/janke/.nvm/nvm-exec: line 5: /Users/janke/.nvm/nvm.sh: No such file or directory
/Users/janke/.nvm/nvm-exec: line 10: nvm: command not found
No .nvmrc file found
Hello world
[~]
$

It also seems like downloading nvm-exec separately as a resource is redundant, since the NVM distribution contains nvm-exec (at least in the current version), and it's already mode 755. (The nvm-exec stuff was added in 23e2497.)

I'd like to remove the caveats about copying nvm-exec, and try doing the install without a separate nvm-exec resource. Anything I'm overlooking here?

Upgrades

If the user doesn't set $NVM_DIR (which defaults to using the NVM installation directory as the data/working directory, too), will NVM upgrades still lose their existing NVM-managed Node installs? Seems like yes, since brew is installing NVM to a versioned directory. Should we add a note about that in the caveats? Or do something about setting a different default $NVM_DIR? Otherwise, if users don't do the additional installation steps, it looks like things will seem to work fine, but then their Node installs will disappear some day when they do a brew update; brew upgrade.

Misc

Couple other minor points on nvm:

  • The "Add NVM's working directory to your $HOME path" wording sounds odd to me; that sounds more like adding something to your path than creating a new directory under $HOME
  • The nvm.sh should probably be chmod -x since it is only intended for source-ing, and is useless if run as a standalone script/command.
  • Maybe we should add a note about the Homebrew formula being officially unsupported by NVM after all, and link it back to the upstream discussion. Seeing that would have helped me understand the current formula a bit better, and could help future maintainers. (As with This install method is not officially supported #38537 – the "not officially supported" might be understood by default, but the link to that particular upstream discussion would be useful IMHO.)
  • Add a note about loading the bash completions to caveats, too? That requires an explicit user configuration change (nvm.sh doesn't do it for you), and it appears misdocumented on the NVM repo. (It tells you to source it from the $NVM_DIR data/working dir, which only works if you're letting that default to the NVM runtime installation directory, which Homebrew does not do if you've followed the instructions in the caveats. And Homebrew relocates NVM's bash_completion anyway, so it needs custom instructions.)
@dunn
Copy link
Contributor

dunn commented Sep 11, 2015

This all sounds good to me. Adding a caveat about NVM_DIR definitely seems like a good idea, assuming that problem remains (can you check?).

If the bash completion issue is one of bad documentation, I'd suggest just opening a PR upstream to fix it.

@apjanke
Copy link
Contributor Author

apjanke commented Sep 11, 2015

Adding a caveat about NVM_DIR definitely seems like a good idea, assuming that problem remains (can you check?).

Yep, I'll test. Pretty sure it remains, because this is a basic design feature of NVM: it expects to be updated in-place, not to have versioned installs.

If the bash completion issue is one of bad documentation, I'd suggest just opening a PR upstream to fix it.

I'll open a PR upstream to fix the wording. But I think we need to note it in Homebrew regardless because the formula relocates bash_completion as part of the installation.

Will put together a PR once I've tested the upgrade behavior.

@DomT4 DomT4 mentioned this issue Sep 28, 2015
@DomT4
Copy link
Member

DomT4 commented Sep 28, 2015

Wanted to deal with the version update, so jumped on a lot of the issues raised here as well in #44394.

Re the upgrade situation, confirmed:

~> nvm install 0.10.32
~> tree /usr/local/opt/nvm
├── INSTALL_RECEIPT.json
├── LICENSE.md
├── README.markdown
├── bin
│   └── node-v0.10.32-darwin-x64
├── etc
│   └── bash_completion.d
│       └── nvm
├── nvm-exec
├── nvm.sh
└── v0.10.32

Post brew upgrade:

tree usr/local/opt/nvm
├── INSTALL_RECEIPT.json
├── LICENSE.md
├── README.markdown
├── etc
│   └── bash_completion.d
│       └── nvm
├── nvm-exec
└── nvm.sh

But I think we need to note it in Homebrew regardless because the formula relocates bash_completion as part of the installation.

Feel free to chase me in on this. I loathe dealing with completions so didn't tweak that in the PR.

@DomT4 DomT4 closed this as completed in f2cbea2 Sep 28, 2015
@apjanke
Copy link
Contributor Author

apjanke commented Oct 14, 2015

Looks like the caveats automatically contain a note about bash completion when displayed after it has been installed. That seems sufficient.

==> Caveats
[...snip...]
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

@Homebrew Homebrew locked and limited conversation to collaborators Jul 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants