coder / code-server

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

Android: UserLAnd code-server docs causing error #6731

Closed haruki-py closed 5 days ago

haruki-py commented 3 months ago

Is there an existing issue for this?

OS/Web Information

Steps to Reproduce

  1. sudo apt update -y
  2. sudo apt install nodejs npm curl -y
  3. curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
  4. nvm install 18
  5. nvm use 18
  6. npm install --global code-server --unsafe-perm
  7. code-server
  8. npm i argon2
  9. code-server (same result as 7.)
  10. npm i -g argon2
  11. code-server (same result as 7.)
  12. npm i -g --unsafe-perm argon2
  13. code-server (same result as 7.) Still module not found error

Expected

Similar to this: [2024-03-16T18:46:44.789Z] info - Using certificate for HTTPS: /home/container/.local/share/code-server/localhost.crt [2024-03-16T18:46:44.789Z] info Session server listening on /home/container/.local/share/code-server/code-server-ipc.sock [18:58:25]

Actual

node:internal/modules/cjs/loader:1143

  throw err;
  ^

Error: Cannot find module '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/argon2/lib/binding/napi-v3/argon2.node'
Require stack:
- /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/argon2/argon2.js
- /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/out/node/util.js
- /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/out/node/cli.js
- /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/out/node/entry.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
    at Module._load (node:internal/modules/cjs/loader:981:27)
    at Module.require (node:internal/modules/cjs/loader:1231:19)
    at require (node:internal/modules/helpers:177:18)
    at Object.<anonymous> (/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/argon2/argon2.js:9:25)
    at Module._compile (node:internal/modules/cjs/loader:1364:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
    at Module.load (node:internal/modules/cjs/loader:1203:32)
    at Module._load (node:internal/modules/cjs/loader:1019:12)
    at Module.require (node:internal/modules/cjs/loader:1231:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/argon2/argon2.js',
    '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/out/node/util.js',
    '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/out/node/cli.js',
    '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/out/node/entry.js'
  ]
}

Node.js v18.20.0

Logs

Same output in Actual with verbose flag. Installations log in the screenshot and the first second of first video

Screenshot/Video

