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

Wrong symlink for node_modules.asar #3355

Closed
aptalca opened this issue May 11, 2021 · 2 comments · Fixed by #3369
Closed

Wrong symlink for node_modules.asar #3355

aptalca opened this issue May 11, 2021 · 2 comments · Fixed by #3369
Assignees
Labels
bug Something isn't working
Milestone

Comments

@aptalca
Copy link

aptalca commented May 11, 2021

OS/Web Information

  • Web Browser: chrome
  • Local OS: Win 10
  • Remote OS: Ubuntu Bionic (linuxserver docker)
  • Remote Architecture: x86_64
  • code-server --version: 3.10.0

Steps to Reproduce

  1. Install extension Bracket Pair Colorizer 2
  2. Check the remote extension host log

Expected

Should enable properly

Actual

Error message:

[2021-05-11 14:16:02.450] [exthost] [info] ExtensionService#_doActivateExtension CoenraadS.bracket-pair-colorizer-2 {"startup":true,"extensionId":{"value":"CoenraadS.bracket-pair-colorizer-2","_lower":"coenraads.bracket-pair-colorizer-2"},"activationEvent":"*"}
[2021-05-11 14:16:02.450] [exthost] [info] ExtensionService#loadCommonJSModule file:///config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/extension
[2021-05-11 14:16:02.679] [exthost] [error] Activating extension CoenraadS.bracket-pair-colorizer-2 failed due to an error:
[2021-05-11 14:16:02.679] [exthost] [error] Error: Cannot find module '/usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/node_modules.asar/vscode-textmate'
Require stack:
- /config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/textMateLoader.js
- /config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/settings.js
- /config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/documentDecorationManager.js
- /config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/extension.js
- /usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/out/vs/loader.js
- /usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/out/bootstrap-amd.js
- /usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/out/bootstrap-fork.js
	at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
	at Function.Module._load (internal/modules/cjs/loader.js:667:27)
	at Function.i._load (/usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:106:27950)
	at Function.S._load (/usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:106:24660)
	at Function.a._load (/usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:96:58822)
	at Module.require (internal/modules/cjs/loader.js:887:19)
	at require (internal/modules/cjs/helpers.js:74:18)
	at TextMateLoader.getNodeModule (/config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/textMateLoader.js:106:16)
	at TextMateLoader.loadTextMate (/config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/textMateLoader.js:109:21)
	at new TextMateLoader (/config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/textMateLoader.js:18:27)
	at new Settings (/config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/settings.js:10:31)
	at new DocumentDecorationManager (/config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/documentDecorationManager.js:9:25)
	at activate (/config/extensions/coenraads.bracket-pair-colorizer-2-0.1.4/out/src/extension.js:6:37)
	at Function._callActivateOptional (/usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:92:14813)
	at Function._callActivate (/usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:92:14486)
	at /usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:92:12643
	at processTicksAndRejections (internal/process/task_queues.js:97:5)
	at async Promise.all (index 2)
	at async Promise.all (index 0)

Logs

See above

Screenshot

N/A

Notes

The issue seems to be that node_modules.asar is incorrectly symlinked when code-server is installed via yarn.

root@tower:/usr/local/share/.config/yarn/global/node_modules/code-server/lib/vscode# ls -al
total 20
drwxr-xr-x 1 root root  150 May 10 19:46 .
drwxr-xr-x 1 root root   46 May 10 19:45 ..
drwxr-xr-x 1 root root 2024 May 10 19:48 extensions
drwxr-xr-x 1 root root 2196 May 10 19:48 node_modules
lrwxrwxrwx 1 root root   23 May 10 19:45 node_modules.asar -> lib/vscode/node_modules
drwxr-xr-x 1 root root  318 May 10 19:45 out
-rw-r--r-- 1 root root 5285 May 10 19:45 package.json
-rw-r--r-- 1 root root 5947 May 10 19:45 product.json
drwxr-xr-x 1 root root   16 May 10 19:45 resources

The symlink should point to node_modules and not lib/vscode/node_modules

Fixing the symlink fixes the issue, the extension is activated properly.

It seems PR #2197 attempted the symlink but perhaps incorrectly (did not dig into the code).

This issue can be reproduced in VS Code: Not tested

@jsjoeio jsjoeio added the needs-investigation This issue needs to be further investigated label May 11, 2021
@jsjoeio
Copy link
Contributor

jsjoeio commented May 11, 2021

Thanks for the report, @aptalca! And for investigating it a bit further. We'll investigate.

cc @code-asher

@code-asher code-asher self-assigned this May 12, 2021
@code-asher code-asher modified the milestones: On Deck, v3.11.0 May 12, 2021
@code-asher
Copy link
Member

code-asher commented May 12, 2021

Strange...we essentially do:

cd lib/vscode
if [ ! -e node_modules.asar ] ; then
  ln -s node_modules node_modules.asar
fi

So it seems like it shouldn't be possible for the symlink to be created incorrectly...not only that but we skip ln if the symlink already exists and our npm package uploads with the symlink already in place (I confirmed by downloading the 3.10.0 tarball, unpacking it, checking that the symlink already exists and is correct, then running yarn to make sure it doesn't replace it).

However I tried yarn global add code-server and sure enough I had the broken symlink. If I delete the link before the install finishes then the postinstall creates the link (correctly).

So...somehow the way yarn global add unpacks the tarball results in a broken symlink?

I think I'll just re-create the symlink every time instead of checking that a link already exists to ensure it's correct.

code-asher added a commit to code-asher/code-server that referenced this issue May 12, 2021
This ensures the link is correct. Should fix coder#3355.
code-asher added a commit to code-asher/code-server that referenced this issue May 12, 2021
This ensures the link is correct. Should fix coder#3355.
@code-asher code-asher added bug Something isn't working and removed needs-investigation This issue needs to be further investigated labels May 12, 2021
code-asher added a commit that referenced this issue May 12, 2021
This ensures the link is correct. Should fix #3355.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants