iterative / setup-cml

GitHub Action for CML setup
25 stars 12 forks source link

Incompatible version of node in latest GitHub ubuntu 20.04 image #53

Closed fcollonval closed 2 years ago

fcollonval commented 2 years ago

In https://github.com/actions/virtual-environments/pull/4395/files, NodeJS 16 has been added to the ubuntu image. I think this is the reason we are hitting that error in our CI although we are using the GitHub actions to use NodeJS 14. Is there a workaround? Or do we need to wait for https://github.com/iterative/cml/issues/825?

casperdcl commented 2 years ago

failing due to an update of NodeJS in the ubuntu image that is incompatible with CML action (to publish the benchmark image).

Error: The module '/usr/local/lib/node_modules/@dvcorg/cml/node_modules/mmmagic/build/Release/magic.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 93. This version of Node.js requires
NODE_MODULE_VERSION 83.

-- https://github.com/jupyterlab/jupyterlab/issues/11606

93 corresponds to node 16. We could also bump to that version in the benchmarks CI workflow?

The trouble is the cml installation that does not apparently use the specified version of node JS but rather one it finds on the os. As GitHub recently added nodejs 16 to the Ubuntu 20.04 image, that breaks CML. This is not related to our code. I opened an issue upstream. No answer yet

-- https://github.com/jupyterlab/jupyterlab/pull/11607#issuecomment-986260326

Other relevant info to the above issues:

jobs:
  test:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/setup-node@v2
        with:
          node-version: '14.x'
      - uses: iterative/setup-cml@v1
      - env:
          REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: cml-publish ./benchmark-results/lab-benchmark.png --md >> ./benchmark-results/lab-benchmark.md

Note that setup-cml itself just uses npm found on $PATH to install things: https://github.com/iterative/setup-cml/blob/a7b00a80a68861804bbdd73396f56b81d5ce999f/src/utils.js#L37

Unsure of how best to go about fixing this.

0x2b3bfa0 commented 2 years ago

Original error message

internal/modules/cjs/loader.js:1144
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The module '/usr/local/lib/node_modules/@dvcorg/cml/node_modules/mmmagic/build/Release/magic.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 93. This version of Node.js requires
NODE_MODULE_VERSION 83. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@dvcorg/cml/node_modules/mmmagic/lib/index.js:1:13)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12) {
  code: 'ERR_DLOPEN_FAILED'
}
0x2b3bfa0 commented 2 years ago

Simplified reproducible example

on: workflow_dispatch
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: '14.x'
    - uses: iterative/setup-cml@v1
    - run: cml-publish /dev/null
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Run actions/checkout@v2

Syncing repository: ···
Getting Git version info
Deleting the contents of '/home/runner/work/···/···'
Initializing the repository
Disabling automatic garbage collection
Setting up auth
Fetching the repository
Determining the checkout info
Checking out the ref
/usr/bin/git log -1 --format='%H'
'···'

Run actions/setup-node@v2

with:
  node-version: 14.x
  always-auth: false
  check-latest: false
  token: ***
Found in cache @ /opt/hostedtoolcache/node/14.18.1/x64

Run iterative/setup-cml@v1

Uninstalling previous CML
Installing CML version latest

Run cml-publish /dev/null

internal/modules/cjs/loader.js:1144
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The module '/usr/local/lib/node_modules/@dvcorg/cml/node_modules/mmmagic/build/Release/magic.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 93. This version of Node.js requires
NODE_MODULE_VERSION 83. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1144:18)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@dvcorg/cml/node_modules/mmmagic/lib/index.js:1:13)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12) {
  code: 'ERR_DLOPEN_FAILED'
}
0x2b3bfa0 commented 2 years ago

Minimal reproducible example

on: workflow_dispatch
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/setup-node@v2
      with:
        node-version: '14.x'
    - run: |
        set -x
        sudo npm --version
        npm --version
        sudo node --version
        node --version

Run actions/setup-node@v2

Found in cache @ /opt/hostedtoolcache/node/14.18.1/x64

Run set -x

+ sudo npm --version
8.1.0
+ npm --version
6.14.15
+ sudo node --version
v16.13.0
+ node --version
v14.18.1
0x2b3bfa0 commented 2 years ago

Minimal working example

on: workflow_dispatch
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: '14.x'
    - uses: iterative/setup-cml@v1
      with:
        sudo: false
    - run: cml-publish /dev/null
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
0x2b3bfa0 commented 2 years ago

Apparently, setup-node@v2 install the requested node version at the user level, not at the system level.

On the other hand, setup-cml@v1 uses sudo by default for the installation process, causing mmmagic to build against the default node version, as opposed to the specified one.

Subsequent workflow steps will try to run cml with the specified node version, but resorting to the native modules built for the default version.

casperdcl commented 2 years ago

@fcollonval should be fixed now!

fcollonval commented 2 years ago

Thanks a lot @0x2b3bfa0 and @casperdcl for fixing this.