neon-bindings / neon

Rust bindings for writing safe and fast native Node.js modules.
https://www.neon-bindings.com/
Apache License 2.0
8.04k stars 284 forks source link

Linker error on Win10 #621

Closed cdbrkfxrpt closed 2 years ago

cdbrkfxrpt commented 3 years ago

Hello,

I don't have a lot of experience with all things JS, nor am I particularly well versed in all things Windows, but we need the Windows build and although it did build at one point it now doesn't do and I've been fighting with it for hours, so if there's anything you can tell me about the following error I'd be really thankful for it.

Build environment is Win10 Education N Version 20H2 OS build 19042.572. Everything is correctly pathed from what I can see, I'm using the git bash that comes with git on Windows. That said, the error is the same on the Windows Powershell.

Environment

$ rustup show
Default host: x86_64-pc-windows-msvc
rustup home:  C:\Users\flrn\.rustup

stable-x86_64-pc-windows-msvc (default)
rustc 1.47.0 (18bf6b4f0 2020-10-07)
$ node --version
v15.0.1
$ npm --version
7.0.3
$ yarn --version
1.22.10
$ python --version
Python 3.9.0

Error

$ yarn build_native
yarn run v1.22.10
$ electron-build-env neon build checkmate --release
neon info forcing rebuild for new build settings
neon info running cargo
   Compiling autocfg v1.0.1
   Compiling memchr v2.3.4
   Compiling lazy_static v1.4.0
   Compiling regex-syntax v0.6.21
   Compiling cfg-if v0.1.10
   Compiling cc v1.0.61
   Compiling version_check v0.9.2
   Compiling proc-macro2 v1.0.24
   Compiling unicode-xid v0.2.1
   Compiling cfg-if v1.0.0
   Compiling syn v1.0.48
   Compiling ryu v1.0.5
   Compiling bitflags v1.2.1
   Compiling libc v0.2.80
   Compiling serde_derive v1.0.117
   Compiling lexical-core v0.7.4
   Compiling gimli v0.23.0
   Compiling crc32fast v1.2.1
   Compiling unicode-xid v0.0.4
   Compiling adler v0.2.3
   Compiling semver-parser v0.7.0
   Compiling static_assertions v1.1.0
   Compiling object v0.22.0
   Compiling arrayvec v0.5.2
   Compiling serde v1.0.117
   Compiling quote v0.3.15
   Compiling rustc-demangle v0.1.18
   Compiling rle-decode-fast v1.0.1
   Compiling cslice v0.2.0
   Compiling adler32 v1.2.0
   Compiling libflate_lz77 v1.0.0
   Compiling thread_local v1.0.1
   Compiling neon-build v0.4.0
   Compiling neon-build v0.5.1
   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling miniz_oxide v0.4.3
   Compiling num-rational v0.2.4
   Compiling num-iter v0.1.42
   Compiling num-complex v0.2.4
   Compiling error-chain v0.12.4
   Compiling nom v5.1.2
   Compiling synom v0.11.3
   Compiling semver v0.9.0
   Compiling addr2line v0.14.0
   Compiling syn v0.11.11
   Compiling aho-corasick v0.7.15
   Compiling quote v1.0.7
   Compiling libflate v1.0.3
   Compiling libmate v0.1.0 (C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native)
   Compiling regex v1.4.2
   Compiling num-traits v0.1.43
   Compiling backtrace v0.3.54
   Compiling enum-primitive-derive v0.1.2
   Compiling neon-sys v0.4.0
   Compiling num v0.2.1
   Compiling matfile v0.2.1
error: failed to run custom build command for `neon-sys v0.4.0`

