Nvm: `nvm update`?

Created on 8 Aug 2012  路  9Comments  路  Source: nvm-sh/nvm

Can we have some functionality in the way of updating nvm? For example, I would prefer to run nvm system update or perhaps how rvm works instead of running git pull within ~/.nvm:

Update RVM to latest development version:

rvm get head

or to stable version:

rvm get stable

update rubygems to latest available:

rvm rubygems latest

or just a version:

rvm rubygems 1.8.16

Most helpful comment

I modified the command (the above one wasn't really working), now I use the following script to update nvm:

#!/bin/bash

set -u

git -C "$NVM_DIR" fetch --tags
TAG=$(git -C "$NVM_DIR" describe --tags `git -C "$NVM_DIR" rev-list --tags --max-count=1`)
echo "Checking out tag $TAG..."
git -C "$NVM_DIR" checkout "$TAG"

. "$NVM_DIR/nvm.sh"

EDIT: I updated the script to be safer.

All 9 comments

I'd rather not do this. It will cause more complexities and problems than good. Is it so hard to cd nvm && git pull when you want to upgrade your nvm version?

Well oddly it does seem a bit complex. Every time I attempt to update nvm something blows up for some strange reason. Please do integrate an update function that guarantees that we'll run this properly. Obviously it should be simple, but something without fail and unequivocally get's in the way.

@ylluminate how do you update? And what are the problems you run into?

Exactly as noted above. I had installed it via homebrew again for good measure, but ended up with the same problem. After removing it and then manually installing it again, it finally worked, but the problem revolved around git being b0rked. I don't have the session up now and I moved on, but the point was simply that if we had a more robust update mechanism that 100% always navigated to the proper folder and initiated the pull, it would be helpful in making sure the update mechanism is clear to users vs leaving question marks.

cd ~/.nvm && git pull would put one on a pre-release version that is highly discouraged; the whole command would be:

cd ~/.nvm && git pull && git checkout `git describe --abbrev=0 --tags`

Too fragile if you ask me.

I modified the command (the above one wasn't really working), now I use the following script to update nvm:

#!/bin/bash

set -u

git -C "$NVM_DIR" fetch --tags
TAG=$(git -C "$NVM_DIR" describe --tags `git -C "$NVM_DIR" rev-list --tags --max-count=1`)
echo "Checking out tag $TAG..."
git -C "$NVM_DIR" checkout "$TAG"

. "$NVM_DIR/nvm.sh"

EDIT: I updated the script to be safer.

+1 for the @ylluminate's proposal

Duplicate of #400.

Would be good to implement as native command bash script that suggested by @mzgol

Was this page helpful?
0 / 5 - 0 ratings