jupyterlab / jupyterlab

JupyterLab computational environment.
https://jupyterlab.readthedocs.io/
Other
14.13k stars 3.36k forks source link

M1 Mac local test runs fail with "Library not loaded: '@rpath/libpixman-1.0.dylib'" dependency error #13938

Closed andrii-i closed 1 year ago

andrii-i commented 1 year ago

Description

Jupyterlab test runs fail locally with "Library not loaded: '@rpath/libpixman-1.0.dylib'" error.

Error: ``` > @jupyterlab/coreutils:test $ jest @jupyterlab/coreutils: FAIL test/pageconfig.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libpixman-1.0.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libpixman-1.0.dylib' (no such file), '/usr/lib/libpixman-1.0.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/url.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libpixman-1.0.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libpixman-1.0.dylib' (no such file), '/usr/lib/libpixman-1.0.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/activitymonitor.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libpixman-1.0.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libpixman-1.0.dylib' (no such file), '/usr/lib/libpixman-1.0.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/markdowncodeblocks.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libpixman-1.0.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libpixman-1.0.dylib' (no such file), '/usr/lib/libpixman-1.0.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/path.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libpixman-1.0.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libpixman-1.0.dylib' (no such file), '/usr/lib/libpixman-1.0.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/time.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libpixman-1.0.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libpixman-1.0.dylib' (no such file), '/usr/lib/libpixman-1.0.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: Test Suites: 6 failed, 6 total @jupyterlab/coreutils: Tests: 0 total @jupyterlab/coreutils: Snapshots: 0 total @jupyterlab/coreutils: Time: 0.226 s ```

Reproduce

  1. Attempt to build and run tests as described in "Build and run tests" section of the contributing guide, for the whole test suite or for separate package
    jlpm run build:testutils
    jlpm test
    cd packages/notebook
    jlpm run build:test
    jlpm test --runInBand
  2. See tests failing with an error described above

Expected behavior

Test runs go through or fail for valid reason

Context

Operating System and version: MacOS 12.6.3 Monterey, Apple M1 Pro chip Browser and version: Chrome version 109.0.5414.87 (Official Build) (arm64) JupyterLab version: 3.6.x, head-of-master (WIP 4.0.0)

krassowski commented 1 year ago

Did you run try running jlpm from the root of the repository to refresh node modules? Sometimes errors like this show up when you pull the latest code but do not refresh the node packages. You can also try jlpm clean and then jlpm What is your node version?

andrii-i commented 1 year ago

Thank you for looking into this. Yes, I tried running jlpm in the root, also just tried running jlpm clean and then jlpm and in both cases error persists. My node version is v19.4.0.

krassowski commented 1 year ago

Did you try running a stable Node version like 18.x?

andrii-i commented 1 year ago

Switched to node 18.14.0 LTS, did a clean install and error still remains.

fcollonval commented 1 year ago

canvas being a binary package is bringing lots of troubles. From the error message, it seems the binary is looking for some system libraries (aka pixman) but does not find them. Did you try installing the package for your OS?

The best to get an answer / fix is certainly to take part into that issue: https://github.com/Automattic/node-canvas/issues/2193

JasonWeill commented 1 year ago

This also occurs for me, on a MacBook Pro with an M1 Pro (Apple Silicon) chip

3coins commented 1 year ago

@andrii-i Can you try this installation page, which has instructions to install these packages from source. https://github.com/Automattic/node-canvas/wiki/Installation%3A-Mac-OS-X

bollwyvl commented 1 year ago

Haters gonna hate, but ol' conda-forge has your back on all of those. A maximally-reproducible environment.yml can solve for all of the below:

conda-lock --file=environment.yml --platform=osx-arm64 --platform=linux-64 --platform=win-64 --platform=osx-64 --kind=explicit
name: jupyterla-dev
channels:
  - conda-forge
  - nodefaults
