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

VSCode Docker extensions does not work #4935

Closed
roflcoopter opened this issue Apr 17, 2019 · 18 comments
Closed

VSCode Docker extensions does not work #4935

roflcoopter opened this issue Apr 17, 2019 · 18 comments
Labels
bug bugs found in the application docker issues related to docker help wanted issues meant to be picked up, require help vscode issues related to VSCode compatibility

Comments

@roflcoopter
Copy link

Description

The VSCode docker extension does not load in Theia.

Reproduction Steps

  1. Install https://marketplace.visualstudio.com/items?itemName=PeterJausovec.vscode-docker
  2. Start Theia

OS and Theia version:
Ubuntu 18.04 - Theia nex 0.6.0

Diagnostics:
It fails with this error
root ERROR [hosted-plugin: 12451] (node:12451) UnhandledPromiseRejectionWarning: Error: Internal error: Could not find keytar module for reading and writing passwords at /home/theia/plugins/vscode-docker/extension/dist/extension.bundle.js:263:1618389 at Function.tryCreate (/home/theia/plugins/vscode-docker/extension/dist/extension.bundle.js:263:1618481) at /home/theia/plugins/vscode-docker/extension/dist/extension.bundle.js:157:603905 at Object.t.activateInternal (/home/theia/plugins/vscode-docker/extension/dist/extension.bundle.js:157:603957) at activate (/home/theia/plugins/vscode-docker/extension/main.js:22:28) at PluginManagerExtImpl.startPlugin (/home/theia/node_modules/@theia/plugin-ext/lib/plugin/plugin-manager.js:172:73)

@tetchel
Copy link
Contributor

tetchel commented Apr 18, 2019

VS Code shipping Keytar is not API, but it's used by multiple extensions anyway since there is no better way to securely store user data. See microsoft/vscode#68738

@roflcoopter
Copy link
Author

I see, do you have any idea how I can install it manually?

Tried putting it in my package.json which doesn't seem to work

@tetchel
Copy link
Contributor

tetchel commented Apr 18, 2019

Maybe someone from the Theia team can comment, but native modules such as keytar are a difficult problem because they have to be compiled per-platform. Maybe you could provide more info about why installing it normally didn't work?

microsoft/vscode#658

@dinvlad
Copy link

dinvlad commented May 28, 2019

@roflcoopter have you gotten around this problem? I've tried everything it seems, but the core of the problem seems to be their use of ${vscode.env.appRoot} value, which is undefined in Theia, afaiu: https://github.com/microsoft/vscode-docker/blob/e63ce0eea9f25e94a968005a41f72ad2982a77e3/src/utils/getCoreNodeModule.ts#L14

Or is there a way to resolve "hard-coded" ${vscode.env.appRoot} inside Theia?

To be clear, I successfully installed keytar package into the Theia installation folder, so the package is definitely there; it's just that appRoot cannot be resolved to this folder..

One more (ugly) workaround may be to patch vscode-docker code to replace ${vscode.env.appRoot} with the Theia root. But I'm unsure how to do that in the context of an extension..

UPDATE: Patching it in-place seems to have worked (I no longer get the OP's error message), but syntax highlighting for Dockerfiles still doesn't work.

@akosyakov
Copy link
Member

@dinvlad syntax highlighting is contributed by built-in vscode extensions: https://github.com/microsoft/vscode/tree/master/extensions/docker

We've republished them to npmjs to consume: https://www.npmjs.com/package/@theia/vscode-builtin-docker

@akosyakov
Copy link
Member

You can try open an issue for vscode-docker to make it configurable somehow. How do you think we could help you from our side? In electron app it probably can be the same, but for browser target we don't have node_modules.asar. We should provide though proper vscode.env.appRoot so maybe you can have a script installing keytar in the proper location.

@akosyakov akosyakov added docker issues related to docker question user / developer questions vscode issues related to VSCode compatibility labels May 28, 2019
@dinvlad
Copy link

dinvlad commented May 28, 2019

Thanks! Will use @theia/vscode-builtin-docker. I was confused by the claim on vscode-docker extension page that it provides syntax highlighting :)

UPDATE: Syntax highlighting still doesn't seem to be working for me, even with the builtin extension. I realize this is a separate issue, so will likely file it there.

Re appRoot, I’m still confused because it seems like @theia/plugin-ext already provides the env namespace with appRoot: https://github.com/theia-ide/theia/blob/4a54abb6741672d291af1919ec610a51fa4e7556/packages/plugin-ext/src/plugin/node/env-node-ext.ts#L54

