bun icon indicating copy to clipboard operation
bun copied to clipboard

native code napi failures (node-postal)

Open sroussey opened this issue 2 years ago • 5 comments

What version of Bun is running?

0.5.6

What platform is your computer?

Darwin 22.3.0 arm64 arm

What steps can reproduce the bug?

bun add node-postal @types/node-postal

Include node-postal in a file

import { expand } from 'node-postal'

This results in errors:

error: Could not locate the bindings file. Tried:
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/build/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/build/Debug/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/build/Release/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/out/Debug/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/Debug/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/out/Release/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/Release/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/build/default/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/compiled/18.13.0/darwin/arm64/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/addon-build/release/install-root/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/addon-build/debug/install-root/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/addon-build/default/install-root/expand.node
 → /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/lib/binding/node-v108-darwin-arm64/expand.node
      at bindings (/Users/steve/Code/embarc-sec-etl/node_modules/bindings/bindings.js:126:8)
      at /Users/steve/Code/embarc-sec-etl/node_modules/node-postal/index.js:3:4
      at /Users/steve/Code/embarc-sec-etl/src/export/processCommon.ts:4:0

So I try this:

cd node_modules/node-postal
bun install

So, one issue is fixed but the next is not:

❯ ./run.sh
dyld[75263]: missing symbol called
./run.sh: line 3: 75263 Killed: 9               bun run src/cli/cli.ts

What is the expected behavior?

To "just work" ;)

What do you see instead?

see errors above

Additional information

No response

sroussey avatar Feb 22 '23 18:02 sroussey

Is the bindings file actually in the package in node_modules if you check? I wonder if it's not installing due to postinstall

ThatOneBro avatar Feb 22 '23 18:02 ThatOneBro

❯ cd node_modules/node-postal
❯ ll
Permissions Size User  Date Modified Name
.rw-r--r--@  726 steve 19 Feb 13:45  binding.gyp
.rw-r--r--@  106 steve 19 Feb 13:45  index.js
.rw-r--r--@ 1.1k steve 19 Feb 13:45  LICENSE
.rw-r--r--@  943 steve 19 Feb 13:45  package.json
.rw-r--r--@ 4.0k steve 19 Feb 13:45  README.md
drwxr-xr-x@    - steve 22 Feb 10:46  src
drwxr-xr-x@    - steve 22 Feb 10:46  test
❯ bun run install
$ (node-gyp rebuild) || (exit 0)
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | darwin | arm64
gyp info find Python using Python version 3.9.6 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
gyp info spawn args [
gyp info spawn args   '/Users/steve/.volta/tools/image/packages/node-gyp/lib/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/steve/Code/embarc-sec-etl/node_modules/node-postal/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/steve/.volta/tools/image/packages/node-gyp/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/steve/Library/Caches/node-gyp/18.14.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/steve/Library/Caches/node-gyp/18.14.0',
gyp info spawn args   '-Dnode_gyp_dir=/Users/steve/.volta/tools/image/packages/node-gyp/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/Users/steve/Library/Caches/node-gyp/18.14.0/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/steve/Code/embarc-sec-etl/node_modules/node-postal',
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 spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CXX(target) Release/obj.target/expand/src/expand.o
../src/expand.cc:122:9: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
        ret->Set(context, i, e);
        ^~~~~~~~ ~~~~~~~~~~~~~
../src/expand.cc:136:47: warning: 'CreationContext' is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
    v8::Local<v8::Context> context = exports->CreationContext();
                                              ^
/Users/steve/Library/Caches/node-gyp/18.14.0/include/node/v8-object.h:597:3: note: 'CreationContext' has been explicitly marked deprecated here
  V8_DEPRECATED("Use MaybeLocal<Context> GetCreationContext()")
  ^
/Users/steve/Library/Caches/node-gyp/18.14.0/include/node/v8config.h:460:35: note: expanded from macro 'V8_DEPRECATED'
# define V8_DEPRECATED(message) [[deprecated(message)]]
                                  ^
../src/expand.cc:143:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(
    ^~~~~~~~~~~~
../src/expand.cc:149:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(
    ^~~~~~~~~~~~
../src/expand.cc:155:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_NONE").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_NONE));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:156:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_ANY").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_ANY));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:157:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_NAME").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_NAME));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:158:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_HOUSE_NUMBER").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_HOUSE_NUMBER));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:159:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_STREET").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_STREET));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:160:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_UNIT").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_UNIT));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:161:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_LEVEL").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_LEVEL));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:162:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_STAIRCASE").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_STAIRCASE));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:163:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_ENTRANCE").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_ENTRANCE));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:165:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_CATEGORY").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_CATEGORY));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:166:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_NEAR").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_NEAR));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:168:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_TOPONYM").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_TOPONYM));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:169:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_POSTAL_CODE").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_POSTAL_CODE));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:170:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_PO_BOX").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_PO_BOX));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/expand.cc:171:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(context, Nan::New("ADDRESS_ALL").ToLocalChecked(), Nan::New(LIBPOSTAL_ADDRESS_ALL));
    ^~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19 warnings generated.
  SOLINK_MODULE(target) Release/expand.node
