baileyherbert / utimes

🕓 Cross-platform native addon to change the btime, mtime, and atime of files in Node.js.
https://npmjs.com/utimes
MIT License
47 stars 6 forks source link

Installation crashes on latest macOS Ventura 13.6 #26

Open Offirmo opened 1 year ago

Offirmo commented 1 year ago

Hi, thanks a lot for this very useful module!

Unfortunately I can't install it anymore since the last OS update.

Error:

gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
  LIBTOOL-STATIC Release/nothing.a
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
  CXX(target) Release/obj.target/utimes/cpp/binding.o
../cpp/binding.cc:63:4: error: use of undeclared identifier 'assert'
                        assert(sizeof(attrBuf) == attrBuf.ssize);
                        ^
1 error generated.
make: *** [Release/obj.target/utimes/cpp/binding.o] Error 1

Full trace:

error /Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes: Command failed.
Exit code: 1
Command: node-pre-gyp install --fallback-to-build
Arguments:
Directory: /Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.11
node-pre-gyp info using node@18.18.0 | darwin | arm64
node-pre-gyp info check checked for "/Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes/lib/binding/napi-v3/utimes.node" (not found)
node-pre-gyp http GET https://github.com/baileyherbert/utimes/releases/download/v5.2.0/utimes-v5.2.0-napi-v3-darwin-arm64.tar.gz
node-pre-gyp ERR! install response status 404 Not Found on https://github.com/baileyherbert/utimes/releases/download/v5.2.0/utimes-v5.2.0-napi-v3-darwin-arm64.tar.gz
node-pre-gyp WARN Pre-built binaries not installable for utimes@5.2.0 and node@18.18.0 (node-v108 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/baileyherbert/utimes/releases/download/v5.2.0/utimes-v5.2.0-napi-v3-darwin-arm64.tar.gz
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@18.18.0 | darwin | arm64
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@18.18.0 | darwin | arm64
gyp info find Python using Python version 3.11.5 found at "/opt/homebrew/opt/python@3.11/bin/python3.11"
gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
gyp info spawn args [
gyp info spawn args   '/Users/offirmo/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/offirmo/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/offirmo/Library/Caches/node-gyp/18.18.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/offirmo/Library/Caches/node-gyp/18.18.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/offirmo/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/offirmo/Library/Caches/node-gyp/18.18.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@18.18.0 | darwin | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
  LIBTOOL-STATIC Release/nothing.a
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
  CXX(target) Release/obj.target/utimes/cpp/binding.o
../cpp/binding.cc:63:4: error: use of undeclared identifier 'assert'
                        assert(sizeof(attrBuf) == attrBuf.ssize);
                        ^
1 error generated.
make: *** [Release/obj.target/utimes/cpp/binding.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/offirmo/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
gyp ERR! System Darwin 22.6.0
gyp ERR! command "/Users/offirmo/.nvm/versions/node/v18.18.0/bin/node" "/Users/offirmo/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes/lib/binding/napi-v3/utimes.node" "--module_name=utimes" "--module_path=/Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes/lib/binding/napi-v3" "--napi_version=9" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
gyp ERR! cwd /Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes
gyp ERR! node -v v18.18.0
gyp ERR! node-gyp -v v9.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/Users/offirmo/.nvm/versions/node/v18.18.0/bin/node /Users/offirmo/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes/lib/binding/napi-v3/utimes.node --module_name=utimes --module_path=/Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes/lib/binding/napi-v3 --napi_version=9 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/@mapbox/node-pre-gyp/lib/util/compile.js:89:23)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1098:16)
node-pre-gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:303:5)
node-pre-gyp ERR! System Darwin 22.6.0
node-pre-gyp ERR! command "/Users/offirmo/.nvm/versions/node/v18.18.0/bin/node" "/Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/offirmo/work/src/off/offirmo-monorepo/stack--2022/node_modules/utimes
node-pre-gyp ERR! node -v v18.18.0
node-pre-gyp ERR! node-pre-gyp -v v1.0.11
node-pre-gyp ERR! not ok

error Error
error     at ChildProcess.<anonymous> (/Users/offirmo/.config/yarn/global/node_modules/bolt/dist/modern/utils/processes.js:128:16)
error     at ChildProcess.emit (node:events:517:28)
error     at maybeClose (node:internal/child_process:1098:16)
error     at ChildProcess._handle.onexit (node:internal/child_process:303:5)

Thanks in advance!

baileyherbert commented 1 year ago