I guess it’s just not getting converted to vscode import?

@dinvlad
Copy link

dinvlad commented May 29, 2019

Sorry if this is off-topic here, but I got the highlighting working now too, by packaging https://github.com/microsoft/vscode/tree/master/extensions/docker directly with vsce package, and installing it as a VSCode plugin.

So at this point, everything seems to be working re vscode-docker, provided I replace ${vscode.env.appRoot} with __dirname in it. I can no longer see errors in the console, and all relevant functionality seems to work well (incl. getting contextual help inside Dockerfiles).

How should we proceed re appRoot?

@akosyakov
Copy link
Member

akosyakov commented May 29, 2019

It seems to be bogus that appRoot is implemented with __dirname in ext-node-ext.ts. I would expect that it point to a directory from which Theia is started. Probably just copying impl from vscode will do: https://github.com/microsoft/vscode/blob/6964233e81c68f5a5f34e7eb1da0836e1d539f14/src/vs/platform/environment/node/environmentService.ts#L83

cc @benoitf @evidolob

@dinvlad
Copy link

dinvlad commented May 29, 2019

@akosyakov you're right, I spoke too soon - __dirname doesn't work after all. It only works when I replace ${vscode.env.appRoot} with the literal value of the path from which Theia is started.. So the code you linked makes sense.

@dinvlad
Copy link

dinvlad commented May 29, 2019

How about we replace __dirname with process.cwd() in https://github.com/theia-ide/theia/blob/4a54abb6741672d291af1919ec610a51fa4e7556/packages/plugin-ext/src/plugin/node/env-node-ext.ts#L54

That seems to work, i.e. process.cwd() points to the folder from which Theia was started (/opt/theia in my setup).

UPDATE: this seems to be the crux of the problem. After patching env-node-ext.ts in this way, I no longer have to patch the extension. I.e. ${vscode.env.appRoot} automatically resolves to the correct path.

dinvlad added a commit to broadinstitute/wdl-ide that referenced this issue May 30, 2019
This commit includes the official Microsoft
plugin for Docker (extension/PeterJausovec.vscode-docker).

However, for the correct operation of the plugin
we had to adjust a few more things
(eclipse-theia/theia#4935):
- patch Theia to return process.cwd() as env.appRoot
- add 'keytar' package and libsecret to the Docker image
- install "built-in" VSCode Docker extension
  for syntax highlighting in Dockerfiles
@akosyakov
Copy link
Member

@dinvlad please open a PR @benoitf @evidolob Do you see any concerns with it? My only concern that it relies on child_process.fork behaviour. If we at some point provide another cwd it will be silently broken. I would rather ask main Theia process for a proper app root.

@dinvlad
Copy link

dinvlad commented May 30, 2019

That make sense @akosyakov! I'm not sure where to plug in that kind of code though..

@akosyakov
Copy link
Member

@dinvlad we could pass it as env variable here: https://github.com/theia-ide/theia/blob/797db759bcdde66c8bbabf2ab0b041bc7d887d30/packages/plugin-ext/src/hosted/node/hosted-plugin-process.ts#L158 you can get the proper app path from here, i.e. via injecting ApplicationPackage

@akosyakov akosyakov added bug bugs found in the application help wanted issues meant to be picked up, require help and removed question user / developer questions labels Oct 17, 2019
@JennyMet
Copy link

JennyMet commented Oct 19, 2020

I've the same issue when using vscode-docker 1.6.0 , I saw that this is issue have started more then a year ago, is there any progress? or any workaround that we can use?

The error is: Activating extension 'Docker' failed: Internal error: Could not find keytar module for reading and writing passwords

@sumeshkanayi
Copy link

sumeshkanayi commented Oct 23, 2020

Same here .I tried the steps mentioned by @dinvlad ie:by changing the path returned to /data/theia (in my case theia is started from here) but ended up with keytar error .I confirmed that keytar is available locally though

Update: this time with a different error,could not start dockerfile language server .. s.languages.registerDocumentSemanticTokensProvider is not a function .I will dig in more

@Viromic
Copy link

Viromic commented Oct 28, 2020

Activating extension 'Docker' failed: Internal error: Could not find keytar module for reading and writing passwords is still not operational

@vince-fugnitto
Copy link
Member

The issue seems to be fixed for newer versions of vscode-docker as keytar is deprecated in favor of using the secrets api.
In the future vscode will completely remove support for keytar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application docker issues related to docker help wanted issues meant to be picked up, require help vscode issues related to VSCode compatibility
Projects
None yet
Development

No branches or pull requests

8 participants