iocave / monkey-patch

Inject custom javascript into vscode
MIT License
155 stars 17 forks source link

Failed to enable on WSL #7

Open annappropriate opened 4 years ago

annappropriate commented 4 years ago

I'm using vscode to connect to a WSL instance and work in Linux. Monkey patch fails to enable. The error I get is:

Monkey Patch failed: Error: ENOENT: no such file or directory, open '/home/anna/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs/code/electron-browser/workbench/workbench.html'

There's no code directory at all:

$ ls ~/.vscode-server/bin/0ba0ca52957102ca3527cf479571617f0de6ed50/out/vs
base  loader.js  platform  server

No workbench.htlm file could be found in ~/.vscode-server either.

Any ideas? Extension works fine on local Windows and throws error only in WSL.

knopp commented 4 years ago

You can't install monkey patch in vscode server. What would be the point?

Monkey patch is used to customize vscode UI, and the UI is not running in vscode-server instances, only extensions are.

The UI is running on your windows machine, that's where you need to have customize UI installed.

ewen-lbh commented 4 years ago

@knopp that makes sense, but I don't see any option to install it locally. For anyone wondering how to make this work with WSL, here's how to do it:

  1. Get temporarily out of the WSL host: Click on WSL: (Your distro) in the bottom-left corner then Select "WSL-Remote: Reopen folder in Windows"
  2. Install the extension
  3. Change some settings
  4. Follow instructions (enable monkeypatch, reload window)
  5. If the window doesn't restart in WSL, you can just switch back to it using the steps in 1.

@knopp, if I may, you could add this to iocave/customize-ui's README ;) (I can do a PR if you want)

ewen-lbh commented 4 years ago

PS: Each time you want to change a setting, you'll have to get out of the WSL Host, as customize-ui's settings won't appear while vscode is hosted by WSL.

I also hope that extensions can declare this in some manifest in the future, as to handle this properly without having to switch back. Some extensions already do this (i.e. when you install them you see the "Installed locally" instead of "Installed on WSL: Ubuntu") but I'm guessing that this is reserved to color themes

knopp commented 4 years ago

You just install the extension before logging to remote server. The vscode server is a headless instance, it doesn't have any UI and there is nothing cutomize-ui can do there.

When you edit configuration while being connected to remote vscode (Preferences: Open User Settings) you will not get the Reload window prompt, but you can still reload the window manually (Developer: Reload window) to refresh changes.

annappropriate commented 4 years ago

Documenting this would be nice. I did get this error every time I opened a WSL window which is pretty annoying. Would be also great to silence the error if possible.

knopp commented 4 years ago

There shouldn't be any error if you don't install the extension in the remote host. It simply shouldn't be installed there. As for documentations, pull requests are always welcome :)

ewen-lbh commented 4 years ago

Yeah, I got that, but I was just saying that, for the end user, knowing the implementation details is not important, and—just as installing color themes from the WSL installs them locally without any user friction—I was wondering if there was a way to mark the extension as "local only" so that it could be installed locally, but from WSL, because having to switch back is just an inconvenience. If Color Themes are a special case and there's no way to tell vscode where to install it, then yes adding this atop the README will help, I can definitely do a pr for that.

QWp6t commented 4 years ago

Users can add this to settings.json file:

  "remote.extensionKind": {
    "iocave.customize-ui": ["ui"],
    "iocave.monkey-patch": ["ui"]
  },

Extension developers can add this to the manifest (package.json):

  "extensionKind": ["ui"]
ewen-lbh commented 4 years ago

Extension developers can add this to the manifest (package.json):

There, this is what I was talking about: developers should be telling vscode where to install the extension, not users

cblavier commented 4 years ago

@QWp6t @ewen-lbh just opened PR #18 for this matter

alexmondaini commented 3 years ago

"Cannot activate the 'Customize UI' extension because it depends on the 'Monkey Patch' extension, which is not loaded. Would you like to reload the window to load the extension? "

I have this message on remote but Customize UI works fine. how to get rid of the message prompt ?