Skip to content

Allow opening files, folders, and workspaces in existing code-server from CLI #1994

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

Merged
merged 4 commits into from
Aug 27, 2020

Conversation

shayne
Copy link
Contributor

@shayne shayne commented Aug 25, 2020

Add initial support for opening files / folders in running code-server instance.

Capabilities:

  • Open an existing/new file(s) in running instance
$ code-server --reuse-window --open-in foo.txt
# or
$ code-server -oi foo.txt -r
  • Open an existing folder in a new window
$ code-server --new-window --open-in path/to/project
# or
$ code-server -oi path/to/project -n

Current limitations:

  • unable to open a file in a new window, only folders
  • unable to use addMode feature
  • others...

#164

@nhooyr nhooyr changed the base branch from master to dev August 25, 2020 18:50
@nhooyr nhooyr closed this Aug 25, 2020
@nhooyr
Copy link
Contributor

nhooyr commented Aug 25, 2020

I'm so sorry about this! Deleted the dev branch was gonna switch this back to base on master but GitHub doesn't let you do that.... After you delete the PR base.

🤦

Please open a new PR with these changes! Once again, I'm so sorry!

@nhooyr
Copy link
Contributor

nhooyr commented Aug 25, 2020

Nvm, got it!

@nhooyr nhooyr reopened this Aug 25, 2020
@nhooyr nhooyr changed the base branch from dev to master August 25, 2020 19:08
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

I gave it a test run and it works like a charm! Left a couple minor comments and am curious as to your thoughts on them.

@code-asher
Copy link
Member

code-asher commented Aug 26, 2020

Awesome. It looks like the patch needs to be regenerated (to update the line number and hash) and I recently made a change to ipc.d.ts as well so we'll need to rebase or merge in master first before regenerating the patch (will need to update the vscode submodule as well since it's now on 1.48.2). Lemme know if you wanna handle that or if I should go ahead and do it (I think I'd need to create a new branch though since I can't push to yours).

shayne added 3 commits August 27, 2020 09:57
Add initial support for opening files / folders in running code-server instance.

Current limitations:

- unable to open a file in a new window, only folders
- unable to use addMode feature
- others...
* Change loop to indexed `for` loop
* Moved isDirectory check to IsDir local func, to prevent continue in loop and messy try/catch
* Cleaned up white space issue with patch
@shayne
Copy link
Contributor Author

shayne commented Aug 27, 2020

the patch needs to be regenerated

Think I got it, let me know how the PR looks now

@code-asher
Copy link
Member

Looks great! Thanks for the contribution. ❤️

@code-asher code-asher merged commit ceb2265 into coder:master Aug 27, 2020
@code-asher
Copy link
Member

I think we can actually remove the open-in flag, lemme know if you think there could be any problems with that: #2013

@BEFH
Copy link

BEFH commented Jul 6, 2022

I'm getting this error:

[2022-07-06T17:18:23.749Z] error got error from Code {"error":{"errno":-2,"code":"ENOENT","syscall":"connect","address":"/hpc/users/fultob01/vsc_runtime/vscode-ipc-9ed54319-8737-41e7-a821-5ed74ba4a14c.sock"}}

Thoughts?

@jsjoeio
Copy link
Contributor

jsjoeio commented Jul 18, 2022

@BEFH strange! Can you tell us more about your environment?

@code-asher
Copy link
Member

code-asher commented Jul 21, 2022 via email

@BEFH
Copy link

BEFH commented Jul 21, 2022

@jsjoeio, what do you want to know about my environment? I can run commands and attach information.

I have installed code-server using anaconda and use fish as my shell. The server is running within a job on a centos 7 cluster with a bsub/lsf scheduler.

@code-asher, I am using the integrated terminal

@code-asher
Copy link
Member

Huh, strange. VS Code is supposed to set the VSCODE_IPC_HOOK_CLI environment variable. Then when running code-server in the integrated terminal it is supposed to read that variable and write to the socket it contains.

Can you verify that VSCODE_IPC_HOOK_CLI is the same path as the path you get in the error? Possibly there is something wrong with that environment variable and code-server is using an old socket path or something.

@BEFH
Copy link

BEFH commented Jul 21, 2022 via email

@code-asher
Copy link
Member

Very strange that it is using the wrong path. The code seems to just use that as-is if it exists.

code-server/src/node/cli.ts

Lines 747 to 750 in 40b650b

if (process.env.VSCODE_IPC_HOOK_CLI) {
logger.debug("Found VSCODE_IPC_HOOK_CLI")
return process.env.VSCODE_IPC_HOOK_CLI
}

Could you run it with trace logging? code-server --log trace -r lsf.yaml

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.

5 participants