After installing nvm: image Screen record starting from installation of codeserver (Other things done correctly as said above:

https://github.com/coder/code-server/assets/134508226/16e7041c-ab6a-4986-a70e-7f9c4e46f3b5

Continuation of recording:

https://github.com/coder/code-server/assets/134508226/82e11792-c43d-4925-9c0c-ffd3fa8b9bf1

Does this bug reproduce in native VS Code?

This cannot be tested in native VS Code

Does this bug reproduce in GitHub Codespaces?

I did not test GitHub Codespaces

Are you accessing code-server over a secure context?

I wasn't able to run the code server and the default one is http but I don't think it affected the bug so I removed it.

Notes

code-asher commented 3 months ago

Probably related: https://github.com/coder/code-server/issues/5561 https://github.com/coder/code-server/issues/5430

Does the npm i argon2 command have any errors? Does npm rebuild help?

I think we should try moving away from argon2.

haruki-py commented 3 months ago
userland@localhost:~$ npm i argon2

up to date, audited 5 packages in 9s

found 0 vulnerabilities
haruki-py commented 3 months ago
userland@localhost:~$ npm rebuild
rebuilt dependencies successfully
haruki-py commented 3 months ago

I tried running code-server again and same issue

haruki-py commented 3 months ago

5561 is about termux. I can get it working on termux but I want in Ubuntu due to some reason like systemctl.

I think #5430 is related to this though

code-asher commented 3 months ago

Yeah I am not sure, it seems like either a bug in argon2 or npm.

Although, the prompt says you are in ~; is that the right directory? I would expect it to be /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server.

cd /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server
npm rebuild # could also try npm i argon2
haruki-py commented 3 months ago
userland@localhost:~/.nvm/versions/node/v18.20.0/lib/node_modules/code-server$ npm rebuild # could also try npm i argon2
npm ERR! code 7
npm ERR! path /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/argon2
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! node-pre-gyp info it worked if it ends with ok
npm ERR! node-pre-gyp info using node-pre-gyp@1.0.11
npm ERR! node-pre-gyp info using node@18.20.0 | linux | arm
npm ERR! node-pre-gyp info check checked for "/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/argon2/lib/binding/napi-v3/argon2.node" (not found)
npm ERR! node-pre-gyp http GET https://github.com/ranisalt/node-argon2/releases/download/v0.31.1/argon2-v0.31.1-napi-v3-linux-arm-glibc.tar.gz
npm ERR! node-pre-gyp ERR! install response status 404 Not Found on https://github.com/ranisalt/node-argon2/releases/download/v0.31.1/argon2-v0.31.1-napi-v3-linux-arm-glibc.tar.gz
npm ERR! node-pre-gyp WARN Pre-built binaries not installable for argon2@0.31.1 and node@18.20.0 (node-v108 ABI, glibc) (falling back to source compile with node-gyp)
npm ERR! node-pre-gyp WARN Hit error response status 404 Not Found on https://github.com/ranisalt/node-argon2/releases/download/v0.31.1/argon2-v0.31.1-napi-v3-linux-arm-glibc.tar.gz
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@18.20.0 | linux | arm
npm ERR! gyp info ok
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@18.20.0 | linux | arm
npm ERR! gyp info find Python using Python version 3.10.6 found at "/usr/bin/python3"
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args '/home/userland/.nvm/versions/node/v18.20.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 '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/argon2/build/config.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args '-I',
npm ERR! gyp info spawn args '/home/userland/.cache/node-gyp/18.20.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=/home/userland/.cache/node-gyp/18.20.0',
npm ERR! gyp info spawn args '-Dnode_gyp_dir=/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args '-Dnode_lib_file=/home/userland/.cache/node-gyp/18.20.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args '-Dmodule_root_dir=/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/argon2',
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! gyp info ok
npm ERR! node-pre-gyp ERR! UNCAUGHT EXCEPTION
npm ERR! node-pre-gyp ERR! stack Error: ENOTEMPTY: directory not empty, rmdir 'build-tmp-napi-v3/Release/obj.target'
npm ERR! node-pre-gyp ERR! stack     at Object.rmdirSync (node:fs:1222:10)
npm ERR! node-pre-gyp ERR! stack     at rmkidsSync (/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/rimraf/rimraf.js:349:27)
npm ERR! node-pre-gyp ERR! stack     at rmdirSync (/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/rimraf/rimraf.js:329:7)
npm ERR! node-pre-gyp ERR! stack     at rimrafSync (/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/rimraf/rimraf.js:301:9)
npm ERR! node-pre-gyp ERR! stack     at /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/rimraf/rimraf.js:336:39
npm ERR! node-pre-gyp ERR! stack     at Array.forEach (<anonymous>)
npm ERR! node-pre-gyp ERR! stack     at rmkidsSync (/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/rimraf/rimraf.js:336:26)
npm ERR! node-pre-gyp ERR! stack     at rmdirSync (/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/rimraf/rimraf.js:329:7)
npm ERR! node-pre-gyp ERR! stack     at rimrafSync (/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/rimraf/rimraf.js:301:9)
npm ERR! node-pre-gyp ERR! stack     at /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/rimraf/rimraf.js:336:39
npm ERR! node-pre-gyp ERR! System Linux 4.9.117+
npm ERR! node-pre-gyp ERR! command "/home/userland/.nvm/versions/node/v18.20.0/bin/node" "/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
npm ERR! node-pre-gyp ERR! cwd /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/argon2
npm ERR! node-pre-gyp ERR! node -v v18.20.0
npm ERR! node-pre-gyp ERR! node-pre-gyp -v v1.0.11

npm ERR! A complete log of this run can be found in: /home/userland/.npm/_logs/2024-03-30T01_56_58_846Z-debug-0.log
userland@localhost:~/.nvm/versions/node/v18.20.0/lib/node_modules/code-server$ npm i argon2
npm WARN cleanup Failed to remove some directories [
npm WARN cleanup   [
npm WARN cleanup     '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/.argon2-DrvUQdTV',
npm WARN cleanup     [Error: ENOTEMPTY: directory not empty, rmdir '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/.argon2-DrvUQdTV/build-tmp-napi-v3/Release/obj.target'] {
npm WARN cleanup       errno: -39,
npm WARN cleanup       code: 'ENOTEMPTY',
npm WARN cleanup       syscall: 'rmdir',
npm WARN cleanup       path: '/home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/.argon2-DrvUQdTV/build-tmp-napi-v3/Release/obj.target'
npm WARN cleanup     }
npm WARN cleanup   ]
npm WARN cleanup ]

added 333 packages, changed 1 package, and audited 521 packages in 2m

161 packages are looking for funding
  run `npm fund` for details

2 moderate severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

To address all issues, run:
  npm audit fix --force

Run `npm audit` for details.
haruki-py commented 3 months ago

Im bad at js. I mean really bad in js. My main language is python but I tried with my very lil knowledge bout js and tried my maximum then only I opened this issue

code-asher commented 3 months ago

No worries, npm is tricky especially with native modules like argon2.

I am not sure why ENOTEMPTY would happen here. I am reading online this can happen when there are network issues or other random failures, so it might be ephemeral. Does it persist if you run npm rebuild again? What about if you remove that directory (rm /home/userland/.nvm/versions/node/v18.20.0/lib/node_modules/code-server/node_modules/.argon2-DrvUQdTV -r) and then run npm rebuild again?

code-asher commented 5 days ago

Closing as stale but feel free to comment if you come back to this.

haruki-py commented 4 days ago

It worked when I tried Ubuntu docs directly

code-asher commented 4 days ago

Ah good to know! Sounds like they are out of date, I see they also specify Node 18 which is wrong now.