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

Cannot find module './lib/binding/napi-v3/argon2.node'[Bug]: #5561

Closed
4 tasks done
RealEthanPlayzDev opened this issue Sep 16, 2022 · 21 comments
Closed
4 tasks done

Cannot find module './lib/binding/napi-v3/argon2.node'[Bug]: #5561

RealEthanPlayzDev opened this issue Sep 16, 2022 · 21 comments
Labels
bug Something isn't working high-priority This issue needs to be resolved ASAP
Milestone

Comments

@RealEthanPlayzDev
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

OS/Web Information

  • Web Browser: Brave
  • Local OS: Android
  • Remote OS: Android (Termux, using proot-distro with the archlinux distro)
  • Remote Architecture: ARM64
  • code-server --version: 4.7.0 (can't use command since it can't run, but this is the version I downloaded)

Steps to Reproduce

  1. Use the install script to install code-server in the standalone method
  2. Try running code-server (like code-server --version)
  3. It fails.

Expected

code-server to run fine without any errors.

Actual

code-server crashes with the following error:

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module './lib/binding/napi-v3/argon2.node'
Require stack:
- /home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/util.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/cli.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/entry.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js:6:25)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/util.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/cli.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/entry.js'
  ]
}

Logs

Can't run code-server at all, following error thrown:

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module './lib/binding/napi-v3/argon2.node'
Require stack:
- /home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/util.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/cli.js
- /home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/entry.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js:6:25)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/node_modules/argon2/argon2.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/util.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/cli.js',
    '/home/radiatedexodus/.local/lib/code-server-4.7.0/out/node/entry.js'
  ]
}

Screenshot/Video

Screenshot_20220916_135343

Does this issue happen in VS Code or GitHub Codespaces?

  • I cannot reproduce this in VS Code.
  • I cannot reproduce this in GitHub Codespaces.

Are you accessing code-server over HTTPS?

  • I am using HTTPS.

Notes

  • Albeit i'm using Termux, I run code-server in a proot-distro environment using the archlinux distro!
  • Installed nodejs-lts-gallium package and npm with pacman
  • Using npm directly doesn't really work for me, the last time I've used it, no matter what I do I couldn't upgrade code-server when a new release was released. (either saying it can't find some cached files, or it doesn't do anything and make me waste time)
@RealEthanPlayzDev RealEthanPlayzDev added bug Something isn't working triage This issue needs to be triaged by a maintainer labels Sep 16, 2022
@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 16, 2022

First, thanks for the thorough notes! Second, sorry to hear this is happening. code-server used to work so well on Termux and the last few months haven't been great.

Could you try building node-argon2 from source and seeing if that works? https://github.com/ranisalt/node-argon2#before-installing

@RealEthanPlayzDev
Copy link
Author

RealEthanPlayzDev commented Sep 16, 2022

@jsjoeio Nope, I don't think it worked: (followed installation and rebuild steps, both failed)
Screenshot_20220916-224719_Termux

I believe I've been starting to have issues with installating a standalone release ever since v4.5.1 when I reset my Termux data to redo it from scratch again, before that I used to be able to install v4.0.0, v4.0.2, v4.0.5

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 16, 2022

Thanks for trying! Let me raise an issue upstream and see if the node-argon2 team has recommendations

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 16, 2022

Wait one last thing, can you try npm_config_build_from_source=true CXX=g++ npm install argon2 in the same directory you were testing before?

@RealEthanPlayzDev
Copy link
Author

@jsjoeio No, the command still doesn't work (I assume you are supposed to execute npm install related commands in the installation directory, specifically ~/.local/lib/code-server-4.7.0, correct me if this is wrong)
Screenshot_20220917-094618_Termux

@RealEthanPlayzDev
Copy link
Author

RealEthanPlayzDev commented Sep 17, 2022

I've tried the suggestion in #5184 (comment) which is going to the argon2 folder in node_modules (~/.local/lib/code-server-4.7.0/node_modules/argon2) and do npm install, this was the result:

[radiatedexodus code-server-4.7.0]$ cd node_modules/argon2
[radiatedexodus argon2]$ ls
LICENSE  README.md  argon2  argon2.d.ts  argon2.js  binding.gyp  build-tmp-napi-v3  lib  package.json  src
[radiatedexodus argon2]$ npm install
npm ERR! code FETCH_ERROR
npm ERR! errno FETCH_ERROR
npm ERR! invalid json response body at https://registry.npmjs.org/color-support reason: Invalid response body while trying to fetch https://registry.npmjs.org/color-support: ENOENT: no such file or directory, rename '/home/radiatedexodus/.npm/_cacache/tmp/f1e0d306' -> '/home/radiatedexodus/.npm/_cacache/content-v2/sha512/5d/61/71054f33939b04a7c6db0bc13c8acc048919f567fe4d5ed67a969f0486fabeb3d18830e5ffe68f40e6d7bc9ea940de2bd9ec46525a04b10f6f7cd3b52f71'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/radiatedexodus/.npm/_logs/2022-09-17T03_03_16_867Z-debug-0.log

This was also one of the reasons I didn't want to bother using npm to deal with it, it has strange issues with not being able to find cached files and I'm getting tired of dealing with them (I've said this in the notes)

  • Using npm directly doesn't really work for me, the last time I've used it, no matter what I do I couldn't upgrade code-server when a new release was released. (either saying it can't find some cached files, or it doesn't do anything and make me waste time)

Additionally, I have to do a correction for the part where I said the early 4.x.x versions worked fine:

  • When 4.x.x releases were finally introduced (v4.0.0, v4.0.2, v4.0.5 are the ones I remember installing), I was able to install a standalone version of them just fine
  • At some point, when the latest version was v4.5.1, I could not install a standalone version and was met with this issue, my workaround was to use npm but as I've said, now that I want to update to v4.7.0, it basically fails saying it can't find cached files or just succeed but not actually upgrade it, basically like locking it at v4.5.1 (I did clear the cached files and it did not help)
  • I do not know when or what exact version that first had this issue, the earliest would be v4.5.1, but there could be more older versions that has a broken standalone release

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 19, 2022

Thank you for the thorough explanation @RealEthanPlayzDev! I can empathize, this sounds frustrating. I am not sure myself or @code-asher have bandwidth to dive deep on this right now but I'll make it high priority and we can look at this in the upcoming or next milestone.

@jsjoeio jsjoeio added high-priority This issue needs to be resolved ASAP and removed triage This issue needs to be triaged by a maintainer labels Sep 19, 2022
@jsjoeio jsjoeio added this to the September 2022 milestone Sep 19, 2022
@RealEthanPlayzDev
Copy link
Author

@jsjoeio I understand. I'll wait for the fix, you can take your time!

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 20, 2022

Thanks for understanding!

@Sonotoki-da
Copy link

Sonotoki-da commented Sep 22, 2022

It works when you download a tar.gz release for arm64, and run it direcrtly, executing code-server which is stored in the bin folder.

My specs are:
termux the latest version (installed from github releases)
proot'ed into manjaro-aarch64
node 18

The result:
Screenshot_2022-09-23-02-10-51-464_com termux

But yes, the errors are the same when installed via the script.

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 22, 2022

@Sonotoki-da wow, thanks for sharing! I wonder then if we can just create a copy of that tar.gz and call it termux.tar.gz which would resolve #5515

thoughts @code-asher?

@RealEthanPlayzDev
Copy link
Author

RealEthanPlayzDev commented Sep 23, 2022

It works when you download a tar.gz release for arm64, and run it direcrtly, executing code-server which is stored in the bin folder.

I wonder what tar.gz did the script download then 🤔
@Sonotoki-da Anyways, thanks for telling me that! I'll try it real quick

EDIT: It worked!
Screenshot_20220923-073807_Termux

@RealEthanPlayzDev
Copy link
Author

RealEthanPlayzDev commented Sep 23, 2022

@jsjoeio I suppose code-server uses symlinks right? I think those links broke in the process of installation (I tried moving the extracted code-server from the comment above to ~/.local/lib and it gave back me argon2 error, rm-rf'ed the folder and re-extracted the tar with tar -xvf /path/to/code-server-tar.tar.gz in lib folder at .local and it worked fine)

@jsjoeio
Copy link
Contributor

jsjoeio commented Sep 23, 2022

I think those links broke in the process of installation

Holy cow, that's amazing insight. We've had troubles with Termux in the past and maybe this is the clue we've been missing. Thank you so much for trying and confirming!

@code-asher does this spark any ideas?

@code-asher
Copy link
Member

code-asher commented Sep 23, 2022 via email

@jsjoeio jsjoeio modified the milestones: September 2022, October 2022 Sep 30, 2022
@utkustnr
Copy link

utkustnr commented Oct 27, 2022

I think those links broke in the process of installation

Holy cow, that's amazing insight. We've had troubles with Termux in the past and maybe this is the clue we've been missing. Thank you so much for trying and confirming!

@code-asher does this spark any ideas?

Sorry to bump the issue but I've had the same problem with op but mine was inside termux shell, not proot. Since links are a known issue I wanted to share my own insight to the problem. When you ignore the argon2 issue with yarn / npm and run install script it gives this output :

~ $ curl -fsSL https://code-server.dev/install.sh | sh
Linux 4.9.319-Phenix
Unsupported package manager.
Falling back to standalone installation.
Installing v4.8.0 of the arm64 release from GitHub.

+ Reusing ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz
+ mkdir -p ~/.local
+ mkdir -p ~/.local/lib ~/.local/bin
+ tar -C ~/.local/lib -xzf ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz
tar: code-server-4.8.0-linux-arm64/node_modules/argon2/build-tmp-napi-v3/Release/obj.target/argon2.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/node_modules/argon2/lib/binding/napi-v3/argon2.node’: Permission denied
tar: code-server-4.8.0-linux-arm64/node_modules/argon2/build-tmp-napi-v3/Release/argon2.a: Cannot hard link to ‘code-server-4.8.0-linux-arm64/node_modules/argon2/build-tmp-napi-v3/Release/obj.target/argon2.a’: Permission denied
tar: code-server-4.8.0-linux-arm64/node_modules/argon2/build-tmp-napi-v3/Release/argon2.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/node_modules/argon2/lib/binding/napi-v3/argon2.node’: Permission denied
tar: code-server-4.8.0-linux-arm64/lib/vscode/node_modules/native-watchdog/build/Release/watchdog.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/lib/vscode/node_modules/native-watchdog/build/Release/obj.target/watchdog.node’: Permission denied
tar: code-server-4.8.0-linux-arm64/lib/vscode/node_modules/spdlog/build/Release/spdlog.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/lib/vscode/node_modules/spdlog/build/Release/obj.target/spdlog.node’: Permission denied
tar: code-server-4.8.0-linux-arm64/lib/vscode/node_modules/@parcel/watcher/build/Release/nothing.a: Cannot hard link to ‘code-server-4.8.0-linux-arm64/lib/vscode/node_modules/@parcel/watcher/build/node-addon-api/nothing.a’: Permission denied
tar: code-server-4.8.0-linux-arm64/lib/vscode/node_modules/@parcel/watcher/build/Release/watcher.node: Cannot hard link to ‘code-server-4.8.0-linux-arm64/lib/vscode/node_modules/@parcel/watcher/build/Release/obj.target/watcher.node’: Permission denied
tar: Exiting with failure status due to previous errors
~ $

But since I have root access why shouldn't I use it when it's just basic links right? This is the output when you fix linking issue :

~ $ node -v
v16.18.0
~ $ tsu
.../files/home # export HOME="/data/data/com.termux/files/home"   
~ # curl -fsSL https://code-server.dev/install.sh | sh
Linux 4.9.319-Phenix
Unsupported package manager.
Falling back to standalone installation.
Installing v4.8.0 of the arm64 release from GitHub.

+ mkdir -p ~/.cache/code-server
+ curl -#fL -o ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz.incomplete -C - https://github.com/coder/code-server/releases/download/v4.8.0/code-server-4.8.0-linux-arm64.tar.gz
######################################################################## 100.0%
+ mv ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz.incomplete ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz
+ mkdir -p ~/.local
+ mkdir -p ~/.local/lib ~/.local/bin
+ tar -C ~/.local/lib -xzf ~/.cache/code-server/code-server-4.8.0-linux-arm64.tar.gz
+ mv -f ~/.local/lib/code-server-4.8.0-linux-arm64 ~/.local/lib/code-server-4.8.0
+ ln -fs ~/.local/lib/code-server-4.8.0/bin/code-server ~/.local/bin/code-server

Standalone release has been installed into ~/.local/lib/code-server-4.8.0

Extend your path to use code-server:
  PATH="$HOME/.local/bin:$PATH"
Then run with:
  code-server
~ # echo $PATH
/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
~ # export PATH="$HOME/.local/bin:$PATH"
~ # echo $PATH
/data/data/com.termux/files/home/.local/bin:/data/data/com.termux/files/usr/bin:/data/data/com.termux/files/usr/bin/applets:/system/bin:/system/xbin:/sbin:/sbin/bin
~ # code-server
/data/data/com.termux/files/home/.local/bin/code-server: 28: exec: /data/data/com.termux/files/home/.local/lib/code-server-4.8.0/lib/node: not found
~ # ln -fs /data/data/com.termux/files/usr/bin/node /data/data/com.termux/files/home/.local/lib/code-server-4.8.0/lib/
~ # code-server
node:internal/modules/cjs/loader:1239
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: dlopen failed: library "libstdc++.so.6" not found
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1239:18)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/data/data/com.termux/files/home/.local/lib/code-server-4.8.0/node_modules/argon2/argon2.js:6:25)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12) {
  code: 'ERR_DLOPEN_FAILED'
}
~ #

