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

Cannot install canvas on apple silicon #2365

Open
1 task done
EdwardMoyse opened this issue Mar 19, 2024 · 13 comments
Open
1 task done

Cannot install canvas on apple silicon #2365

EdwardMoyse opened this issue Mar 19, 2024 · 13 comments

Comments

@EdwardMoyse
Copy link

EdwardMoyse commented Mar 19, 2024

Issue or Feature

I have done: brew install pkg-config cairo pango libpng jpeg giflib librsvg

And I have tried many, many other ways to get around this (some of which are listed here)

But I still cannot install canvas on Apple silicon. Failure is:

In file included from /Users/emoyse/Library/Caches/node-gyp/21.7.1/include/node/v8-array-buffer.h:12:
/Users/emoyse/Library/Caches/node-gyp/21.7.1/include/node/v8-local-handle.h:253:5: error: static assertion failed due to requirement 'std::is_base_of<v8::Value, v8::Data>::value': type check
    static_assert(std::is_base_of<T, S>::value, "type check");
    ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../nan/nan_callbacks_12_inl.h:175:20: note: in instantiation of function template specialization 'v8::Local<v8::Value>::Local<v8::Data>' requested here
      cbinfo(info, obj->GetInternalField(kDataIndex));
                   ^

N.B. we don't actually have a direct dependency on canvas from phoenix, but get it from a package we use jsroot.

emoyse@macminim1umass phoenix % yarn why canvas
└─ jsroot@npm:7.6.0
   └─ canvas@npm:2.11.2 (via npm:^2.11.2)

Steps to Reproduce

git clone https://github.com/HSF/phoenix.git 
cd phoenix 
yarn install

This will fail with:

➤ YN0009: │ canvas@npm:2.11.2 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/j6/cv3xx2910nx_pg7v2t8czqzc0000gn/T/xfs-bf1ea463/build.log)

(build.log is attached)

What is weird is checking out node-canvas and doing yarn install there seems to work... the only obvious difference I see in the log files is node-gyp version:

< gyp info using node-gyp@10.0.1
---
> gyp info using node-gyp@9.3.1

Your Environment

  • yarn --version : 3.3.1
  • Version of node-canvas: v2.11.2
  • Environment: node 21.7.1 on macOS 14.3.1, Apple M1

build.log

@neumartin
Copy link

Try this before, I think you miss pixman

brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

@mn4367
Copy link

mn4367 commented Mar 19, 2024

Maybe this and the following comment helps.

@capnslipp
Copy link

@neumartin The issue with this is some of those brew packages now depend on python@3.12. The node-gyp build errors our team is seeing seem to not occur on python@3.11 but do on python@3.12.

@capnslipp
Copy link

@EdwardMoyse python3 --version?

@fourbytes
Copy link

Had the same issue (on node 21.7.1), downgrading node fixed it.

brew install node@20
export PATH="/opt/homebrew/opt/node@20/bin:$PATH"

@capnslipp
Copy link

@fourbytes We've had luck with node@20 and node@18 (but not the latest node@18 version of 18.19.1; had to switch to using nvm so I could pin to node 18.13.0), but only if on python@3.11.

@EdwardMoyse
Copy link
Author

@neumartin The issue with this is some of those brew packages now depend on python@3.12. The node-gyp build errors our team is seeing seem to not occur on python@3.11 but do on python@3.12.

Is it the same error as I'm reporting? Because if it's diskutils related, then I think you can fix it with pip3 install setuptools

@EdwardMoyse
Copy link
Author

@EdwardMoyse python3 --version?

3.12.2

@EdwardMoyse
Copy link
Author

EdwardMoyse commented Mar 21, 2024

Had the same issue (on node 21.7.1), downgrading node fixed it.

brew install node@20
export PATH="/opt/homebrew/opt/node@20/bin:$PATH"

Bingo! This seems to be the answer (or at least, a clue). Downgrading to v18.19.1 worked for me. I did some more tests using nwm:

Version Result
v18.19.1 Succeeds
v20.11.1 Succeeds
v21.7.1 Fails

@dy-dx
Copy link

dy-dx commented Mar 28, 2024

@neumartin The issue with this is some of those brew packages now depend on python@3.12. The node-gyp build errors our team is seeing seem to not occur on python@3.11 but do on python@3.12.

Is it the same error as I'm reporting? Because if it's diskutils related, then I think you can fix it with pip3 install setuptools

For me, pip3 install setuptools fails with:

error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-brew-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.

    If you wish to install a non-brew packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

pip3 install setuptools --break-system-packages does seem to work, but this works too:

brew install python-setuptools

@capnslipp
Copy link

@dy-dx That's an LLVM target triple in the form of “ARCHITECTURE-VENDOR-OPERATING_SYSTEM”. So the unknown part I believe should be “apple”, since valid triples look like “i386-apple-darwin10” (not at my Mac RN, but I'll check later what an M2 reports).

@igloo1505
Copy link

I'm currently facing the same issue. Can we get some sort of poll going, how is everyone that's struggling installing both Python and Canvas?
For me I have Conda installed with a few environments, although it takes some finagling to get Node to use the conda environment and not the Homebrew installed Python version, and I'm using pnpm in a pretty large monorepo.
I keep getting errors about node-gyp being unable to find gobject-2.0 in the PKG_CONFIG path. If this was true in the beginning, it's certainly not true now since I added it to that path explicitly, so I'm guessing that it's either that this is just an inaccurate error message that wasn't caught early enough to give accurate information, or that the node environment and python environment are looking different things?

@igloo1505
Copy link

igloo1505 commented Mar 31, 2024

I'm currently facing the same issue. Can we get some sort of poll going, how is everyone that's struggling installing both Python and Canvas? For me I have Conda installed with a few environments, although it takes some finagling to get Node to use the conda environment and not the Homebrew installed Python version, and I'm using pnpm in a pretty large monorepo. I keep getting errors about node-gyp being unable to find gobject-2.0 in the PKG_CONFIG path. If this was true in the beginning, it's certainly not true now since I added it to that path explicitly, so I'm guessing that it's either that this is just an inaccurate error message that wasn't caught early enough to give accurate information, or that the node environment and python environment are looking different things?

Ok. Right after I sent this I think I got it, but I'm not sure exactly how, and I'm scared to test it and break things again. This is my PKG_CONFIG_PATH env variable now. I had most of this in there to begin with, from what I can gather it's one of these two things, but I can't promise that this was the solution:

# The path that worked:
export PKG_CONFIG_PATH="/opt/homebrew/opt/postgresql@15/lib/pkgconfig:/opt/homebrew/Cellar/glib/2.80.0_2/lib/pkgconfig:/opt/homebrew/opt/glib/lib/pkgconfig:/opt/homebrew/cellar/pkg-config"
  1. Adding this last bit: /opt/homebrew/cellar/pkg-config
  2. Adding the glib libraries that point directly to the pkgconfig directory instead of it's parent directory. I know literally nothing about Go, so someone from that community is going to have to fill me in on whether or not that makes any sense at all.

This is with Node 21.7.1 installed with homebrew, 3.11.8 in a conda environment, and pnpm 9.0.0-beta.1 in a TurboRepo, and on an M1 chip. I just confirmed that it works with python 3.12.2 as well, also in a conda environment.

I had also tried a few different versions of Node with nvm, a couple different versions of python with both Conda and Homebrew, and the stable version of pnpm. So far, this is the only combination that worked.

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

No branches or pull requests

7 participants