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

Update to work with newer VSCode Server folder structure + dual installation fix #17

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Mikrz
Copy link

@Mikrz Mikrz commented May 7, 2024

This PR fixes the detection to work with the newer VSCode Remote Server file structure. Not sure when it changed, but it works again with this.

I also included a fix I made for cases where the remote system might also have a local installation of VSCode, where code-connect might conflict.

@@ -68,17 +66,17 @@ def get_code_binary() -> Path:

# Every entry in ~/.vscode-server/bin corresponds to a commit id
# Pick the most recent one
code_repos = sort_by_access_timestamp(Path.home().glob(".vscode-server/bin/*"))
code_repos = sort_by_access_timestamp(Path.home().glob(".vscode-server/cli/servers/*"))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Sorry, I'm just a random passer-by, not the author)

Maybe we can put a more concrete condition for repo candidates, otherwise:

$ code
Traceback (most recent call last):
  File "/home/USER/.code-connect/bin/code_connect.py", line 120, in <module>
    main()
  File "/home/USER/.code-connect/bin/code_connect.py", line 113, in main
    proc = sp.run(args)
           ^^^^^^^^^^^^
  File "/home/USER/.asdf/installs/python/3.11.9/lib/python3.11/subprocess.py", line 548, in run
    with Popen(*popenargs, **kwargs) as process:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/USER/.asdf/installs/python/3.11.9/lib/python3.11/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/home/USER/.asdf/installs/python/3.11.9/lib/python3.11/subprocess.py", line 1955, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: '/home/USER/.vscode-server/cli/servers/lru.json/server/bin/remote-cli/code'
$ l ~/.vscode-server/cli/servers
total 12K
drwxr-xr-x 3 USER USER 4.0K May  6 08:46 Stable-b58957e67ee1e712cebf466b995adf4c5307b2bd
drwxr-xr-x 3 USER USER 4.0K Apr 25 16:32 Stable-e170252f762678dec6ca2cc69aba1570769a5d39
-rw-r--r-- 1 USER USER  101 May  6 08:46 lru.json

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, no apologies necessary. I very much like more robust solutions, and this is certainly the way to go. I'll probably dig into this tomorrow a little.

Copy link
Author

@Mikrz Mikrz May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kissge I rewrote the cli executable search code to be a lot more broad but also check against the output to make sure we're only manipulating the right code binaries. It seems to work, though I don't have access to my non-local system to properly test at the moment, nor do I have multiple versions installed to confirm it selects the most up-to-date executable.

Let me know how it works for you!

As an aside, I do have an idea to check against the code binary that's in the path to verify the right hash to use, but that'd be a bit more work than I think is really necessary.

@dotaxis
Copy link

dotaxis commented Dec 5, 2024

Hey! Shame this never got merged.

I had to make some changes to get it working in fish, but it works, so thank you!

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

Successfully merging this pull request may close these issues.

3 participants