Skip to content

"unbound variable" error when running nvm from post-receive hook #1363

Closed

Description

@Znarkus

Running (cd /home/user/app2/2016-12-25-19.28.59 && nvm i && nvm use)

remote: Found '/home/user/app2/2016-12-25-19.28.59/.nvmrc' with version <6.9.2>
remote: /home/user/.nvm/nvm.sh: line 2250: PROVIDED_REINSTALL_PACKAGES_FROM: unbound variable
remote: /home/user/.nvm/nvm.sh: line 2253: PROVIDED_REINSTALL_PACKAGES_FROM: unbound variable

I removed this from .bashrc to make sure environment is setup properly.

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

Any idea what I'm doing wrong?

Activity

  1. PeterDaveHello commented on Dec 25, 2016

    @PeterDaveHello
    Collaborator

    I think you didn't provide enough info @Znarkus, what's the define of post-receive hook here? What's the shell been using here?

  2. Znarkus commented on Dec 25, 2016

    @Znarkus
    Author

    Sorry just upgraded 0.32.0 -> 0.32.1 and the error changed to:

    remote: /home/user/.nvm/nvm.sh: line 374: NVM_FLAVOR: unbound variable
    remote: /home/user/.nvm/nvm.sh: line 2375: NVM_INSTALL_SUCCESS: unbound variable
    

    Post-receive hook:

    #!/bin/bash
    
    source $HOME/.bashrc
    
    set -u
    set -e
    
    NEW_DIR="$HOME/app2/`date +%Y-%m-%d-%H.%M.%S`"
    CURRENT_DIR=$HOME/app2/current
    REPO_DIR="$HOME/app2/repo"
    GIT_DIR="$HOME/project.git"
    
    mkdir -p $REPO_DIR
    
    git --work-tree="$REPO_DIR" --git-dir="$GIT_DIR" checkout -f
    git --work-tree="$REPO_DIR" checkout-index -a --prefix="$NEW_DIR/"
    (cd "$NEW_DIR" && nvm i && nvm use && npm i --production && npm run build)
    rm -f "$CURRENT_DIR"
    ln -s "$NEW_DIR" "$CURRENT_DIR"
    sudo restart project
    

    Bash is the shell on the local computer I'm doing git push from, and bash is the default for the remote user.

  3. PeterDaveHello commented on Dec 25, 2016

    @PeterDaveHello
    Collaborator

    @Znarkus would you please how did you install and upgrade nvm?

  4. Znarkus commented on Dec 25, 2016

    @Znarkus
    Author

    curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash

  5. ljharb commented on Dec 25, 2016

    @ljharb
    Member

    @Znarkus what bash options do you have set? what does nvm debug output? I see in your hook that you have the u and e options set, but I'm not able to reproduce these errors with that.

    Either way, I can address the NVM_INSTALL_SUCCESS and NVM_FLAVOR errors.

  6. added
    needs followupWe need some info or action from whoever filed this issue/PR.
    on Dec 25, 2016
  7. reopened this on Dec 26, 2016
  8. added 3 commits that reference this issue on Apr 9, 2018
    4ada3f8
    939c2a1
    208570d
  9. added 2 commits that reference this issue on Feb 1, 2024
    60239e3
    853afbf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs followupWe need some info or action from whoever filed this issue/PR.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions