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

Add --omit=optional to spago build #86

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MonoidMusician
Copy link

node-gyp was failing to build cpu-features on x86 Darwin (due to some issue with clang, see below), which is an optional npm-wrapped native dependency of ssh2, but it is only used to set default ciphers which doesn't seem relevant.

This patch should make it into a pure node package. Although I still see cpu-features appearing on x86 Linux ...? No idea what's up with that, but at least it seems to build both places now.

Error logs
npm ERR! code 1
npm ERR! path /private/tmp/nix-build-spago-0.93.28.drv-0/package/node_modules/cpu-features
npm ERR! command failed
npm ERR! command sh -c node buildcheck.js > buildcheck.gypi && node-gyp rebuild
npm ERR! make: Entering directory '/private/tmp/nix-build-spago-0.93.28.drv-0/package/node_modules/cpu-features/build'
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_linux_or_android.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_aarch64_macos_or_iphone.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_arm_linux_or_android.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_mips_linux_or_android.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_ppc_linux.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_freebsd.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_linux_or_android.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_macos.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/impl_x86_windows.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/filesystem.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/stack_line_reader.o
npm ERR!   CC(target) Release/obj.target/cpu_features/deps/cpu_features/src/string_view.o
npm ERR!   LIBTOOL-STATIC Release/cpu_features.a
npm ERR!   CXX(target) Release/obj.target/cpufeatures/src/binding.o
npm ERR! make: Leaving directory '/private/tmp/nix-build-spago-0.93.28.drv-0/package/node_modules/cpu-features/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.11.1 | darwin | x64
npm ERR! gyp info find Python using Python version 3.11.8 found at "/nix/store/5w2l8qgsinw2gzlm2q61wychfvinsxvx-python3-3.11.8/bin/python3"
npm ERR! gyp WARN read config.gypi ENOENT: no such file or directory, open '/nix/store/656j4m7kj0rklasv69hx649p161zp5r3-nodejs-20.11.1-source/include/node/config.gypi'
npm ERR! gyp info spawn /nix/store/5w2l8qgsinw2gzlm2q61wychfvinsxvx-python3-3.11.8/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/nix/store/c0bc4479fbsdmzam1b50yil1ixcaaz4s-nodejs-20.11.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args 'binding.gyp',
npm ERR! gyp info spawn args '-f',
npm ERR! gyp info spawn args 'make',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/private/tmp/nix-build-spago-0.93.28.drv-0/package/node_modules/cpu-features/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/nix/store/c0bc4479fbsdmzam1b50yil1ixcaaz4s-nodejs-20.11.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/nix/store/656j4m7kj0rklasv69hx649p161zp5r3-nodejs-20.11.1-source/common.gypi',
npm ERR! gyp info spawn args '-Dlibrary=shared_library',
npm ERR! gyp info spawn args '-Dvisibility=default',
npm ERR! gyp info spawn args '-Dnode_root_dir=/nix/store/656j4m7kj0rklasv69hx649p161zp5r3-nodejs-20.11.1-source',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/nix/store/c0bc4479fbsdmzam1b50yil1ixcaaz4s-nodejs-20.11.1/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/nix/store/656j4m7kj0rklasv69hx649p161zp5r3-nodejs-20.11.1-source/$(Configuration)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/private/tmp/nix-build-spago-0.93.28.drv-0/package/node_modules/cpu-features',
npm ERR! gyp info spawn args '-Dnode_engine=v8',
npm ERR! gyp info spawn args '--depth=.',
npm ERR! gyp info spawn args '--no-parallel',
npm ERR! gyp info spawn args '--generator-output',
npm ERR! gyp info spawn args 'build',
npm ERR! gyp info spawn args '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! In file included from ../src/binding.cc:1:
npm ERR! In file included from /nix/store/656j4m7kj0rklasv69hx649p161zp5r3-nodejs-20.11.1-source/src/node.h:73:
npm ERR! In file included from /nix/store/656j4m7kj0rklasv69hx649p161zp5r3-nodejs-20.11.1-source/deps/v8/include/v8.h:21:
npm ERR! In file included from /nix/store/33f0vanq37w3c6p0387fwqpc8qgcnjpv-libcxx-16.0.6-dev/include/c++/v1/memory:884:
npm ERR! In file included from /nix/store/33f0vanq37w3c6p0387fwqpc8qgcnjpv-libcxx-16.0.6-dev/include/c++/v1/__memory/allocate_at_least.h:13:
npm ERR! In file included from /nix/store/33f0vanq37w3c6p0387fwqpc8qgcnjpv-libcxx-16.0.6-dev/include/c++/v1/__memory/allocator_traits.h:14:
npm ERR! In file included from /nix/store/33f0vanq37w3c6p0387fwqpc8qgcnjpv-libcxx-16.0.6-dev/include/c++/v1/__memory/construct_at.h:23:
npm ERR! /nix/store/33f0vanq37w3c6p0387fwqpc8qgcnjpv-libcxx-16.0.6-dev/include/c++/v1/new:355:14: error: no member named 'aligned_alloc' in the global namespace
npm ERR!     return ::aligned_alloc(__alignment, __size > __rounded_size ? __size : __rounded_size);
npm ERR!            ~~^
npm ERR! 1 error generated.
npm ERR! make: *** [cpufeatures.target.mk:133: Release/obj.target/cpufeatures/src/binding.o] Error 1
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack at ChildProcess.<anonymous> (/nix/store/c0bc4479fbsdmzam1b50yil1ixcaaz4s-nodejs-20.11.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:209:23)
npm ERR! gyp ERR! System Darwin 21.6.0
npm ERR! gyp ERR! command "/nix/store/c0bc4479fbsdmzam1b50yil1ixcaaz4s-nodejs-20.11.1/bin/node" "/nix/store/c0bc4479fbsdmzam1b50yil1ixcaaz4s-nodejs-20.11.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /private/tmp/nix-build-spago-0.93.28.drv-0/package/node_modules/cpu-features
npm ERR! gyp ERR! node -v v20.11.1
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

Since node-gyp was failing to build cpu-features on x86 Darwin,
which is an optional dependency of ssh2 but it is only used
to set default ciphers.
@thomashoneyman
Copy link
Owner

Hm — I'm not sure we can remove node-gyp and python3 from the derivation altogether; we at least need the python dependency, at least according to the errors I see running the build for spago-unstable on Linux:

nix build .#spago-unstable

This produces the following error:

npm ERR! code 1
npm ERR! path /build/package/node_modules/better-sqlite3
npm ERR! command failed
npm ERR! command sh -c prebuild-install || node-gyp rebuild --release
npm ERR! prebuild-install warn install EACCES: permission denied, access '/nix/store/lb8yghs9xy8g3m3aqk647jy7dfb4sn5h-spago-0.93.28-npm-deps'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.3.1
npm ERR! gyp info using node@18.17.1 | linux | x64
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
npm ERR! gyp ERR! find Python checking if "python3" can be used
npm ERR! gyp ERR! find Python - "python3" is not in PATH or produced an error
npm ERR! gyp ERR! find Python checking if "python" can be used
npm ERR! gyp ERR! find Python - "python" is not in PATH or produced an error
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack     at PythonFinder.fail (/nix/store/8dargxvfa70wbfr5s6yr5lwmp15nc7ii-nodejs-18.17.1/lib/node_modules/npm/node_modules/node-gyp/l>
npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/nix/store/8dargxvfa70wbfr5s6yr5lwmp15nc7ii-nodejs-18.17.1/lib/node_modules/npm/node_modules/node->
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/nix/store/8dargxvfa70wbfr5s6yr5lwmp15nc7ii-nodejs-18.17.1/lib/node_modules/npm/node_modules/nod>
npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/nix/store/8dargxvfa70wbfr5s6yr5lwmp15nc7ii-nodejs-18.17.1/lib/node_modules/npm/node_module>
npm ERR! gyp ERR! stack     at exithandler (node:child_process:427:5)
npm ERR! gyp ERR! stack     at ChildProcess.errorhandler (node:child_process:439:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:514:28)
npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:289:12)
npm ERR! gyp ERR! stack     at onErrorNT (node:internal/child_process:476:16)
npm ERR! gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
npm ERR! gyp ERR! System Linux 6.5.7
npm ERR! gyp ERR! command "/nix/store/8dargxvfa70wbfr5s6yr5lwmp15nc7ii-nodejs-18.17.1/bin/node" "/nix/store/8dargxvfa70wbfr5s6yr5lwmp15nc7ii-nodejs-18.17>
npm ERR! gyp ERR! cwd /build/package/node_modules/better-sqlite3
npm ERR! gyp ERR! node -v v18.17.1
npm ERR! gyp ERR! node-gyp -v v9.3.1
npm ERR! gyp ERR! not ok

npm ERR! Log files were not written due to an error writing to the directory: /nix/store/lb8yghs9xy8g3m3aqk647jy7dfb4sn5h-spago-0.93.28-npm-deps/_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal

@MonoidMusician
Copy link
Author

hm weird, I don't see that on Fedora. Are you on NixOS?

@thomashoneyman
Copy link
Owner

Yeah, I’m on NixOS. Weird! I’ll take another look at this over the weekend.

@joneshf
Copy link

joneshf commented Aug 25, 2024

In case anyone else needs a fix in the meantime, you ought to be able to add an overlay that passes in the --omit=optional flag. Something like:

final: prev: {
  spago-unstable = prev.spago-unstable.overrideAttrs (previousAttrs: {
    npmInstallFlags = previousAttrs.npmInstallFlags ++ [
      "--omit=optional"
    ];
  });
};

Slap it in your overlays somehow. And you should be able to build.

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

Successfully merging this pull request may close these issues.

3 participants