Caused by:
  process didn't exit successfully: `C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\release\build\neon-sys-1096345010ae9bf1\build-script-build` (exit code: 1)
  --- stdout

  > preinstall
  > echo 'Skipping node-gyp installation as part of npm install.'

  'Skipping node-gyp installation as part of npm install.'
  cargo:node_arch=x64
  cargo:node_root_dir=C:\\Users\\flrn\\.electron-gyp\\10.1.4
  cargo:node_lib_file=C:\\Users\\flrn\\.electron-gyp\\10.1.4\\<(target_arch)\\node.lib

  > build-release
  > node-gyp build

  TARGET = Some("x86_64-pc-windows-msvc")
  HOST = Some("x86_64-pc-windows-msvc")
  AR_x86_64-pc-windows-msvc = None
  AR_x86_64_pc_windows_msvc = None
  HOST_AR = None
  AR = None
  running: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX64\\x64\\lib.exe" "-out:C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\release\\build\\neon-sys-2c4c217e95a9ae54\\out\\libneon.a" "-nologo" "C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\release\\build\\neon-sys-2c4c217e95a9ae54\\out\\native\\build\\Release\\obj\\neon\\neon.obj"
  LINK : fatal error LNK1181: cannot open input file 'C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\release\build\neon-sys-2c4c217e95a9ae54\out\native\build\Release\obj\neon\neon.obj'
  exit code: 1181

  --- stderr
  gyp info it worked if it ends with ok
  gyp info using node-gyp@3.6.2
  gyp info using node@15.0.1 | win32 | x64
  gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
  gyp info spawn args [
  gyp info spawn args   'build/binding.sln',
  gyp info spawn args   '/clp:Verbosity=minimal',
  gyp info spawn args   '/nologo',
  gyp info spawn args   '/p:Configuration=Release;Platform=x64'
  gyp info spawn args ]
  gyp ERR! UNCAUGHT EXCEPTION
  gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\MSBuild.exe ENOENT
  gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:269:19)
  gyp ERR! stack     at onErrorNT (node:internal/child_process:465:16)
  gyp ERR! stack     at processTicksAndRejections (node:internal/process/task_queues:80:21)
  gyp ERR! System Windows_NT 10.0.19042
  gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\release\\build\\neon-sys-2c4c217e95a9ae54\\out\\native\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
  gyp ERR! cwd C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\release\build\neon-sys-2c4c217e95a9ae54\out\native
  gyp ERR! node -v v15.0.1
  gyp ERR! node-gyp -v v3.6.2
  gyp ERR! This is a bug in `node-gyp`.
  gyp ERR! Try to update node-gyp and file an Issue if it does not help:
  gyp ERR!     <https://github.com/nodejs/node-gyp/issues>
  npm ERR! code 7
  npm ERR! path C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\release\build\neon-sys-2c4c217e95a9ae54\out\native
  npm ERR! command failed
  npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "node-gyp build"

  npm ERR! A complete log of this run can be found in:
  npm ERR!     C:\Users\flrn\AppData\Local\npm-cache\_logs\2020-11-03T23_44_10_722Z-debug.log

  error occurred: Command "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX64\\x64\\lib.exe" "-out:C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\release\\build\\neon-sys-2c4c217e95a9ae54\\out\\libneon.a" "-nologo" "C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\release\\build\\neon-sys-2c4c217e95a9ae54\\out\\native\\build\\Release\\obj\\neon\\neon.obj" with args "lib.exe" did not execute successfully (status code exit code: 1181).

warning: build failed, waiting for other jobs to finish...
error: build failed
neon ERR! cargo build failed

Error: cargo build failed
    at Target.<anonymous> (C:\Users\flrn\workbench\datalyzer\node_modules\neon-cli\lib\target.js:98:27)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\flrn\workbench\datalyzer\node_modules\neon-cli\lib\target.js:24:58)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
electron-build-env error
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

As I've said, any help is welcome. Thanks.

kjvalencik commented 3 years ago

@cdbrkfxrpt It appears like one of the node-gyp dependencies may be missing. Can you run python --version?

Alternatively, if your use case is synchronous only you can try the n-api backend which has a much simpler build process and doesn't require node-gyp.

neon = { version = "0.5", default-features = false, features = ["napi-runtime"] }
cdbrkfxrpt commented 3 years ago

Sorry @kjvalencik - I had forgotten to include the Python version call in the original post. It's now updated.

