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

SyntaxError from import os in gyp_main.py #3073

Open
ZedThree opened this issue Sep 27, 2024 · 1 comment
Open

SyntaxError from import os in gyp_main.py #3073

ZedThree opened this issue Sep 27, 2024 · 1 comment

Comments

@ZedThree
Copy link

  • Node Version: 22.3.0
  • Platform: Linux 6.10
  • Compiler: gcc 14.2.0
  • Module: "git://github.com/stadelmanma/tree-sitter-fortran.git"
Verbose output (from npm or node-gyp):
npm verbose cli /usr/bin/node22 /usr/bin/npm22
npm info using [email protected]
npm info using [email protected]
npm verbose title npm install
npm verbose argv "--loglevel" "verbose" "install"
npm verbose logfile logs-max:10 dir:/home/peter/.npm/_logs/2024-09-27T13_12_29_014Z-
npm verbose logfile /home/peter/.npm/_logs/2024-09-27T13_12_29_014Z-debug-0.log
npm verbose shrinkwrap failed to load node_modules/.package-lock.json out of date, updated: node_modules
npm http fetch GET 200 https://registry.npmjs.org/node-addon-api 136ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/node-gyp-build 30ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/prebuildify 696ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/npm-run-path 13ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/pump 13ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/node-abi 16ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/mkdirp-classic 18ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/tar-fs 18ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/minimist 22ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/end-of-stream 17ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/once 18ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/tar-stream 18ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/path-key 39ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/semver 65ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/chownr 94ms (cache revalidated)
npm http fetch GET 200 https://registry.npmjs.org/wrappy 3ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/bl 5ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/inherits 6ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/readable-stream 8ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/fs-constants 14ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/util-deprecate 4ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/buffer 7ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/string_decoder 10ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/base64-js 3ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/ieee754 3ms (cache hit)
npm http fetch GET 200 https://registry.npmjs.org/safe-buffer 2ms (cache hit)
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 184ms
npm http fetch GET 200 https://codeload.github.com/stadelmanma/tree-sitter-fortran/tar.gz/4a593dda9cbc050a6686187249f8350ceea292ce 228ms (cache revalidated)
npm verbose stack Error: git dep preparation failed
npm verbose stack     at promiseSpawn (/usr/lib64/node_modules/npm22/node_modules/@npmcli/promise-spawn/lib/index.js:22:22)
npm verbose stack     at module.exports (/usr/lib64/node_modules/npm22/node_modules/pacote/lib/util/npm.js:13:10)
npm verbose stack     at /usr/lib64/node_modules/npm22/node_modules/pacote/lib/git.js:183:14
npm verbose stack     at async withTempDir (/usr/lib64/node_modules/npm22/node_modules/@npmcli/fs/lib/with-temp-dir.js:21:14)
npm error code 1
npm error git dep preparation failed
npm error command /usr/bin/node22 /usr/lib64/node_modules/npm22/bin/npm-cli.js install --force --cache=/home/peter/.npm --prefer-offline=false --prefer-online=false --offline=false --no-progress --no-save --no-audit --include=dev --include=peer --include=optional --no-package-lock-only --no-dry-run
npm error > [email protected] install
npm error > node-gyp-build
npm error npm verbose cli /usr/bin/node22 /usr/lib64/node_modules/npm22/bin/npm-cli.js
npm error npm info using [email protected]
npm error npm info using [email protected]
npm error npm verbose title npm install
npm error npm verbose argv "install" "--force" "--cache" "/home/peter/.npm" "--prefer-offline" "false" "--prefer-online" "false" "--offline" "false" "--no-progress" "--no-save" "--no-audit" "--include" "dev" "--include" "peer" "--include" "optional" "--no-package-lock-only" "--no-dry-run"
npm error npm verbose logfile logs-max:10 dir:/home/peter/.npm/_logs/2024-09-27T13_12_31_924Z-
npm error npm verbose logfile /home/peter/.npm/_logs/2024-09-27T13_12_31_924Z-debug-0.log
npm error npm warn using --force Recommended protections disabled.
npm error npm http fetch GET 200 https://registry.npmjs.org/node-addon-api 14ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/node-gyp-build 5ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/prebuildify 3ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/mkdirp-classic 7ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/node-abi 8ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/npm-run-path 10ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/tar-fs 11ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/pump 13ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/end-of-stream 7ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/chownr 8ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/tar-stream 9ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/readable-stream 4ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/fs-constants 8ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/bl 8ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/util-deprecate 5ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/string_decoder 6ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/buffer 8ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/ieee754 3ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/base64-js 4ms (cache hit)
npm error npm http fetch GET 200 https://registry.npmjs.org/safe-buffer 2ms (cache hit)
npm error npm info run [email protected] install node_modules/tree-sitter-cli node install.js
npm error npm info run [email protected] install { code: 0, signal: null }
npm error /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/node_modules/node-gyp-build/node-gyp-build.js:60
npm error   throw new Error('No native build was found for ' + target + '\n    loaded from: ' + dir + '\n')
npm error   ^
npm error
npm error Error: No native build was found for platform=linux arch=x64 runtime=node abi=127 uv=1 libc=glibc node=22.3.0
npm error     loaded from: /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa
npm error
npm error     at load.resolve.load.path (/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/node_modules/node-gyp-build/node-gyp-build.js:60:9)
npm error     at load (/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/node_modules/node-gyp-build/node-gyp-build.js:22:30)
npm error     at Object.<anonymous> (/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/node_modules/node-gyp-build/build-test.js:19:19)
npm error     at Module._compile (node:internal/modules/cjs/loader:1460:14)
npm error     at Module._extensions..js (node:internal/modules/cjs/loader:1544:10)
npm error     at Module.load (node:internal/modules/cjs/loader:1275:32)
npm error     at Module._load (node:internal/modules/cjs/loader:1091:12)
npm error     at wrapModuleLoad (node:internal/modules/cjs/loader:212:19)
npm error     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:158:5)
npm error     at node:internal/main/run_main_module:30:49
npm error
npm error Node.js v22.3.0
npm error
npm error gyp info it worked if it ends with ok
npm error gyp verb cli [
npm error gyp verb cli '/usr/bin/node22',
npm error gyp verb cli '/usr/lib64/node_modules/npm22/node_modules/node-gyp/bin/node-gyp.js',
npm error gyp verb cli 'rebuild'
npm error gyp verb cli ]
npm error gyp info using [email protected]
npm error gyp info using [email protected] | linux | x64
npm error gyp verb clean removing "build" directory
npm error gyp verb find Python Python is not set from command line or npm configuration
npm error gyp verb find Python Python is not set from environment variable PYTHON
npm error gyp verb find Python checking if "python3" can be used
npm error gyp verb find Python - executing "python3" to get executable path
npm error gyp verb find Python - executable path is "/usr/bin/python3"
npm error gyp verb find Python - executing "/usr/bin/python3" to get version
npm error gyp verb find Python - version is "3.11.10"
npm error gyp info find Python using Python version 3.11.10 found at "/usr/bin/python3"
npm error gyp verb get node dir no --target version specified, falling back to RPM installed headers
npm error gyp verb build dir attempting to create "build" dir: /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build
npm error gyp verb build dir attempting to create "build" dir: /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build
npm error gyp verb build dir "build" dir needed to be created? Yes
npm error gyp verb build/config.gypi creating config file
npm error gyp verb build/config.gypi writing out config file: /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi
npm error gyp verb build dir "build" dir needed to be created? No
npm error gyp verb build/config.gypi creating config file
npm error gyp verb build/config.gypi writing out config file: /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi
npm error gyp verb config.gypi checking for gypi file: /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/config.gypi
npm error gyp verb common.gypi checking for gypi file: /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/common.gypi
npm error gyp verb gyp gyp format was not specified; forcing "make"
npm error gyp info spawn /usr/bin/python3
npm error gyp info spawn args [
npm error gyp info spawn args '/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'make',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/usr/lib64/node_modules/npm22/node_modules/node-gyp/addon-rpm.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/usr/include/node22/common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=/usr/include/node22',
npm error gyp info spawn args '-Dnode_gyp_dir=/usr/lib64/node_modules/npm22/node_modules/node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=/usr/include/node22/<(target_arch)/node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp info spawn /usr/bin/python3
npm error gyp info spawn args [
npm error gyp info spawn args '/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'make',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/usr/lib64/node_modules/npm22/node_modules/node-gyp/addon-rpm.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/usr/include/node22/common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=/usr/include/node22',
npm error gyp info spawn args '-Dnode_gyp_dir=/usr/lib64/node_modules/npm22/node_modules/node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=/usr/include/node22/<(target_arch)/node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/usr/lib64/node_modules/npm22/node_modules/node-gyp/addon-rpm.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/usr/include/node22/common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=/usr/include/node22',
npm error gyp info spawn args '-Dnode_gyp_dir=/usr/lib64/node_modules/npm22/node_modules/node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=/usr/include/node22/<(target_arch)/node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=/home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error Traceback (most recent call last):
npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/gyp_main.py", line 45, in <module>
npm error     sys.exit(gyp.script_main())
npm error              ^^^^^^^^^^^^^^^^^
npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 688, in script_main
npm error     return main(sys.argv[1:])
npm error            ^^^^^^^^^^^^^^^^^^
npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 680, in main
npm error     return gyp_main(args)
npm error            ^^^^^^^^^^^^^^
npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 647, in gyp_main
npm error     [generator, flat_list, targets, data] = Load(
npm error                                             ^^^^^
npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 157, in Load
npm error     result = gyp.input.Load(
npm error              ^^^^^^^^^^^^^^^
npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2985, in Load
npm error     LoadTargetBuildFile(
npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 400, in LoadTargetBuildFile
npm error     build_file_data = LoadOneBuildFile(
npm error                       ^^^^^^^^^^^^^^^^^
npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 237, in LoadOneBuildFile
npm error     build_file_data = eval(build_file_contents, {"__builtins__": {}}, None)
npm error                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/gyp_main.py", line 7
npm error     import os
npm error     ^^^^^^
npm error SyntaxError: invalid syntax
npm error gyp ERR! configure error 
npm error gyp ERR! stack Error: `gyp` failed with exit code: 1
npm error gyp ERR! stack at ChildProcess.<anonymous> (/usr/lib64/node_modules/npm22/node_modules/node-gyp/lib/configure.js:307:18)
npm error gyp ERR! stack at ChildProcess.emit (node:events:520:28)
npm error gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
npm error gyp ERR! System Linux 6.10.9-1-default
npm error gyp ERR! command "/usr/bin/node22" "/usr/lib64/node_modules/npm22/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm error gyp ERR! cwd /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa
npm error gyp ERR! node -v v22.3.0
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok 
npm error npm verbose stack Error: command failed
npm error npm verbose stack     at promiseSpawn (/usr/lib64/node_modules/npm22/node_modules/@npmcli/promise-spawn/lib/index.js:22:22)
npm error npm verbose stack     at spawnWithShell (/usr/lib64/node_modules/npm22/node_modules/@npmcli/promise-spawn/lib/index.js:124:10)
npm error npm verbose stack     at promiseSpawn (/usr/lib64/node_modules/npm22/node_modules/@npmcli/promise-spawn/lib/index.js:12:12)
npm error npm verbose stack     at runScriptPkg (/usr/lib64/node_modules/npm22/node_modules/@npmcli/run-script/lib/run-script-pkg.js:77:13)
npm error npm verbose stack     at runScript (/usr/lib64/node_modules/npm22/node_modules/@npmcli/run-script/lib/run-script.js:12:10)
npm error npm verbose stack     at async Install.exec (/usr/lib64/node_modules/npm22/lib/commands/install.js:163:9)
npm error npm verbose stack     at async Npm.exec (/usr/lib64/node_modules/npm22/lib/npm.js:207:9)
npm error npm verbose stack     at async module.exports (/usr/lib64/node_modules/npm22/lib/cli/entry.js:74:5)
npm error npm verbose pkgid [email protected]
npm error npm error code 1
npm error npm error path /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa
npm error npm error command failed
npm error npm error command sh -c node-gyp-build
npm error npm verbose cwd /home/peter/.npm/_cacache/tmp/git-cloneXXXXXX53FbOa
npm error npm verbose os Linux 6.10.9-1-default
npm error npm verbose node v22.3.0
npm error npm verbose npm  v10.8.1
npm error npm verbose exit 1
npm error npm verbose code 1
npm error npm error A complete log of this run can be found in: /home/peter/.npm/_logs/2024-09-27T13_12_31_924Z-debug-0.log
npm verbose cwd /home/peter/Tools/tree-sitter/tree-sitter-fixed-form-fortran
npm verbose os Linux 6.10.9-1-default
npm verbose node v22.3.0
npm verbose npm  v10.8.1
npm verbose exit 1
npm verbose code 1
npm error A complete log of this run can be found in: /home/peter/.npm/_logs/2024-09-27T13_12_29_014Z-debug-0.log

I'm getting a very confusing error trying to install a package from GitHub, verbose output above, but I see this in the middle of it:

npm error   File "/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/gyp_main.py", line 7
npm error     import os
npm error     ^^^^^^
npm error SyntaxError: invalid syntax
npm error gyp ERR! configure error 

Now obviously that's completely valid Python, so something else is going on -- but I have no idea where to even begin

@ZedThree
Copy link
Author

I'm still running into this. It looks like the immediate source of the error is this:

npm error gyp info spawn args '/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '/usr/lib64/node_modules/npm22/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',

It's somehow ended up duplicating the first two args, which means it's trying to use gyp_main.py as a build file, which obviously won't work.

I noticed that if I run node-gyp build directly, it works, but it fails as part of npm update

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

1 participant