coder / code-server

VS Code in the browser
https://coder.com
MIT License
67.81k stars 5.57k forks source link

[Bug]: npm install process is trying to install the Windows version of Kerberos on FreeBSD #6499

Closed katrinabryce closed 2 months ago

katrinabryce commented 11 months ago

Is there an existing issue for this?

OS/Web Information

Steps to Reproduce

  1. Install the dependencies python npm-node18 pkgconf libinotify libsecret krb5
  2. Run the install process npm install -g code-server --unsafe-perm

Expected

It should install

Actual

It returns an error about being unable to find windows.h, which obviously it won't because we are in FreeBSD, not Windows.

root@miku:/usr/home/katrina # npm install -g code-server --unsafe-perm
npm ERR! code 1
npm ERR! path /usr/local/lib/node_modules/code-server
npm ERR! command failed
npm ERR! command sh -c sh ./postinstall.sh
npm ERR! Installing Code dependencies...
npm ERR! User agent: npm/10.2.0 node/v18.18.2 freebsd x64 workspaces/false
npm ERR! You may not have the required dependencies to build the native modules.
npm ERR! Please see https://github.com/coder/code-server/blob/main/docs/npm.md
npm ERR! npm ERR! code 1
npm ERR! npm ERR! path /usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos
npm ERR! npm ERR! command failed
npm ERR! npm ERR! command sh -c prebuild-install --runtime napi || node-gyp rebuild
npm ERR! npm ERR! gmake: Entering directory '/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos/build'
npm ERR! npm ERR!   CXX(target) Release/obj.target/kerberos/src/kerberos.o
npm ERR! npm ERR! gmake: Leaving directory '/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos/build'
npm ERR! npm ERR! prebuild-install warn install No prebuilt binaries found (target=4 runtime=napi arch=x64 libc= platform=freebsd)
npm ERR! npm ERR! gyp info it worked if it ends with ok
npm ERR! npm ERR! gyp info using node-gyp@9.4.0
npm ERR! npm ERR! gyp info using node@18.18.2 | freebsd | x64
npm ERR! npm ERR! gyp info find Python using Python version 3.9.18 found at "/usr/local/bin/python3.9"
npm ERR! npm ERR! gyp http GET https://nodejs.org/download/release/v18.18.2/node-v18.18.2-headers.tar.gz
npm ERR! npm ERR! gyp http 200 https://nodejs.org/download/release/v18.18.2/node-v18.18.2-headers.tar.gz
npm ERR! npm ERR! gyp http GET https://nodejs.org/download/release/v18.18.2/SHASUMS256.txt
npm ERR! npm ERR! gyp http 200 https://nodejs.org/download/release/v18.18.2/SHASUMS256.txt
npm ERR! npm ERR! gyp info spawn /usr/local/bin/python3.9
npm ERR! npm ERR! gyp info spawn args [
npm ERR! npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! npm ERR! gyp info spawn args   '-f',
npm ERR! npm ERR! gyp info spawn args   'make',
npm ERR! npm ERR! gyp info spawn args   '-I',
npm ERR! npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos/build/config.gypi',
npm ERR! npm ERR! gyp info spawn args   '-I',
npm ERR! npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! npm ERR! gyp info spawn args   '-I',
npm ERR! npm ERR! gyp info spawn args   '/root/.cache/node-gyp/18.18.2/include/node/common.gypi',
npm ERR! npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/18.18.2',
npm ERR! npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/18.18.2/<(target_arch)/node.lib',
npm ERR! npm ERR! gyp info spawn args   '-Dmodule_root_dir=/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos',
npm ERR! npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! npm ERR! gyp info spawn args   '--depth=.',
npm ERR! npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! npm ERR! gyp info spawn args   '--generator-output',
npm ERR! npm ERR! gyp info spawn args   'build',
npm ERR! npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! npm ERR! gyp info spawn args ]
npm ERR! npm ERR! gyp info spawn gmake
npm ERR! npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! npm ERR! In file included from ../src/kerberos.cc:1:
npm ERR! npm ERR! In file included from ../src/kerberos.h:12:
npm ERR! npm ERR! In file included from ../src/kerberos_common.h:13:
npm ERR! npm ERR! ../src/win32/kerberos_sspi.h:22:10: fatal error: 'windows.h' file not found
npm ERR! npm ERR! #include <windows.h>
npm ERR! npm ERR!          ^~~~~~~~~~~
npm ERR! npm ERR! 1 error generated.
npm ERR! npm ERR! gmake: *** [kerberos.target.mk:107: Release/obj.target/kerberos/src/kerberos.o] Error 1
npm ERR! npm ERR! gyp ERR! build error
npm ERR! npm ERR! gyp ERR! stack Error: `gmake` failed with exit code: 2
npm ERR! npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
npm ERR! npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
npm ERR! npm ERR! gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
npm ERR! npm ERR! gyp ERR! System FreeBSD 13.2-RELEASE-p4
npm ERR! npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! npm ERR! gyp ERR! cwd /usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos
npm ERR! npm ERR! gyp ERR! node -v v18.18.2
npm ERR! npm ERR! gyp ERR! node-gyp -v v9.4.0
npm ERR! npm ERR! gyp ERR! not ok
npm ERR!
npm ERR! npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-10-21T09_56_25_299Z-debug-0.log

npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-10-21T09_56_20_728Z-debug-0.log

Logs

0 verbose cli /usr/local/bin/node /usr/local/bin/npm
[trimmed to keep within size limit]
634 timing build:link:node_modules/code-server/lib/vscode/node_modules/prebuild-install Completed in 2ms
635 timing build:link:node_modules/code-server/lib/vscode/node_modules/mkdirp Completed in 2ms
636 timing build:link:node_modules/code-server/lib/vscode/node_modules/semver Completed in 1ms
637 timing build:link:node_modules/code-server/lib/vscode/node_modules/rc Completed in 2ms
638 timing build:link:node_modules/code-server/lib/vscode/node_modules/node-gyp-build Completed in 2ms
639 timing build:link Completed in 2ms
640 info run @parcel/watcher@2.1.0 install node_modules/code-server/lib/vscode/node_modules/@parcel/watcher node-gyp-build
641 info run @vscode/spdlog@0.13.11 install node_modules/code-server/lib/vscode/node_modules/@vscode/spdlog node-gyp rebuild
642 info run @vscode/windows-process-tree@0.5.0 install node_modules/code-server/lib/vscode/node_modules/@vscode/windows-process-tree node-gyp rebuild
643 info run @vscode/windows-registry@1.1.0 install node_modules/code-server/lib/vscode/node_modules/@vscode/windows-registry node-gyp rebuild
644 info run kerberos@2.0.3 install node_modules/code-server/lib/vscode/node_modules/kerberos prebuild-install --runtime napi || node-gyp rebuild
645 info run native-watchdog@1.4.2 install node_modules/code-server/lib/vscode/node_modules/native-watchdog node-gyp rebuild
646 info run node-pty@1.1.0-beta1 install node_modules/code-server/lib/vscode/node_modules/node-pty node-gyp rebuild
647 info run kerberos@2.0.3 install { code: 1, signal: null }
648 timing reify:rollback:createSparse Completed in 100ms
649 timing reify:rollback:retireShallow Completed in 0ms
650 timing command:install Completed in 43837ms
651 verbose stack Error: command failed
651 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
651 verbose stack     at ChildProcess.emit (node:events:517:28)
651 verbose stack     at maybeClose (node:internal/child_process:1098:16)
651 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:303:5)
652 verbose pkgid kerberos@2.0.3
653 verbose cwd /usr/local/lib/node_modules/code-server/lib/vscode
654 verbose FreeBSD 13.2-RELEASE-p4
655 verbose node v18.18.2
656 verbose npm  v10.2.0
657 error code 1
658 error path /usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos
659 error command failed
660 error command sh -c prebuild-install --runtime napi || node-gyp rebuild
661 error gmake: Entering directory '/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos/build'
661 error   CXX(target) Release/obj.target/kerberos/src/kerberos.o
661 error gmake: Leaving directory '/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos/build'
662 error prebuild-install warn install No prebuilt binaries found (target=4 runtime=napi arch=x64 libc= platform=freebsd)
662 error gyp info it worked if it ends with ok
662 error gyp info using node-gyp@9.4.0
662 error gyp info using node@18.18.2 | freebsd | x64
662 error gyp info find Python using Python version 3.9.18 found at "/usr/local/bin/python3.9"
662 error gyp http GET https://nodejs.org/download/release/v18.18.2/node-v18.18.2-headers.tar.gz
662 error gyp http 200 https://nodejs.org/download/release/v18.18.2/node-v18.18.2-headers.tar.gz
662 error gyp http GET https://nodejs.org/download/release/v18.18.2/SHASUMS256.txt
662 error gyp http 200 https://nodejs.org/download/release/v18.18.2/SHASUMS256.txt
662 error gyp info spawn /usr/local/bin/python3.9
662 error gyp info spawn args [
662 error gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
662 error gyp info spawn args   'binding.gyp',
662 error gyp info spawn args   '-f',
662 error gyp info spawn args   'make',
662 error gyp info spawn args   '-I',
662 error gyp info spawn args   '/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos/build/config.gypi',
662 error gyp info spawn args   '-I',
662 error gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
662 error gyp info spawn args   '-I',
662 error gyp info spawn args   '/root/.cache/node-gyp/18.18.2/include/node/common.gypi',
662 error gyp info spawn args   '-Dlibrary=shared_library',
662 error gyp info spawn args   '-Dvisibility=default',
662 error gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/18.18.2',
662 error gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
662 error gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/18.18.2/<(target_arch)/node.lib',
662 error gyp info spawn args   '-Dmodule_root_dir=/usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos',
662 error gyp info spawn args   '-Dnode_engine=v8',
662 error gyp info spawn args   '--depth=.',
662 error gyp info spawn args   '--no-parallel',
662 error gyp info spawn args   '--generator-output',
662 error gyp info spawn args   'build',
662 error gyp info spawn args   '-Goutput_dir=.'
662 error gyp info spawn args ]
662 error gyp info spawn gmake
662 error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
662 error In file included from ../src/kerberos.cc:1:
662 error In file included from ../src/kerberos.h:12:
662 error In file included from ../src/kerberos_common.h:13:
662 error ../src/win32/kerberos_sspi.h:22:10: fatal error: 'windows.h' file not found
662 error #include <windows.h>
662 error          ^~~~~~~~~~~
662 error 1 error generated.
662 error gmake: *** [kerberos.target.mk:107: Release/obj.target/kerberos/src/kerberos.o] Error 1
662 error gyp ERR! build error
662 error gyp ERR! stack Error: `gmake` failed with exit code: 2
662 error gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:203:23)
662 error gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
662 error gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
662 error gyp ERR! System FreeBSD 13.2-RELEASE-p4
662 error gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
662 error gyp ERR! cwd /usr/local/lib/node_modules/code-server/lib/vscode/node_modules/kerberos
662 error gyp ERR! node -v v18.18.2
662 error gyp ERR! node-gyp -v v9.4.0
662 error gyp ERR! not ok
663 verbose exit 1
664 timing npm Completed in 43979ms
665 verbose unfinished npm timer reify 1697882185439
666 verbose unfinished npm timer reify:build 1697882218967
667 verbose unfinished npm timer build 1697882218968
668 verbose unfinished npm timer build:deps 1697882218968
669 verbose unfinished npm timer build:run:install 1697882218974
670 verbose unfinished npm timer build:run:install:node_modules/code-server/lib/vscode/node_modules/@parcel/watcher 1697882218974
671 verbose unfinished npm timer build:run:install:node_modules/code-server/lib/vscode/node_modules/@vscode/spdlog 1697882218991
672 verbose unfinished npm timer build:run:install:node_modules/code-server/lib/vscode/node_modules/@vscode/windows-process-tree 1697882219003
673 verbose unfinished npm timer build:run:install:node_modules/code-server/lib/vscode/node_modules/@vscode/windows-registry 1697882219015
674 verbose unfinished npm timer build:run:install:node_modules/code-server/lib/vscode/node_modules/kerberos 1697882219029
675 verbose unfinished npm timer build:run:install:node_modules/code-server/lib/vscode/node_modules/native-watchdog 1697882219044
676 verbose unfinished npm timer build:run:install:node_modules/code-server/lib/vscode/node_modules/node-pty 1697882219059
677 verbose code 1
678 error A complete log of this run can be found in: /root/.npm/_logs/2023-10-21T09_56_25_299Z-debug-0.log

