Hi all ! Faced with an issue - pact is not running...
# pact-js
t
Hi all ! Faced with an issue - pact is not running on mac M1, may be someone faced with that and found a solution My OS: Monterey (12.1) nodejs version: 16.14.2 (lst), I am using nvm pact_foundation/pact: 9.7.13 When I am trying to run pact, receiving error:
Copy code
act-node@10.17.2: Pact Binary Error: .../node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/lib/ruby/bin/ruby: line 14: .../node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/lib/ruby/lib/ruby/gems/2.2.0: No such file or directory
Everything works on Windows, but right now I need to run it on mac M1 I will grateful for any advise I also tried a V3 version (but still interesting on not beta option)
Copy code
pact-foundation/pact@beta
with another kind of error:
Copy code
npm WARN deprecated fastify-warning@0.2.0: This module renamed to process-warning
npm ERR! code 1
npm ERR! path /...project_path/node_modules/@pact-foundation/pact-core
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.14.0 | darwin | x64
npm ERR! gyp info find Python using Python version 3.8.9 found at "/Library/Developer/CommandLineTools/usr/bin/python3"
npm ERR! gyp info spawn /Library/Developer/CommandLineTools/usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '...nvm_path/versions/node/v16.14.0/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   '/...project_path/node_modules/@pact-foundation/pact-core/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '...lib_path/Library/Caches/node-gyp/16.14.0/include/node/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=...lib_path/Library/Caches/node-gyp/16.14.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=...lib_path/Library/Caches/node-gyp/16.14.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/...project_path/node_modules/@pact-foundation/pact-core',
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! Traceback (most recent call last):
npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 45, in <module>
npm ERR!     sys.exit(gyp.script_main())
npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 662, in script_main
npm ERR!     return main(sys.argv[1:])
npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 654, in main
npm ERR!     return gyp_main(args)
npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 639, in gyp_main
npm ERR!     generator.GenerateOutput(flat_list, targets, data, params)
npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 2455, in GenerateOutput
npm ERR!     writer.Write(
npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 798, in Write
npm ERR!     self.WriteActions(
npm ERR!   File "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py", line 1005, in WriteActions
npm ERR!     assert " " not in input, (
npm ERR! AssertionError: Spaces in action input filenames not supported (/...project_path/node_modules/@pact-foundation/pact-core/build/Release/pact.node)
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: `gyp` failed with exit code: 1
npm ERR! gyp ERR! stack     at ChildProcess.onCpExit (...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:259:16)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:520:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Darwin 21.2.0
npm ERR! gyp ERR! command "...nvm_path/versions/node/v16.14.0/bin/node" "...nvm_path/versions/node/v16.14.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /...project_path/node_modules/@pact-foundation/pact-core
npm ERR! gyp ERR! node -v v16.14.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok
y
are you running in rosetta or arm64 mode? can you run
uname -m
This is running in
arm64
mode on my m1 mbp, also montery 12.3.1
Copy code
❯ uname -m
arm64
❯ node -v
v16.13.1
❯ cat package.json | grep -e pact
    "test:pact": "cross-env CI=true react-scripts test --testTimeout 30000 pact.spec.js"
    "@pact-foundation/pact": "^9.17.2",
    "@pact-foundation/pact-node": "^10.17.1",
then yarn install
Copy code
[4/4] 🔨  Building fresh packages...
success Saved lockfile.
✨  Done in 43.36s.
❯ find . -name pact-mock-service
./node_modules/.bin/pact-mock-service
./node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/bin/pact-mock-service
./node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/lib/vendor/ruby/2.2.0/bin/pact-mock-service
./node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.83/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.9.0/bin/pact-mock-service
./node_modules/@pact-foundation/pact/node_modules/.bin/pact-mock-service
using this repo as an example
I assume you are on the same network when running both?
t
@Yousaf Nabi (pactflow.io) I am on: x86_64
rosetta something new for me, as mac in common )
will try arm64, thanks !
y
I've just cleared my node modules and installed and ran the pact tests successfully in both arm64 and x86_64 emulation mode with rosetta and both have worked fine, good luck buddy!
t
@Yousaf Nabi (pactflow.io) I tried using arm64, but with the same result. Actually native terminal is using arm64, while other terminals can initially use x86 (vscode etc). In any way does not help, the same with example of your repo, I faced the same error with ruby - pact binary error... May be something else I missed ? Just thinig I made before, after installing docker I ran:
Copy code
softwareupdate --install-rosetta
But I suppose it dost not relate to the problem
y
yeah that shouldn't be an issue, just installing rosetta as it doesn't attach to your shell by default, you have to open it with the rosetta flag you can install the standalone via homebrew https://github.com/pact-foundation/homebrew-pact-ruby-standalone skip the binary install in the pact-js and copy them in manually (It might work if they are installed on the path, via homebrew). we also have the binaries on the website. There was a documented flag for that, I can't find it in the readme atm
I have these two things in my
.zshrc
so that if I use the alias
axbrew
I can download x86_64 packages from brew. The other flag passes in the platform flag to docker run and build otherwise I just had problems, I seem to be in a happy place now whether everything is working across both, I rarely use the rosetta shell.
Copy code
# useful only for Mac OS Silicon M1,
# still working but useless for the other platforms
docker() {
 if [[ `uname -m` == "arm64" ]] && [[ "$1" == "run" || "$1" == "build" ]]; then
    /usr/local/bin/docker "$1" --platform linux/amd64 "${@:2}"
  else
     /usr/local/bin/docker "$@"
  fi
}

# for intel x86_64 brew
alias axbrew='arch -x86_64 /usr/local/homebrew/bin/brew'%
The latest binaries are on the release page https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v1.88.83 This is obviously not the ideal method and there is something else up, which I would love to solve, but maybe this will get you going for now.
t
Thanks a lot ! Will give it a try, starting from manually adding ) Path after installation of pac using npm is really empty - no version 1.88.83 created.. The last one - 1.88.81
y
yeah if the installation fails, it won't rebuild anything in your node_modules. I normally
rm -rf node_modules
to nuke it, before a reinstall if things have gone bork. Is your npm installation completing under the x86_64 arch? but failing under v3? and the same issues seen when trying under arm64?
t
yep, for V3 - under x86_64 and arm64 error exactly the same
m
OK for t he V3 build, it uses Node Gyp. It looks like it’s not happy with spaces in your project path:
Copy code
npm ERR! AssertionError: Spaces in action input filenames not supported (/...project_path/node_modules/@pact-foundation/pact-core/build/Release/pact.node)
Could you please try without any spaces in your working project folder? That will help us fix the problem, if possible
For the current stable build, can you please share an
npm i --verbose
output? (attach a file)
I suspect there is a different issue at play there. Is it a work laptop? It could be a proxy
t
You are totally right, thanks ! Decision was near and much simple - spaces in path... Was small hint with V3 from python:
Copy code
AssertionError: Spaces in action input filenames not supported
In case with path without spaces: With stable version - working as expected both for x86_64 and arm64 With beta version - installation also correct In case of spaces: Logs for stable and beta version I attached
🙌 2