Hi @Offirmo! Thanks for the build logs, and sorry about this.

I tested with the macos-13 ventura runner from GitHub Actions, it's still in beta and only supports x64, but I could not reproduce this issue. Unfortunately, I don't have any Apple devices to play with it myself.

It looks like the problem is that assert() is not declared, though this usually globally available. To be fair, I didn't explicitly include assert.h as I should have, so my best guess is that you have a header file somewhere in your system path which conflicted with it.

I pushed some changes to the main branch to hopefully fix this, but I want to confirm that there are no other conflicts before publishing. Would you be willing to try building directly from the latest code?

git clone https://github.com/baileyherbert/utimes.git utimes-main
cd utimes-main
npm install --ignore-scripts
npm run build

This should build the native binding into lib/binding/napi-v3/utimes.node. Feel free to paste the build logs here if you're not certain whether it succeeded. 🔥

Offirmo commented 1 year ago

Thanks for the answer!

My laptop it a company one installed from scratch a month ago, so it should be quite "clean" (I have a bunch of brew installed though)

I'm testing your branch asap.

Offirmo commented 1 year ago

Hi mate, standard procedure but I reviewed your src before running commands from a stranger :)

Why do you have aws-sdk as a dependency? It doesn't seem related and I couldn't see its usage.

Offirmo commented 1 year ago

The build succeeded:

npm run build

> utimes@0.0.0 build
> node-pre-gyp clean configure build package && copyfiles -f ./build/stage/**/*.tar.gz packages

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@1.0.11
node-pre-gyp info using node@18.18.0 | darwin | arm64
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@18.18.0 | darwin | arm64
gyp info find Python using Python version 3.11.5 found at "/opt/homebrew/opt/python@3.11/bin/python3.11"
gyp info spawn /opt/homebrew/opt/python@3.11/bin/python3.11
gyp info spawn args [
gyp info spawn args   '/Users/offirmo/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/offirmo/work/src/utimes-main/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/offirmo/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/offirmo/Library/Caches/node-gyp/18.18.0/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/offirmo/Library/Caches/node-gyp/18.18.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/offirmo/.nvm/versions/node/v18.18.0/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/offirmo/Library/Caches/node-gyp/18.18.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/offirmo/work/src/utimes-main',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok
gyp info it worked if it ends with ok
gyp info using node-gyp@9.4.0
gyp info using node@18.18.0 | darwin | arm64
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
CC(target) Release/obj.target/nothing/node_modules/node-addon-api/nothing.o
LIBTOOL-STATIC Release/nothing.a
warning: /Library/Developer/CommandLineTools/usr/bin/libtool: archive library: Release/nothing.a the table of contents is empty (no object file members in the library define global symbols)
CXX(target) Release/obj.target/utimes/cpp/binding.o
SOLINK_MODULE(target) Release/utimes.node
COPY /Users/offirmo/work/src/utimes-main/lib/binding/napi-v3/utimes.node
TOUCH Release/obj.target/copy.stamp
gyp info ok
packing napi-v3/utimes.node
node-pre-gyp info package Binary staged at "build/stage/v0.0.0/utimes-v0.0.0-napi-v3-darwin-arm64.tar.gz"
node-pre-gyp info ok
Offirmo commented 1 year ago

FYI I also ran npm test

They succeeded once but they are flaky for the "multiple files" section.

baileyherbert commented 1 year ago

That's great, thank you! I've just released v5.2.1 with the new fix.

Why do you have aws-sdk as a dependency? It doesn't seem related and I couldn't see its usage.

Yeah, that's my bad. I used to deploy prebuilt binaries to Amazon S3, and had a script in the package.json file to publish them. I've just removed that dev dependency, thanks for pointing it out.

They succeeded once but they are flaky for the "multiple files" section.

That's weird... can you paste the test logs here from when it fails? I'd appreciate it!

Offirmo commented 1 year ago

Hi @baileyherbert I fetched the latest, re-built and ran npm test 5 times. It failed 3 times:

Screenshot 2023-09-30 at 15 59 58
Screenshot 2023-09-30 at 16 00 27
Screenshot 2023-09-30 at 16 00 44

I hope this help!

baileyherbert commented 1 year ago

As I suspected, the tests are failing because the atime is wrong when measured. This particular timestamp has always given me some trouble, the very act of querying it can bump it. I'll investigate in a couple days, thank you!

Offirmo commented 1 year ago

Hi @baileyherbert thanks again for your help, feel free to close this issue!