dependencies:
  # binder
  - jupyterlab-link-share=0.2
  - jupyter_server_fileid
  - jupyter-server-proxy
  - matplotlib-base
  - nodejs=18
  - numpy
  - pip
  - python=3.10
  - vega_datasets
  - xeus-python
  # docs
  - sphinx >=1.8
  - sphinx-copybutton
  - pydata-sphinx-theme
  - pytest
  - pytest-tornasync
  - pytest-check-links
  - jsx-lexer
  - myst-parser
  # screenshots
  - altair
  - ipython
  - ipywidgets
  - jupyterlab-geojson
  - matplotlib-base
  - nbconvert
  - pandas
  - scipy
  - vega_datasets
  # canvas cruft
  - pkgconfig
  - cairo
  - pango
  - libpng
  - libjpeg-turbo
  - giflib
  - librsvg
  - pixman
  # test
  - coverage
  - pytest >=7.0
  - pytest-check-links >=0.7
  - pytest-console-scripts
  - pytest-cov
  - pytest-jupyter >=0.5.3
  - pytest-timeout
  - pytest-tornasync
  - requests
  - requests_cache
  - virtualenv
  # dev
  - build
  - pre-commit
  - pytest-cov
  - coverage
  - hatch
  - bump2version
  - ruff  # ==0.0.242",
  - black-jupyter ==23.1.0

At least, it solves: good luck doing that with pip/brew/choco!

andrii-i commented 1 year ago

@andrii-i Can you try this installation page, which has instructions to install these packages from source. https://github.com/Automattic/node-canvas/wiki/Installation%3A-Mac-OS-X

Tried installing through homebrew and from source as suggested, error still remains

andrii-i commented 1 year ago

Haters gonna hate, but ol' conda-forge has your back on all of those. A maximally-reproducible environment.yml can solve for all of the below:

@bollwyvl Thank you for suggesting a solution, I would be happy with any way to run tests locally.

I have created a conda-lock file based on suggested environment.yml, created new environment from it and installed jupyterlab in this new environment. Tests don't go through but I get a different error now, it has to do with missing cairo library now (even though cairo is already present in the environment.yml file). Do you know how to fix this?

New error: ``` $ jest @jupyterlab/coreutils: FAIL test/pageconfig.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libcairo.2.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/path.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libcairo.2.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/url.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libcairo.2.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/markdowncodeblocks.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libcairo.2.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/activitymonitor.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libcairo.2.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: FAIL test/time.spec.ts @jupyterlab/coreutils: ● Test suite failed to run @jupyterlab/coreutils: dlopen(/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: '@rpath/libcairo.2.dylib' @jupyterlab/coreutils: Referenced from: '/Users/aieroshe/Documents/jupyterlab/node_modules/canvas/build/Release/canvas.node' @jupyterlab/coreutils: Reason: tried: '/usr/local/lib/libcairo.2.dylib' (no such file), '/usr/lib/libcairo.2.dylib' (no such file) @jupyterlab/coreutils: at Object. (../../node_modules/canvas/lib/bindings.js:3:18) @jupyterlab/coreutils: Test Suites: 6 failed, 6 total @jupyterlab/coreutils: Tests: 0 total @jupyterlab/coreutils: Snapshots: 0 total @jupyterlab/coreutils: Time: 0.227 s @jupyterlab/coreutils: Ran all test suites. ```
3coins commented 1 year ago

@andrii-i Installing these packages using homebrew worked for me on an M1 Mac. I still have some tests failing, but they are not because of the package binaries anymore. Here are my installation steps.

# Install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install cairo and dependencies
brew install pkg-config cairo pango libpng jpeg giflib librsvg

I also got rid of my jupyterlab local package and re-cloned it locally. Opened a new terminal (so homebrew paths are activated) and then went through the jupyterlab install/build steps.

pip install -e ".[dev,test]"
jlpm install
jlpm run build
jlpm test

@bollwyvl I tried the conda-lock route as well, but ran into errors during the jlab installation step. Here are the steps I followed.

pip install conda-lock
conda-lock --file=environment.yml --platform=osx-arm64 --kind=explicit
conda create -n jlab-py-3.10 --file conda-osx-arm64.lock
conda activate jlab-py-3.10
pip install -e ".[dev,test]"
bollwyvl commented 1 year ago

conda-lock

