nvm: Unable to upgrade manually according to doc

Tried the following from your docs to upgrade nvm manually

(
  cd "$NVM_DIR"
  git fetch origin
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
) && \. "$NVM_DIR/nvm.sh"

but that prints me a git error:

┌─( /Users/michael-heuberger/.nvm 7ad6d98
cd "$NVM_DIR"
  git fetch origin
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" origin`
) && \. "$NVM_DIR/nvm.sh"
CONTRIBUTING.md      LICENSE.md           README.md            alias                bin                  nvm-exec             package.json         update_test_mocks.sh
Dockerfile           Makefile             ROADMAP.md           bash_completion      install.sh           nvm.sh               test                 versions
fatal: Not a valid object name origin

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 20 (14 by maintainers)

Commits related to this issue

Most upvoted comments

nope, on git 1.8.3.1 running git fetch beforehand changes nothing. also, the current upgrade script already does git fetch anyway. it appears to be that git fetch in my context doesn’t actually pull down tags, so it always thinks it’s at the latest version? some insight: https://stackoverflow.com/questions/1204190/does-git-fetch-tags-include-git-fetch

update 1

through some testing on my own box (completely remove .nvm, reinstall 0.33.9 fresh, run manual upgrade script with custom git fetch) it appears I’ve got something that works.

(
  cd "$NVM_DIR"
  git fetch --tags origin
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"

the key detail being the --tags flag to git fetch. given the way that nvm is currently tagged, it seems that simply adding --tags is sufficient to get older git to detect the updated tag list, and thus allow upgrades. submitting a pr shortly, but feel free to contend it if I’m wrong!

update 2

https://github.com/creationix/nvm/pull/1793

Well crap, i thought that might do it.

I’m still not sure what’s going on; I’ll think more on it.

same here

└─( 2 ) ❱❱❱ git describe origin
fatal: Not a valid object name origin