The second log file it references doesn't exist.

Screenshot/Video

No response

Does this issue happen in VS Code or GitHub Codespaces?

Are you accessing code-server over a secure context?

Notes

This problem started in v4.17. 4.16.1 installs correctly.

muuuh commented 11 months ago

I had the same error. I somehow (not pretty!) managed to install code-server 4.18.0 it on FreeBSD (iocage jail):

pkg install git npm-node20 krb5-devel git clone https://github.com/mongodb-js/kerberos

Modify/add the following in kerberos/binding.gyp:

'include_dirs': [
    "/usr/local/include",
    "<!(node -p \"require('node-addon-api').include_dir\")"
],
['OS=="mac" or OS=="linux" or OS=="freebsd"', {

Modify/add the following in kerberos/src/kerberos_common.h:

#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)

I did not found another way than using a local npm registry with verdaccio to install this (upper) modified kerberos npm package: npm install -g verdaccio

Modify/add the following (fake) in kerberos/package.json:

"version": "2.0.4",

Executing verdaccio in another shell (screen): verdaccio --listen http:0.0.0:4873

Meanwhile: npm adduser --registry http://localhost:4873/ cd kerberos && npm publish --registry http://localhost:4873

Finally: env FORCE_NODE_VERSION=20 npm install -g code-server --unsafe-perm

Hope there will be a better solution (like https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256144)

katrinabryce commented 11 months ago

I tried this on a test machine with a fresh install of FreeBSD: At the first stage, I also had to install pkgconf libinotify

Before the final stage, I had to do: npm set registry http://localhost:4873/ npm login Verdaccio does proxy registry.npmjs.org for anything it doesn't have installed.

To upgrade my production machine, I had to do pkg install krb5-devel

Then I pointed npm at the registry on my test machine npm set registry http://testbench:4873/ #Where "testbench" is the name of the computer set up in the previous step npm login

Installed code-server

For both, I also applied the fix for terminal not working: sed -i -e 's|switch(process.platform)|switch("linux")|' /usr/local/lib/node_modules/code-server/lib/vscode/out/vs/platform/terminal/node/ptyHostMain.js

and changed the npm registry back to the default npm set registry https://registry.npmjs.org/

code-asher commented 10 months ago

If I understand correctly, this needs to be fixed upstream in the Kerberos package and is not something we can fix here, right?

AlLiberali commented 7 months ago

Thanks to your workarounds I managed to install it. Unrelated to the issue, but as someone not terribly familiar with js and the modern web stack in general, I must voice my utmost disdain for the most vile piece of package management software there is, that is npm. If keyboards were people, mine could sue me to oblivion for numerous charges of battery and domestic violence. Thank you

code-asher commented 2 months ago

Well said! :laughing:

Closing since it seems this is out of our hands.