Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How can I start code-server from specific workspace file? #3616

Answered by ghost
dkultasev asked this question in General
Discussion options

I can start code-server and specify startup folder. Can I start by passing workspace file?

You must be logged in to vote

I recommend reading the FAQ as it answers a lot of questions people typically ask. As for what you mentioned, How does code-server decide what workspace or folder to open?. So you can use a query parameter in the url or from the command line when launching code-server.

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
3 replies
Comment options

in such case I'll open everything from single folder. I can have different folders from different locations in the same workspace and I can save these settings to the file and then open at any time. Additionally I can have separate settings for each of such workspaces. I can open workspace file in VS Code and it will open all needed folders for me and apply all needed settings. Can I open workspace file with code-server?

Comment options

If you are talking about Multi-Root Workspaces then yes, you can save the workspace file in your code-server machine and can access it from the url:
https://codeserver-url.com?workspace=/path/to/workspace.code-workspace-file

Comment options

How can I start the code-server with workspace? I want to have the dockerfile that I would build/run and it would created new container that I'll open with specific workspace on the first launch

Comment options

I recommend reading the FAQ as it answers a lot of questions people typically ask. As for what you mentioned, How does code-server decide what workspace or folder to open?. So you can use a query parameter in the url or from the command line when launching code-server.

You must be logged in to vote
4 replies
Comment options

I saw the workspace query param mentioning there, however didn't find any mention on what the query param is. I tried to do --workspace but it didn't work. I also tried to pass the path to the workspace file, that didn't help either.

Comment options

You can try it for yourself. Open code-server, open a folder, right click in the explorer and choose "Add folder to workspace" and select a different folder. You should be redirected to a url such as https://example.com/?workspace=/home/coder/.local/share/code-server/User/Workspaces/Untitled-1623868353702.code-workspace. If you click File in the menubar, you can click "Save workspace as" and choose a path to save the workspace file to. Then, instead of pointing to a temp file under /home/coder/.local/share/code-server/User/Workspaces/, you could point the query param to the workspace file directly.

Comment options

The docs could use another run through. workspace query param means the query param in the browser URL. Here is an example:

http://localhost:8080/?workspace=/Users/jp/.local/share/code-server/User/test.workspace.code-workspace

from the command line when launching code-server

Using the same workspace as above, you can do it like this:

code-server /Users/jp/.local/share/code-server/User/test.workspace.code-workspace

If you think this should be in the docs (either new entry or updated), please feel free to open a PR!

Comment options

I just tried it on my server and it worked successfully, I guess you might've done something wrong.In my case, the url was: https://codeserver987.herokuapp.com/?workspace=/app/.data/User/Workspaces/w1.code-workspace and my workspace was:

Answer selected by jsjoeio
Comment options

(削除) code-server /path/to/file.workspace should work (third option in the linked docs). Otherwise you can use the query param as mentioned above. (削除ここまで)

Edit: oops @jsjoeio also mentioned passing on the command line! Ignore me. :)

If doing code-server file.workspace doesn't open the workspace then that's a bug because it's supposed to!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /