coder / vscode-coder

Open any Coder workspace in VS Code with a single click.
MIT License
66 stars 15 forks source link

Logging out or connected to different deployment causes url load to fail with no such file or directory #173

Closed spikecurtis closed 4 months ago

spikecurtis commented 10 months ago

When logged out of the Coder extension or connecting to a different deployment of the Coder than the one previously logged in. I get the below error with VSCode not even trying to connect.

I think the relevant error is:

[14:48:57.703] Running script with connection command: ssh -T -D 51504 -o ConnectTimeout=20 'coder-vscode--matifali--coder' bash
[14:48:58.001] > Encountered an error running "coder vscodessh"
> read url: open /Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/url: no such file or directory
> kex_exchange_identification: Connection closed by remote host

Contents of .ssh/config:

Host github.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed25519

# ------------START-CODER-----------
# This section is managed by coder. DO NOT EDIT.
#
# You should not hand-edit this section unless you are removing it, all
# changes will be lost when running "coder config-ssh".
#
Host coder.coder
    HostName coder.coder
    ConnectTimeout=0
    StrictHostKeyChecking=no
    UserKnownHostsFile=/dev/null
    LogLevel ERROR
    ProxyCommand /opt/homebrew/bin/coder --global-config "/Users/matifali/Library/Application Support/coderv2" ssh --stdio coder
Host coder.coder.dev
    HostName coder.coder.dev
    ConnectTimeout=0
    StrictHostKeyChecking=no
    UserKnownHostsFile=/dev/null
    LogLevel ERROR
    ProxyCommand /opt/homebrew/bin/coder --global-config "/Users/matifali/Library/Application Support/coderv2" ssh --stdio coder.dev
# ------------END-CODER------------

# --- START CODER JETBRAINS dev.coder.com
Host coder-jetbrains--coder.dev--dev.coder.com
  HostName coder.coder.dev
  ProxyCommand "/Users/matifali/Library/Application Support/coder-gateway/dev.coder.com/coder-darwin-arm64" --global-config "/Users/matifali/Library/Application Support/coder-gateway/dev.coder.com/config" ssh --stdio coder.dev
  ConnectTimeout 0
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  LogLevel ERROR
  SetEnv CODER_SSH_SESSION_TYPE=JetBrains
# --- END CODER JETBRAINS dev.coder.com

# --- START CODER VSCODE ---
Host coder-vscode--*
  ConnectTimeout 0
  LogLevel ERROR
  ProxyCommand "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/bin/coder-darwin-arm64" vscodessh --network-info-dir "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/net" --log-dir "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/log" --session-token-file "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/session_token" --url-file "/Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/url" %h
  SetEnv  CODER_SSH_SESSION_TYPE=vscode
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
# --- END CODER VSCODE ---%

reported by @matifali in a different repo

spikecurtis commented 10 months ago

@matifali does the file /Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/url exist on your system? And, if so, are you still hitting the error?

@spikecurtis No, this does not exist if we are logged out of the Coder vscode extension and can not log in with the same error I posted. Error: connect ECONNREFUSED 127.0.0.1:80

