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

Unable to upgrade manually according to doc #1772

Closed
binarykitchen opened this issue Apr 3, 2018 · 20 comments · Fixed by #1793
Closed

Unable to upgrade manually according to doc #1772

binarykitchen opened this issue Apr 3, 2018 · 20 comments · Fixed by #1793
Labels
installing nvm Problems installing nvm itself

Comments

@binarykitchen
Copy link

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
@ljharb
Copy link
Member

ljharb commented Apr 3, 2018

Hmm - what does git remote print out inside $NVM_DIR? Note that nvm must have been initially installed using git (ie, git was available when install.sh was ran) for this to work.

@ljharb ljharb added the installing nvm Problems installing nvm itself label Apr 3, 2018
@binarykitchen
Copy link
Author

$ git remote

prints just

origin

Dont remember how I installed nvm so cant answer that.

@ljharb
Copy link
Member

ljharb commented Apr 3, 2018

What is git --version?

@binarykitchen
Copy link
Author

2.17.0

@joshsleeper
Copy link
Contributor

joshsleeper commented Apr 4, 2018

edit

added second system experiencing the same issues


Seeing the exact same behavior as @binarykitchen on my systems

system 1

  • MX-Linux 17 x86_64, which is based on Debian Stable 9.4 (Stretch), fully patched
  • git 2.11.0
  • nvm 0.33.8

system 2

  • CentOS 7 x68_64, fully patched
  • git 1.8.3.1
  • nvm 0.33.8

@ljharb
Copy link
Member

ljharb commented Apr 4, 2018

And in the git repo (on all three systems described above), what does git describe origin print out?

@joshsleeper
Copy link
Contributor

can't test my debian system until i'm home, but the centos system prints out the same error:

[USER@HOSTNAME .nvm]$ git describe origin
fatal: Not a valid object name origin

@binarykitchen
Copy link
Author

same here

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

@ljharb
Copy link
Member

ljharb commented Apr 5, 2018

That's very confusing. If you git fetch first and then git describe origin, the same thing happens?

@joshsleeper
Copy link
Contributor

centos system, straight from the terminal

[USER@HOSTNAME .nvm]$ git status
# Not currently on any branch.
nothing to commit, working directory clean
[USER@HOSTNAME .nvm]$ git fetch
[USER@HOSTNAME .nvm]$ git describe origin
fatal: Not a valid object name origin

@ljharb
Copy link
Member

ljharb commented Apr 5, 2018

Ok, next try :-) git fetch --unshallow before the describe?

@joshsleeper
Copy link
Contributor

coming right up

[USER@HOSTNAME .nvm]$ git fetch --unshallow
remote: Counting objects: 6396, done.
remote: Compressing objects: 100% (2410/2410), done.
remote: Total 6396 (delta 4191), reused 6156 (delta 3951), pack-reused 0
Receiving objects: 100% (6396/6396), 1.88 MiB | 0 bytes/s, done.
Resolving deltas: 100% (4191/4191), completed with 173 local objects.
[USER@HOSTNAME .nvm]$ git describe origin
fatal: Not a valid object name origin

@ljharb
Copy link
Member

ljharb commented Apr 5, 2018

Well crap, i thought that might do it.

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

PeterDaveHello added a commit to PeterDaveHello/nvm that referenced this issue Apr 12, 2018
@PeterDaveHello
Copy link
Collaborator

I guess this may be a wrong usage, man page of git-describe didn't describe any usage with "remote" name

Usage like out Makefile is correct:
https://github.com/creationix/nvm/blob/master/Makefile#L74

    @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \

@PeterDaveHello
Copy link
Collaborator

PeterDaveHello commented Apr 12, 2018

@binarykitchen @joshsleeper would you like to try the revised version here? Hope it'll work for you!
#1786

@joshsleeper
Copy link
Contributor

#1786 (comment)

ljharb pushed a commit to PeterDaveHello/nvm that referenced this issue Apr 12, 2018
@joshsleeper
Copy link
Contributor

joshsleeper commented Apr 25, 2018

Argh...

So I was pretty sure #1786 fixed things, but here I am on 0.33.9 and the new upgrade script doesn't bump me to 0.33.11 (latest at time of writing)
So maybe it's not quite resolved?

@ljharb
Copy link
Member

ljharb commented Apr 25, 2018

You might need a git fetch as well, beforehand?

@binarykitchen
Copy link
Author

yes, works now

@joshsleeper
Copy link
Contributor

joshsleeper commented Apr 25, 2018

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

#1793

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
installing nvm Problems installing nvm itself
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants