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

Unable to paste text or images into a Dev Container #73

Open
ElanHasson opened this issue Feb 27, 2022 · 9 comments
Open

Unable to paste text or images into a Dev Container #73

ElanHasson opened this issue Feb 27, 2022 · 9 comments

Comments

@ElanHasson
Copy link

The dev container believes it's running linux, so it does not work for pasting images in that environment. Even directly in WSL, I get an invalid image being saved.

stack trace: Error: xsel: Can't open display: (null): Inappropriate ioctl for device    at Function.module.exports.sync (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/node_modules/execa/index.js:277:26)    at Object.pasteSync (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/node_modules/clipboardy/lib/linux.js:42:18)    at Object.exports.readSync (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/node_modules/clipboardy/index.js:41:37)    at Function.<anonymous> (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/out/paster.js:81:39)    at Generator.next (<anonymous>)    at /home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/out/paster.js:8:71    at new Promise (<anonymous>)    at __awaiter (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/out/paster.js:4:12)    at Function.pasteCode (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/out/paster.js:80:16)    at /home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/out/extension.js:65:25    at u._executeContributedCommand (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:93:30232)    at u.$executeContributedCommand (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:93:30774)    at i._doInvokeHandler (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:97:13801)    at i._invokeHandler (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:97:13485)    at i._receiveRequest (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:97:12147)    at i._receiveOneMessage (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:97:10825)    at /vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:97:8934    at l.fire (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:64:1712)    at s.fire (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:72:19002)    at /vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:112:34390    at l.fire (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:64:1712)    at s.fire (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:72:19002)    at a._receiveMessage (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:72:23583)    at /vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:72:21117    at l.fire (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:64:1712)    at _.acceptChunk (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:72:15833)    at /vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:72:14963    at l.fire (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:64:1712)    at d._processReadQueue (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:112:21346)    at d.acceptFrame (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:112:21002)    at p._acceptChunk (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:112:18966)    at /vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:112:15955    at Socket.T (/vscode/vscode-server/bin/linux-x64/f80445acd5a3dadef24aa209168452a3d97cc326/out/vs/workbench/services/extensions/node/extensionHostProcess.js:112:13838)    at Socket.emit (events.js:315:20)    at addChunk (internal/streams/readable.js:309:12)    at readableAddChunk (internal/streams/readable.js:284:9)    at Socket.Readable.push (internal/streams/readable.js:223:10)    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
  ERR xsel: Can't open display: (null)
: Inappropriate ioctl for device
: Error: xsel: Can't open display: (null)
: Inappropriate ioctl for device

    at Function.module.exports.sync (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/node_modules/execa/index.js:277:26)
    at Object.pasteSync (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/node_modules/clipboardy/lib/linux.js:42:18)
    at Object.exports.readSync (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/node_modules/clipboardy/index.js:41:37)
    at Function.<anonymous> (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/out/paster.js:115:51)
    at Generator.next (<anonymous>)
    at fulfilled (/home/node/.vscode-server/extensions/telesoho.vscode-markdown-paste-image-0.18.4/out/paster.js:5:58)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
@vezaynk
Copy link
Collaborator

vezaynk commented Feb 27, 2022

The extension actually runs on the VSCode server, which is the root of the issue.

@hotchilipowder
Copy link

The extension actually runs on the VSCode server, which is the root of the issue.

May I ask how to solve it?
I have the same issue when I want to use it in my home-lab server with code-server.
I have installed the xclip.
It works well when I drap a file to the web (The file can be successful uploaded into the server).
But I can't paste images to the server with this vscode extension.

@telesoho
Copy link
Owner

telesoho commented Mar 6, 2022

@ElanHasson

This is because xclip does not work properly under the dev container.
Maybe the DISPLAY environment variable was not been set correctly in your dev container.

you can check by run xclip -h command in container to confirm it work or not.

If not work, you should set your DISPLAY environment variable first. For example:

Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
export DISPLAY=":99.0"

@predkambrij
Copy link

Hi. It would be awesome if this issue would be fixed :) I'm using code-server for personal knowledge management (foam, but in web browser) and I think this issue might be similar or the same as in devcontainer.

There's some information I found so far:
coder/code-server#1849
dendronhq/dendron#749

So the solution might be correctly using clipboardy
https://code.visualstudio.com/docs/remote/troubleshooting#_clipboard-does-not-work

Best regards

@joaociocca
Copy link

I think I'm running in the same problem, despite not being a "dev container".

Using VS Code 1.67.2 on Windows 10, with Remote Server running Ubuntu.

When I try to paste I get nothing, on checking the extension's log, I get "Clipboard Type: -1 no xclip" but there isn't "xclip" on Windows.

So I thought, ok maybe the extension thinks it's running on Linux because of the remote stuff. Installed xclip on the remote server, but now the error is "Can't open display: (null)" - because, of course, there's no display there since I use it as a remote server only.

Which is curious, since it is installed locally and not on the remote server.

image

@meldarionqeusse
Copy link

@ElanHasson

This is because xclip does not work properly under the dev container. Maybe the DISPLAY environment variable was not been set correctly in your dev container.

you can check by run xclip -h command in container to confirm it work or not.

If not work, you should set your DISPLAY environment variable first. For example:

Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
export DISPLAY=":99.0"

How can I do this in docker-compose?

@chtran46
Copy link

Would implementing this into the extension help?
https://code.visualstudio.com/api/advanced-topics/remote-extensions#using-the-clipboard

@vezaynk
Copy link
Collaborator

vezaynk commented Oct 20, 2022

@chtran46 No. It missing the ability to read non-text clipboard data.

image

I filed the issue about this last year: microsoft/vscode#139761

@watahani
Copy link

Since the VS Code issue is not expected to be fixed, I created a simple extension for myself. I hope this will be useful to someone.

https://marketplace.visualstudio.com/items?itemName=watahani.markdown-image-paste-for-remote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants