nvm: command not found

Hello,

I am migrating CI from travis to actions and I am having problems using nvm.
looking at actions/virtual-environments Ubuntu1804-README 
nvm should be available, but when I run my action it errors with:

nvm: command not found

My action and script look like this:

workflow.yml:

jobs:
  test:
    runs-on: ubuntu-latest


    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Build
        shell: bash -l -eo pipefail {0}
        run: .build.sh

.build.sh:

#!/bin/bash

set -eo pipefail

# (re)source nvm if required
command -v nvm >/dev/null 2>&1 || {
  if [[-s "${NVM_DIR}/nvm.sh"]]; then
    source "${NVM_DIR}/nvm.sh"
  elif [[-s "${HOME}/.nvm/nvm.sh"]]; then
    source "${HOME}/.nvm/nvm.sh"
  fi
}

nvm install 12.16.0
nvm use 12.16.0

yarn install --production=true --frozen-lockfile

yarn link

What am I doing wrong here, how do I use the image provided nvm in my script?

Edit:
After looking at the output of the ‘setup job’ step, I see that my action is being run against version 20200323.1  I should have noticed this sooner.

The version (as of making this edit [16 April 2020]) is old, there have been 3 tagged newer releases.
Is getting a version of the virtual envionment this far behind the current release expected?
Am I garanteed (per repo?) to get a consistent version when my action is run or maybe atleast no version older than X (I can see this leading to flakey action outcomes if I sometimes get a version with features and sometimes without)

@lidbetter ,

I have reported this ticket to the appropriate engineering team for further investigation and evaluation. If they have any progress, I will notify you in time, and sometimes the appropriate engineers may directly reply you here.

Hello,

We have confirmed the issue.

New image with NVM was not deployed to some VM machines / pools. Looking at it

Thanks @brightran 

I have updated my original post with some more details.
My action was being run on an older version of the virtual environment, which explains why it wasn’t working.

Is there anything I can do other than wait for updates to be rolled out - is there anywhere I can see progress and/or what possible versions my action could be run on

Hello,
All pools have been updated. Could you please check if nvm works for you?

@lidbetter ,

The engineering team has fixed this issue.

I checked with the following scripts, and I can confirm the  nvm command can work fine on the GitHub-hosted runners now.

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - name: check nvm location
        shell: bash -l -eo pipefail {0}
        run: echo $NVM_DIR

      - name: test nvm command
        shell: bash -l -eo pipefail {0}
        run: nvm ls

Could you please also check this on your side? Any progress, feel free to tell us.

1 Like

Thanks, nvm is now working!

Thanks, nvm is now working for me

Gh-hosted runners have nvm now?  Thank you!

I can finally get rid of the set-output workaround to read my .nvmrc with setup-node.

Hi!

Please, is it still working for you? It’s available according to the list of sw: https://github.com/actions/virtual-environments/blob/ubuntu18/20200604.1/images/linux/Ubuntu1804-README.md

However, I’m getting nvm: command not found with ubuntu-latest right now.

I looked at the HOME directory and .nvm is available so it’s possible to finish the installation:

  export NVM_DIR="$HOME/.nvm"
  source "$NVM_DIR/nvm.sh"

However it doesn’t recognize all the available Node versions according to the list of sw:

node:

    node 8.17.0
    node 10.21.0
    node 12.18.0
    node 14.4.0

Thanks in advance!