Unfortunately we need async.

kjvalencik commented 3 years ago

@cdbrkfxrpt I see this in the log: gyp ERR! stack Error: spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\MSBuild.exe ENOENT

Can you verify that file exists?

You also try cloning neon and building neon-sys directly. You may get better error messages:

git clone https://github.com/neon-bindings/neon.git
cd neon\crates\neon-sys\native
npm install
npm run configure-debug
npm run build-debug
cdbrkfxrpt commented 3 years ago

That file does indeed not exist. Specifically, I don't have a 15.0 subdirectory, only a Current subdirectory which in turn contains Bin/MSBuild.exe. I don't understand this, I installed MSVC build tools per instructions; is there some aliasing going on here? Employing the stupidest approach I could think of I copied the Current directory to 15.0 to exclude that there was some issue in the path resolution, yet the linker error remains the same.

Specifically:

$ yarn build_native
yarn run v1.22.10
$ electron-build-env neon build checkmate --release
neon info forcing rebuild for new build settings
neon info running cargo
   Compiling cfg-if v0.1.10
   Compiling cfg-if v1.0.0
   Compiling gimli v0.23.0
   Compiling adler v0.2.3
   Compiling object v0.22.0
   Compiling rustc-demangle v0.1.18
   Compiling arrayvec v0.5.2
   Compiling static_assertions v1.1.0
   Compiling semver-parser v0.7.0
   Compiling cslice v0.2.0
   Compiling libflate_lz77 v1.0.0
   Compiling lazy_static v1.4.0
   Compiling adler32 v1.2.0
   Compiling rle-decode-fast v1.0.1
   Compiling regex-syntax v0.6.21
   Compiling memchr v2.3.4
   Compiling bitflags v1.2.1
   Compiling ryu v1.0.5
   Compiling libc v0.2.80
   Compiling lexical-core v0.7.4
   Compiling crc32fast v1.2.1
   Compiling serde v1.0.117
   Compiling semver v0.9.0
   Compiling addr2line v0.14.0
   Compiling thread_local v1.0.1
   Compiling num-traits v0.2.14
   Compiling num-integer v0.1.44
   Compiling miniz_oxide v0.4.3
   Compiling num-iter v0.1.42
   Compiling num-complex v0.2.4
   Compiling num-rational v0.2.4
   Compiling nom v5.1.2
   Compiling error-chain v0.12.4
   Compiling aho-corasick v0.7.15
   Compiling libflate v1.0.3
   Compiling backtrace v0.3.54
   Compiling regex v1.4.2
   Compiling libmate v0.1.0 (C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native)
   Compiling neon-sys v0.4.0
error: failed to run custom build command for `neon-sys v0.4.0`