And If I have previously connected to another Coder deployment (e.g https://atif.cdr.dev/) then, cat /Users/matifali/Library/Application Support/Code/User/globalStorage/coder.coder-remote/url is https://atif.cdr.dev% (the url of my other deployment).

Now if I try to connect to a workspace on dev.coder.com I get

image image

bpmct commented 10 months ago

I'm currently running into this. Is it related?

[15:50:47.915] Log Level: 2
[15:50:47.957] VS Code version: 1.80.2
[15:50:47.957] Remote-SSH version: remote-ssh@0.102.0
[15:50:47.957] darwin arm64
[15:50:55.744] SSH Resolver called for "ssh-remote+coder-vscode--bpmct--dev", attempt 1
[15:50:55.745] "remote.SSH.useLocalServer": true
[15:50:55.745] "remote.SSH.path": undefined
[15:50:55.745] "remote.SSH.configFile": undefined
[15:50:55.745] "remote.SSH.useFlock": true
[15:50:55.745] "remote.SSH.lockfilesInTmp": false
[15:50:55.745] "remote.SSH.localServerDownload": auto
[15:50:55.745] "remote.SSH.remoteServerListenOnSocket": false
[15:50:55.746] "remote.SSH.showLoginTerminal": false
[15:50:55.746] "remote.SSH.defaultExtensions": []
[15:50:55.746] "remote.SSH.loglevel": 2
[15:50:55.746] "remote.SSH.enableDynamicForwarding": true
[15:50:55.746] "remote.SSH.enableRemoteCommand": false
[15:50:55.746] "remote.SSH.serverPickPortsFromRange": {}
[15:50:55.746] "remote.SSH.serverInstallPath": {}
[15:50:55.754] SSH Resolver called for host: coder-vscode--bpmct--dev
[15:50:55.754] Setting up SSH remote "coder-vscode--bpmct--dev"
[15:50:55.756] Acquiring local install lock: /var/folders/vl/yb8hbt457170ghyvd_0qk80c0000gn/T/vscode-remote-ssh-d7dc8702-install.lock
[15:50:55.756] Looking for existing server data file at /Users/benpotter/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-d7dc8702-2ccd690cbff1569e4a83d7c43d45101f817401dc-0.102.0/data.json
[15:50:55.757] Using commit id "2ccd690cbff1569e4a83d7c43d45101f817401dc" and quality "stable" for server
[15:50:55.759] Install and start server if needed
[15:50:55.764] PATH: /Users/benpotter/.nvm/versions/node/v16.20.1/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/munki:/Users/benpotter/Library/Application Support/JetBrains/Toolbox/scripts:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Users/benpotter/Apps/flutter/bin:/Users/benpotter/Library/Android/sdk/tools/bin
[15:50:55.764] Checking ssh with "ssh -V"
[15:50:55.770] > OpenSSH_9.4p1, LibreSSL 3.3.6

[15:50:55.773] askpass server listening on /var/folders/vl/yb8hbt457170ghyvd_0qk80c0000gn/T/vscode-ssh-askpass-f5735aac85f434e38dfd7bb3ffaa3ee6dfa087b4.sock
[15:50:55.773] Spawning local server with {"serverId":1,"ipcHandlePath":"/var/folders/vl/yb8hbt457170ghyvd_0qk80c0000gn/T/vscode-ssh-askpass-b5f2f895291370a0a8bc7b4a62bb7af4cff2351f.sock","sshCommand":"ssh","sshArgs":["-v","-T","-D","52773","-o","ConnectTimeout=15","coder-vscode--bpmct--dev","bash"],"serverDataFolderName":".vscode-server","dataFilePath":"/Users/benpotter/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-ssh/vscode-ssh-host-d7dc8702-2ccd690cbff1569e4a83d7c43d45101f817401dc-0.102.0/data.json"}
[15:50:55.773] Local server env: {"SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.Xyghy1oWUT/Listeners","SHELL":"/bin/zsh","DISPLAY":"1","ELECTRON_RUN_AS_NODE":"1","SSH_ASKPASS":"/Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/local-server/askpass.sh","VSCODE_SSH_ASKPASS_NODE":"/private/var/folders/vl/yb8hbt457170ghyvd_0qk80c0000gn/T/AppTranslocation/1248821E-4003-4A92-B02C-F81CFA17F96F/d/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin)","VSCODE_SSH_ASKPASS_EXTRA_ARGS":"--ms-enable-electron-run-as-node","VSCODE_SSH_ASKPASS_MAIN":"/Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/askpass-main.js","VSCODE_SSH_ASKPASS_HANDLE":"/var/folders/vl/yb8hbt457170ghyvd_0qk80c0000gn/T/vscode-ssh-askpass-f5735aac85f434e38dfd7bb3ffaa3ee6dfa087b4.sock"}
[15:50:55.774] Spawned 29392
[15:50:55.839] > local-server-1> Running ssh connection command: "-v -T -D 52773 -o ConnectTimeout=15 coder-vscode--bpmct--dev bash"
[15:50:55.840] > local-server-1> Spawned ssh, pid=29398
[15:50:55.847] stderr> OpenSSH_9.4p1, LibreSSL 3.3.6
[15:50:56.048] stderr> Agent doesn't exist with that id.
[15:50:56.049] stderr> kex_exchange_identification: Connection closed by remote host
[15:50:56.049] stderr> Connection closed by UNKNOWN port 65535
[15:50:56.050] > local-server-1> ssh child died, shutting down
[15:50:56.053] Local server exit: 0
[15:50:56.054] Received install output: local-server-1> Running ssh connection command: "-v -T -D 52773 -o ConnectTimeout=15 coder-vscode--bpmct--dev bash"
local-server-1> Spawned ssh, pid=29398
OpenSSH_9.4p1, LibreSSL 3.3.6
Agent doesn't exist with that id.
kex_exchange_identification: Connection closed by remote host
Connection closed by UNKNOWN port 65535
local-server-1> ssh child died, shutting down

[15:50:56.054] Failed to parse remote port from server output
[15:50:56.056] Resolver error: Error: 
    at m.Create (/Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:584145)
    at t.handleInstallOutput (/Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:582705)
    at Object.e [as tryInstallWithLocalServer] (/Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:623656)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async /Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:643708
    at async t.withShowDetailsEvent (/Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:647428)
    at async /Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:622128
    at async C (/Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:618634)
    at async t.resolveWithLocalServer (/Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:621743)
    at async t.resolve (/Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:645036)
    at async /Users/benpotter/.vscode/extensions/ms-vscode-remote.remote-ssh-0.102.0/out/extension.js:1:720916
[15:50:56.064] ------
Screenshot 2023-12-11 at 3 53 00 PM
matifali commented 10 months ago

Agent doesn't exist with that id.

@bpmct this line is different. I suppose you are using the vscode-desktop module and its probably configured with a wrong agent.

bpmct commented 10 months ago

hmm interesting i was trying to connect using the workspaces list in my sidebar

code-asher commented 10 months ago

Very interesting, error seems to come from the Coder CLI. Does ssh coder-vscode--bpmct--dev work?

Kira-Pilot commented 5 months ago

@stirby to chat with Ben regarding prioritization before we continue work on this

Kira-Pilot commented 4 months ago

@code-asher let's solve this without the CLI deployment context piece right now!