My bad: conda-lock was just there to demonstrate that it can solve it, as i don't have all those machines lying around.

Though, of course, checking in "known-good" conda-locks is pretty damned nice for reproducibility.

/usr/local/lib/libcairo.2.dylib

Sure, that's likely to happen for pre-compiled binaries. But usually that crap can be massaged with LD_LIBRARY_PATH.

So maybe something like:

# i like project-local envs, so i can find stuff
mamba env update --prefix=./.venv --file=environment.yml
source activate ./.venv
# prefer binaries you just installed
export LD_LIBRARY_PATH=${CONDA_PREFIX}/lib:$LD_LIBRARY_PATH
# get this out of the way up-front, instead of deep inside `hatch`-land
yarn
# no need to use [extras], you already have them at known versions
python -m pip install -vv -e . --no-deps --ignore-installed
jlpm build
jlpm test
jasongrout commented 1 year ago

Since I keep my m1 macos global environment clean, I regularly have to follow the bullet point in https://jupyterlab.readthedocs.io/en/stable/developer/contributing.html#installing-jupyterlab where it talks about a pixman error, and do:

mamba install -c conda-forge pkg-config glib pango pixman

When I install those packages with conda/mamba, then I can do a dev install and test JupyterLab.

andrii-i commented 1 year ago

@jasongrout this fixed it 🎉, thank you very much!

3coins commented 1 year ago

@jasongrout @fcollonval Given the missing piece here was the pixman library, should we add this explicitly to the first set of instructions in the docs?

conda install -c conda-forge pkg-config pango libpng cairo jpeg giflib librsvg glib **pixman**

It is natural that users might not reach the notes section that comes later, but the initial instructions are not easily missed.

andrii-i commented 1 year ago

I was actually working on editing the docs in #13956 although without adding the command explicitly to the first set of instructions as @3coins mentions (it still would have more visibility in Notes section as currently command is formatted as italics text, not as code that is more visible).

jasongrout commented 1 year ago

Given the missing piece here was the pixman library, should we add this explicitly to the first set of instructions in the docs?

Often these libraries are already installed at the system level, and presumably users will want to use those system libraries if they are installed? I mean, we don't ask them to install git and nodejs using conda, but we could?

I was thinking that making the bullet point more explicit about the possible errors and make it jump out a bit more by making the install instruction a block instead of just inline text would be enough?

3coins commented 1 year ago

Agree that formatting the notes better will help.

andrii-i commented 1 year ago

@3coins @jasongrout updated #13956 to display paragraoph about pixman error and command to fix it as a note element in "Installing JupyterLab" section. Also now string with longer set of conda packages that @3coins suggested is used:

conda install -c conda-forge pkg-config pango libpng cairo jpeg giflib librsvg glib pixman

Updated documentation preview.

DonJayamanne commented 1 year ago

I'm running into this issue on my Mac M1

@jupyterlab/coreutils:  FAIL  test/url.spec.ts
@jupyterlab/coreutils:   ● Test suite failed to run
@jupyterlab/coreutils:     dlopen(/Users/donjayamanne/Desktop/development/vsc/jupyterlab/node_modules/canvas/build/Release/canvas.node, 0x0001): Library not loaded: @rpath/libpixman-1.0.dylib
@jupyterlab/coreutils:       Referenced from: <E241D0E7-A034-3C64-AF79-E45D7487118C> /Users/donjayamanne/Desktop/development/vsc/jupyterlab/node_modules/canvas/build/Release/canvas.node
@jupyterlab/coreutils:       Reason: no LC_RPATH's found
@jupyterlab/coreutils:       at Object.<anonymous> (../../node_modules/canvas/lib/bindings.js:3:18)

I have managed to install using conda and brew without any issues I.e. I tried both of the following

conda install -c conda-forge pkg-config pango libpng cairo jpeg giflib librsvg glib pixman
export PKG_CONFIG_PATH=$CONDA_PREFIX/lib/pkgconfig
brew install pkg-config cairo pango libpng jpeg giflib librsvg

Still no joy.

Sarthug99 commented 9 months ago

I'm facing the same issue again on MacOS (M2).