ld: warning: dylib (/usr/local/lib/libpostal.dylib) was built for newer macOS version (13.0) than being linked (11.0)
  CXX(target) Release/obj.target/parser/src/parser.o
../src/parser.cc:82:9: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
        o->Set(context, name_key, Nan::New(component).ToLocalChecked());
        ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/parser.cc:83:9: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
        o->Set(context, label_key, Nan::New(label).ToLocalChecked());
        ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/parser.cc:85:9: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
        ret->Set(context, i, o);
        ^~~~~~~~ ~~~~~~~~~~~~~
../src/parser.cc:99:47: warning: 'CreationContext' is deprecated: Use MaybeLocal<Context> GetCreationContext() [-Wdeprecated-declarations]
    v8::Local<v8::Context> context = exports->CreationContext();
                                              ^
/Users/steve/Library/Caches/node-gyp/18.14.0/include/node/v8-object.h:597:3: note: 'CreationContext' has been explicitly marked deprecated here
  V8_DEPRECATED("Use MaybeLocal<Context> GetCreationContext()")
  ^
/Users/steve/Library/Caches/node-gyp/18.14.0/include/node/v8config.h:460:35: note: expanded from macro 'V8_DEPRECATED'
# define V8_DEPRECATED(message) [[deprecated(message)]]
                                  ^
../src/parser.cc:106:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(
    ^~~~~~~~~~~~
../src/parser.cc:112:5: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
    exports->Set(
    ^~~~~~~~~~~~
6 warnings generated.
  SOLINK_MODULE(target) Release/parser.node
ld: warning: dylib (/usr/local/lib/libpostal.dylib) was built for newer macOS version (13.0) than being linked (11.0)
gyp info ok 

Then

❯ ll
Permissions Size User  Date Modified Name
.rw-r--r--@  726 steve 19 Feb 13:45  binding.gyp
drwxr-xr-x@    - steve 22 Feb 10:47  build
.rw-r--r--@  106 steve 19 Feb 13:45  index.js
.rw-r--r--@ 1.1k steve 19 Feb 13:45  LICENSE
.rw-r--r--@  943 steve 19 Feb 13:45  package.json
.rw-r--r--@ 4.0k steve 19 Feb 13:45  README.md
drwxr-xr-x@    - steve 22 Feb 10:46  src
drwxr-xr-x@    - steve 22 Feb 10:46  test

sroussey avatar Feb 22 '23 18:02 sroussey

And now there is a build folder, so looking in there:

❯ ll build
Permissions Size User  Date Modified Name
.rw-r--r--@  121 steve 22 Feb 10:47  binding.Makefile
.rw-r--r--@  15k steve 22 Feb 10:47  config.gypi
.rw-r--r--@ 5.3k steve 22 Feb 10:47  expand.target.mk
.rwxr-xr-x@  30k steve 22 Feb 10:47  gyp-mac-tool
.rw-r--r--@  14k steve 22 Feb 10:47  Makefile
drwxr-xr-x@    - steve 22 Feb 10:47  node_gyp_bins
.rw-r--r--@ 5.3k steve 22 Feb 10:47  parser.target.mk
drwxr-xr-x@    - steve 22 Feb 10:47  Release
❯ ll build/Release
Permissions Size User  Date Modified Name
.rwxr-xr-x@  60k steve 22 Feb 10:47  expand.node
drwxr-xr-x@    - steve 22 Feb 10:47  obj.target
.rwxr-xr-x@  59k steve 22 Feb 10:47  parser.node

sroussey avatar Feb 22 '23 18:02 sroussey

And for completeness:

❯ ll /usr/local/lib
Permissions Size User Date Modified Name
drwxr-xr-x@    - root 28 Jan 13:18  docker
.rwxr-xr-x@ 9.9M root 19 Feb 13:49  libpostal.1.dylib
.rw-r--r--@  13M root 19 Feb 13:49  libpostal.a
lrwxr-xr-x@   17 root 19 Feb 13:49  libpostal.dylib -> libpostal.1.dylib
.rwxr-xr-x@  938 root 19 Feb 13:49  libpostal.la
drwxr-xr-x@    - root 19 Feb 13:49  pkgconfig

sroussey avatar Feb 22 '23 18:02 sroussey

Thank you, we'll look into what's going on here soon

ThatOneBro avatar Feb 22 '23 18:02 ThatOneBro

This will be fixed by #2073 which @alexlamsl is working on

Jarred-Sumner avatar Jun 04 '23 21:06 Jarred-Sumner

Duplicate of #4959

Electroid avatar Oct 25 '23 22:10 Electroid

Fixed by @dylan-conway and @paperdave in #7132

This will be part of the Bun v1.0.17 release, which ships in a few hours from the time of writing.

Jarred-Sumner avatar Dec 12 '23 06:12 Jarred-Sumner