As you can see node wasn't recognized so I had to link it manually as well. I couldn't go past this I'm afraid. Let me know if these help. Thanks.

Edit: Termux has mingw-w64-gcc-libs package that includes libstdc++ but installing it did not change anything whatsoever.

@jsjoeio
Copy link
Contributor

jsjoeio commented Oct 27, 2022

Thank you for sharing all that! One idea, which we've tried in the past is switching to @node-rs/argon2 (see here: #4804 (comment)). We may investigate that again and see if using --force with the npm install works.

@code-asher
Copy link
Member

Yeah I would not expect the standalone arm64 GitHub release to work on Android. I believe we would need to compile specifically for Termux rather than generic Linux arm64. We should fix the install script trying to download a release that will not work and make it use npm install instead.

@utkustnr
Copy link

Hey, I know this is not directly connected to argon2 issue but since I bringed up termux I might as well follow up on it. Apparently termux has a user repository with it's own code-server install script. (see here: code-server) Installing code-server was as easy as pkg install code-server after installing repo. Install script was created just a few days ago as well, figured I should give a heads up.

@code-asher
Copy link
Member

Good point! I think we can close this issue once we get the install script changes done in #5745.

@haruki-py
Copy link

Doing as per termux docs worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high-priority This issue needs to be resolved ASAP
Projects
None yet
Development

No branches or pull requests

6 participants