Caused by:
  process didn't exit successfully: `C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\release\build\neon-sys-1096345010ae9bf1\build-script-build` (exit code: 1)
  --- stdout

  > preinstall
  > echo 'Skipping node-gyp installation as part of npm install.'

  'Skipping node-gyp installation as part of npm install.'
  cargo:node_arch=x64
  cargo:node_root_dir=C:\\Users\\flrn\\.electron-gyp\\10.1.4
  cargo:node_lib_file=C:\\Users\\flrn\\.electron-gyp\\10.1.4\\<(target_arch)\\node.lib

  > build-release
  > node-gyp build

  Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
  C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-51bc7a7647459b54\out\native\build\neon.vcxproj(21,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
  TARGET = Some("x86_64-pc-windows-msvc")
  HOST = Some("x86_64-pc-windows-msvc")
  AR_x86_64-pc-windows-msvc = None
  AR_x86_64_pc_windows_msvc = None
  HOST_AR = None
  AR = None
  running: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX64\\x64\\lib.exe" "-out:C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\x86_64-pc-windows-msvc\\release\\build\\neon-sys-51bc7a7647459b54\\out\\libneon.a" "-nologo" "C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\x86_64-pc-windows-msvc\\release\\build\\neon-sys-51bc7a7647459b54\\out\\native\\build\\Release\\obj\\neon\\neon.obj"
  LINK : fatal error LNK1181: cannot open input file 'C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-51bc7a7647459b54\out\native\build\Release\obj\neon\neon.obj'
  exit code: 1181

  --- stderr
  gyp info it worked if it ends with ok
  gyp info using node-gyp@3.6.2
  gyp info using node@15.0.1 | win32 | x64
  gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
  gyp info spawn args [
  gyp info spawn args   'build/binding.sln',
  gyp info spawn args   '/clp:Verbosity=minimal',
  gyp info spawn args   '/nologo',
  gyp info spawn args   '/p:Configuration=Release;Platform=x64'
  gyp info spawn args ]
  gyp ERR! build error
  gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
  gyp ERR! stack     at ChildProcess.onExit (C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-51bc7a7647459b54\out\native\node_modules\node-gyp\lib\build.js:258:23)
  gyp ERR! stack     at ChildProcess.emit (node:events:327:20)
  gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
  gyp ERR! System Windows_NT 10.0.19042
  gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\x86_64-pc-windows-msvc\\release\\build\\neon-sys-51bc7a7647459b54\\out\\native\\node_modules\\node-gyp\\bin\\node-gyp.js" "build"
  gyp ERR! cwd C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-51bc7a7647459b54\out\native
  gyp ERR! node -v v15.0.1
  gyp ERR! node-gyp -v v3.6.2
  gyp ERR! not ok
  npm ERR! code 1
  npm ERR! path C:\Users\flrn\workbench\datalyzer\node_modules\checkmate\native\target\x86_64-pc-windows-msvc\release\build\neon-sys-51bc7a7647459b54\out\native
  npm ERR! command failed
  npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "node-gyp build"

  npm ERR! A complete log of this run can be found in:
  npm ERR!     C:\Users\flrn\AppData\Local\npm-cache\_logs\2020-11-05T15_15_59_804Z-debug.log

  error occurred: Command "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.27.29110\\bin\\HostX64\\x64\\lib.exe" "-out:C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\x86_64-pc-windows-msvc\\release\\build\\neon-sys-51bc7a7647459b54\\out\\libneon.a" "-nologo" "C:\\Users\\flrn\\workbench\\datalyzer\\node_modules\\checkmate\\native\\target\\x86_64-pc-windows-msvc\\release\\build\\neon-sys-51bc7a7647459b54\\out\\native\\build\\Release\\obj\\neon\\neon.obj" with args "lib.exe" did not execute successfully (status code exit code: 1181).

warning: build failed, waiting for other jobs to finish...
error: build failed
neon ERR! cargo build failed

Error: cargo build failed
    at Target.<anonymous> (C:\Users\flrn\workbench\datalyzer\node_modules\neon-cli\lib\target.js:98:27)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\flrn\workbench\datalyzer\node_modules\neon-cli\lib\target.js:24:58)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
electron-build-env error
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I also did as you say clone neon and build neon-sys directly:

$ git clone https://github.com/neon-bindings/neon.git
Cloning into 'neon'...
remote: Enumerating objects: 126, done.
remote: Counting objects: 100% (126/126), done.
remote: Compressing objects: 100% (91/91), done.
remote: Total 9235 (delta 48), reused 82 (delta 33), pack-reused 9109
Receiving objects: 100% (9235/9235), 9.87 MiB | 1.84 MiB/s, done.
Resolving deltas: 100% (5658/5658), done.

$ cd neon/crates/neon-sys/native/

$ npm i

> preinstall
> echo 'Skipping node-gyp installation as part of npm install.'

'Skipping node-gyp installation as part of npm install.'

added 97 packages, and audited 97 packages in 4s

2 low severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

$ npm run configure-debug

> configure-debug
> node-gyp configure --verbose --debug

gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Users\\flrn\\workbench\\neon\\crates\\neon-sys\\native\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'configure',
gyp verb cli   '--verbose',
gyp verb cli   '--debug'
gyp verb cli ]
gyp info using node-gyp@3.6.2
gyp info using node@15.0.1 | win32 | x64
gyp verb command configure []
gyp verb check python checking for Python executable "C:\Users\flrn\.windows-build-tools\python27\python.exe" in the PATH
gyp verb `which` succeeded C:\Users\flrn\.windows-build-tools\python27\python.exe C:\Users\flrn\.windows-build-tools\python27\python.exe
gyp verb check python version `C:\Users\flrn\.windows-build-tools\python27\python.exe -c "import platform; print(platform.python_version());"` returned: "2.7.18\r\n"
gyp verb get node dir no --target version specified, falling back to host node version: 15.0.1
gyp verb command install [ '15.0.1' ]
gyp verb install input version string "15.0.1"
gyp verb install installing version: 15.0.1
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 15.0.1
gyp verb build dir attempting to create "build" dir: C:\Users\flrn\workbench\neon\crates\neon-sys\native\build
gyp verb build dir "build" dir needed to be created? C:\Users\flrn\workbench\neon\crates\neon-sys\native\build
gyp verb find vs2017 Found installation at: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.Windows10SDK.18362
gyp verb find vs2017   - Found Microsoft.VisualStudio.Component.VC.Tools.x86.x64
gyp verb find vs2017   - Found Microsoft.VisualStudio.VC.MSBuild.Base
gyp verb find vs2017   - Using this installation with Windows 10 SDK
gyp verb find vs2017 using installation: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\config.gypi
gyp verb config.gypi checking for gypi file: C:\Users\flrn\workbench\neon\crates\neon-sys\native\config.gypi
gyp verb common.gypi checking for gypi file: C:\Users\flrn\workbench\neon\crates\neon-sys\native\common.gypi
gyp verb gyp gyp format was not specified; forcing "msvs"
gyp info spawn C:\Users\flrn\.windows-build-tools\python27\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\flrn\\workbench\\neon\\crates\\neon-sys\\native\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'msvs',
gyp info spawn args   '-G',
gyp info spawn args   'msvs_version=2015',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\flrn\\workbench\\neon\\crates\\neon-sys\\native\\build\\config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\flrn\\workbench\\neon\\crates\\neon-sys\\native\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\flrn\\.node-gyp\\15.0.1\\include\\node\\common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=C:\\Users\\flrn\\.node-gyp\\15.0.1',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\flrn\\workbench\\neon\\crates\\neon-sys\\native\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\flrn\\.node-gyp\\15.0.1\\<(target_arch)\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\flrn\\workbench\\neon\\crates\\neon-sys\\native',
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   'C:\\Users\\flrn\\workbench\\neon\\crates\\neon-sys\\native\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp info spawn args ]
gyp info ok

$ npm run build-debug

> build-debug
> node-gyp build --verbose --debug

gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'C:\\Users\\flrn\\workbench\\neon\\crates\\neon-sys\\native\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'build',
gyp verb cli   '--verbose',
gyp verb cli   '--debug'
gyp verb cli ]
gyp info using node-gyp@3.6.2
gyp info using node@15.0.1 | win32 | x64
gyp verb command build []
gyp verb build type Debug
gyp verb architecture x64
gyp verb node dev dir C:\Users\flrn\.node-gyp\15.0.1
gyp verb found first Solution file build/binding.sln
gyp verb using MSBuild: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\MSBuild.exe
gyp info spawn args [
gyp info spawn args   'build/binding.sln',
gyp info spawn args   '/nologo',
gyp info spawn args   '/p:Configuration=Debug;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 11/5/2020 4:22:35 PM.
Project "C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\binding.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|x64".
Project "C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\binding.sln" (1) is building "C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\neon.vcxproj" (2) on node 1 (default targets).
C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\neon.vcxproj(21,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.
Done Building Project "C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\neon.vcxproj" (default targets) -- FAILED.
Done Building Project "C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\binding.sln" (default targets) -- FAILED.

Build FAILED.

"C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\binding.sln" (default target) (1) ->
"C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\neon.vcxproj" (default target) (2) ->
  C:\Users\flrn\workbench\neon\crates\neon-sys\native\build\neon.vcxproj(21,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\Microsoft\VC\v160\Microsoft.Cpp.Default.props" was not found. Confirm that the expression in the Import declaration "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\Microsoft\VC\v160\\Microsoft.Cpp.Default.props" is correct, and that the file exists on disk.

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.36
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\flrn\workbench\neon\crates\neon-sys\native\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (node:events:327:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\flrn\\workbench\\neon\\crates\\neon-sys\\native\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--verbose" "--debug"
gyp ERR! cwd C:\Users\flrn\workbench\neon\crates\neon-sys\native
gyp ERR! node -v v15.0.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code 1
npm ERR! path C:\Users\flrn\workbench\neon\crates\neon-sys\native
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c "node-gyp build --verbose --debug"

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\flrn\AppData\Local\npm-cache\_logs\2020-11-05T15_22_35_877Z-debug.log

Again, indeed that file doesn't exist on disk. Actually, this doesn't even exist in the Current directory. Is there some MSVC Build Tools component which I'm missing?

Thanks a lot for your time!

kjvalencik commented 3 years ago

In our Windows CI we configure the MSVC version in NPM globally:

npm config set msvs_version 2019

Something similar might be necessary? To be honest, I am not super familiar with the Windows platform. neon-sys/native is a fairly normal node-gyp project, if it doesn't compile, I would expect other native node modules wouldn't compile.

It's interesting that you are getting a different error when compiling within the module. 🤔

goto-bus-stop commented 3 years ago

I get the same "missing neon.obj" error locally on Windows 10. It looks like the legacy runtime for Neon does not work with Node.js 15 right now.

I tried running CI on a branch with Node.js 15 to confirm: https://github.com/neon-bindings/neon/runs/1363852935?check_suite_focus=true that gives yet another different error:

  Traceback (most recent call last):
    File "D:\a\neon\neon\target\release\build\neon-sys-f3dce05700290eca\out\native\node_modules\node-gyp\gyp\gyp_main.py", line 16, in <module>
      sys.exit(gyp.script_main())
    File "D:\a\neon\neon\target\release\build\neon-sys-f3dce05700290eca\out\native\node_modules\node-gyp\gyp\pylib/gyp/__init__.py", line 545, in script_main
      return main(sys.argv[1:])
    File "D:\a\neon\neon\target\release\build\neon-sys-f3dce05700290eca\out\native\node_modules\node-gyp\gyp\pylib/gyp/__init__.py", line 538, in main
      return gyp_main(args)
    File "D:\a\neon\neon\target\release\build\neon-sys-f3dce05700290eca\out\native\node_modules\node-gyp\gyp\pylib/gyp/__init__.py", line 514, in gyp_main
      options.duplicate_basename_check)
    File "D:\a\neon\neon\target\release\build\neon-sys-f3dce05700290eca\out\native\node_modules\node-gyp\gyp\pylib/gyp/__init__.py", line 98, in Load
      generator.CalculateVariables(default_variables, params)
    File "D:\a\neon\neon\target\release\build\neon-sys-f3dce05700290eca\out\native\node_modules\node-gyp\gyp\pylib/gyp/generator/msvs.py", line 1916, in CalculateVariables
      generator_flags.get('msvs_version', 'auto'))
    File "D:\a\neon\neon\target\release\build\neon-sys-f3dce05700290eca\out\native\node_modules\node-gyp\gyp\pylib/gyp/MSVSVersion.py", line 434, in SelectVisualStudioVersion
      versions = _DetectVisualStudioVersions(version_map[version], 'e' in version)
KeyError: '2019'
kjvalencik commented 3 years ago

Thanks @goto-bus-stop. A simple thing to test would be to upgrade node-gyp which is behind quite a few versions.

cdbrkfxrpt commented 3 years ago

Sorry, been otherwise occupied the last few days.

I quickly tried global installing gulp as recommended by the issue in neon-bindings you referenced but this didn't change anything for me. I haven't re-installed everything on Windows; it should be clean as it's a VM I'm only using to build stuff, but I'll do that at some point soon.

goto-bus-stop commented 3 years ago

gulp was probably extremely specific to that user's problem—if you weren't using it already, installing it or not won't change anything 😅

Neon's build system simply does not work with Node 15. I'm trying to fix it in https://github.com/neon-bindings/neon/pull/623.

cdbrkfxrpt commented 3 years ago

Got it, thanks for the hint :)

The world of node and JS build systems in general to me is unknown, so I'm just kind of stirring in the fog when it comes to issues with it. As you may have noticed ^^

imor commented 3 years ago

@cdbrkfxrpt did you install the VS build tools using the following command line as per the getting started guide:

npm install --global --production windows-build-tools

Also looks like your node-gyp version is quite old. Did you try upgrading it?

goto-bus-stop commented 3 years ago

An old version of node-gyp is installed by neon itself. https://github.com/neon-bindings/neon/pull/623 updates it.

imor commented 3 years ago

@goto-bus-stop ah ok

apolkingg8 commented 3 years ago

Similar issue with neon 0.5.3

error: failed to run custom build command for `neon-sys v0.5.3`

Caused by:
  process didn't exit successfully: `D:\MyWork\thread-count\native\target\release\build\neon-sys-568d79a6af6482ec\build-script-build` (exit code: 1)
--- stderr

error occurred: Command "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX64\\x64\\lib.exe" "-out:D:\\MyWor
k\\thread-count\\native\\target\\release\\build\\neon-sys-9c48543367ca0e71\\out\\libneon.a" "-nologo" "D:\\MyWork\\thread-count\\native\\target\\release\\build\\neon-
sys-9c48543367ca0e71\\out\\native\\build\\Release\\obj\\neon\\neon.obj" with args "lib.exe" did not execute successfully (status code exit code: 1181).

warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `neon-sys v0.5.3`

Caused by:
  process didn't exit successfully: `D:\MyWork\thread-count\native\target\release\build\neon-sys-568d79a6af6482ec\build-script-build` (exit code: 1)
--- stderr

error occurred: Command "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX64\\x64\\lib.exe" "-out:D:\\MyWor
k\\thread-count\\native\\target\\x86_64-pc-windows-msvc\\release\\build\\neon-sys-3887e6db62fb0408\\out\\libneon.a" "-nologo" "D:\\MyWork\\thread-count\\native\\targe
t\\x86_64-pc-windows-msvc\\release\\build\\neon-sys-3887e6db62fb0408\\out\\native\\build\\Release\\obj\\neon\\neon.obj" with args "lib.exe" did not execute successful
ly (status code exit code: 1181).

neon ERR! cargo build failed

Error: cargo build failed
    at Target.<anonymous> (D:\MyWork\thread-count\node_modules\neon-cli\lib\target.js:98:27)
    at Generator.next (<anonymous>)
    at fulfilled (D:\MyWork\thread-count\node_modules\neon-cli\lib\target.js:24:58)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
electron-build-env error

A simple repo here: https://github.com/apolkingg8/thread-count

neon build --release with node@12 ✅ electron-build-env neon build --release with electron@9 ❌ electron-build-env neon build --release with electron@10, 11

[EDIT]

electron-build-env neon build path/to/some-neon-project --releasecd some-neon-project && electron-build-env neon build --release

Not sure why it's different, maybe I misunderstood something🤔

himself65 commented 3 years ago

this should be fixed in 0.7.0

kjvalencik commented 3 years ago

@Himself65 I don't believe this is fixed. It still may impact some users with the legacy backend and this specific set of tool versions.

@apolkingg8 Your last edit appears like electron-build-env is failing to find electron. If there is a package.json in the neon directory that doesn't include electron (most likely because electron is in a parent directory), that might cause this issue.

kjvalencik commented 2 years ago

This should be fixed in 0.10 by https://github.com/neon-bindings/neon/commit/62a5ffc1e606ad906e4ca350bbae25ba28a55fd0