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

Native settings sync #2195

Open
pwoolvett opened this issue Oct 12, 2020 · 38 comments
Open

Native settings sync #2195

pwoolvett opened this issue Oct 12, 2020 · 38 comments
Labels
feature New user visible feature
Milestone

Comments

@pwoolvett
Copy link

Hi. Since native sync is available upstream, is there motivation to implement this? maybe choosing a different "backend" (eg github gists, a la settings sync ext

@code-asher
Copy link
Member

code-asher commented Oct 12, 2020

I'd like to get it working but I'm unsure if it's possible. Will need to investigate. Related: #2064

@Stradivario
Copy link

I can help with this feature also.

@code-asher
Copy link
Member

code-asher commented Oct 14, 2020 via email

@csaska
Copy link
Contributor

csaska commented Nov 23, 2020

Settings Sync by Shan Khan seems like a fine alternative for now.

However, it does not appear to work if code-server is used behind a HTTPS reverse proxy. If code-server is running behind a reverse proxy, clicking Login With GitHub will generate a bad URI for the callback as this extension is not aware that it is behind a proxy.

E.g. code-server running on localhost:54321 behind a proxy that is exposed via my.domain.com. Clicking "Login with GitHub" generates http://localhost:54321/callback?code=1234 instead of https://my.domain.com/callback?code=1234

@code-asher
Copy link
Member

code-asher commented Nov 23, 2020 via email

@csaska
Copy link
Contributor

csaska commented Nov 23, 2020

Yea definitely a problem with the extension. I just wanted to comment here to link the two issues together.

If the following headers are set by the proxy, and the extension has access to the original request received from code-server, it should be able to generate a valid URI.

E.g.

      proxy_set_header   Host                 $host;
      proxy_set_header   X-Real-IP            $remote_addr;
      proxy_set_header   X-Forwarded-For      $proxy_add_x_forwarded_for;
      proxy_set_header   X-Forwarded-Proto    $scheme;
      proxy_set_header   X-Forwarded-Prefix   /prefix/if/there/is/one;

I am completely naive to how code-server sends requests to VS Code and what the extension has access to.

@nhooyr nhooyr added enhancement Some improvement that isn't a feature feature New user visible feature and removed needs-investigation enhancement Some improvement that isn't a feature labels Dec 7, 2020
@chilcano
Copy link

I solved this issue with this workaround.
shanalikhan/code-settings-sync#1236 (comment)
Hope it helps.

@Yrobot
Copy link

Yrobot commented Jul 31, 2021

Hope native settings sync will work in the future.

@stale
Copy link

stale bot commented Jan 27, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no activity occurs in the next 5 days.

@stale stale bot added stale and removed stale labels Jan 27, 2022
@prokher
Copy link

prokher commented Jan 27, 2022

It still would be nice to have it.

@djarbz
Copy link
Contributor

djarbz commented May 6, 2022

As a workaround, I copied the URL and ran a curl from the code-server terminal window.
curl localhost:54321/callback?code=SecretCode

@jsjoeio
Copy link
Contributor

jsjoeio commented May 6, 2022

@djarbz and that worked for you?

@djarbz
Copy link
Contributor

djarbz commented May 6, 2022

Yes, for shanalikhan/code-settings-sync.
This extension is listening on port 54321 and is just looking for the secret code to come through as a query.

@nghminh163
Copy link

Actually, u can enable native settings but u need to get config from your local vscode and patch it to code-server. I enabled and patch my code server version with vscode config so I can get ext from vscode official like Copilot and using sync with my Github Account

@djarbz
Copy link
Contributor

djarbz commented Jul 10, 2022

@nghminh163 can you elaborate on the steps needed for this?

@nghminh163
Copy link

Actually, in this week I will make new fork for adaptive with my patch. I will ping here again with my document

@jmqm
Copy link

jmqm commented Aug 13, 2022

Actually, in this week I will make new fork for adaptive with my patch. I will ping here again with my document

@edqx
Copy link

edqx commented Feb 7, 2023

Any updates on this in the new year? It might be the one thing stopping me from really using Coder properly as I used GitHub codespaces.

@code-asher
Copy link
Member

code-asher commented Feb 9, 2023 via email

@qraynaud
Copy link

qraynaud commented May 5, 2023

@nghminh163 you seemed to have a solution? Is this any good?

@bordernone
Copy link

Actually, in this week I will make new fork for adaptive with my patch. I will ping here again with my document

any update?

@davidcomputes
Copy link

No updates. I think it is unlikely this will get worked on from our end any time soon (possibly never).

Too complicated, not enough demand, or both? It'd be a very helpful update.

@code-asher
Copy link
Member

code-asher commented Jul 17, 2023 via email

@edqx
Copy link

edqx commented Jul 20, 2023

Just for a grasp of what is actually required: I'm assuming it isn't reasonable to use the same database that Visual Studio uses (i.e., by using some undocumented API), so I'm guessing that the only way forward for proper "settings sync" between clients is to make it an extension, possibly pre-installed. This isn't "native" obviously but it's better than nothing.

It could be built into the editor (native), but I don't think this helps considering you'd need to install an extension on non-Coder instances of Visual Studio Code to actually import your settings from. Alternatively, it might just be a neat thing standalone that every Coder Visual Studio Code instance under your user (for each of your projects) has the same settings. In this way it could be native.

The extension https://marketplace.visualstudio.com/items?itemName=Shan.code-settings-sync&ssr=false#overview, I've found, is very sub-par and I've had very little success with it; I've found it easier just to install the extensions that I need manually.

Willing to PR if we can figure out the requirements exactly here.

@code-asher
Copy link
Member

code-asher commented Jul 20, 2023 via email

@edqx
Copy link

edqx commented Jul 20, 2023

Thanks for the responses!

Re-implementing the settings sync API sounds fun! 🙂 That could be a decent project, could use the opportunity to learn some Rust finally (I know... late bloomer). I think an extension for non-coder VS Code would be fairly light-weight in this situation - it would just be a matter of somehow redirecting the default settings sync API back-end to the user configured one. If that's not possible, then most of the code for settings sync things is freely available anyway.

I'll wait to hear some thoughts on using something like Gist VS a private settings sync instance before going further though. I will say that going the back-end route is likely more helpful for me personally.

@kimtiago
Copy link

Use this extension, it's working

https://marketplace.visualstudio.com/items?itemName=nonoroazoro.syncing

@Ali-Flt
Copy link

Ali-Flt commented Aug 22, 2023

I used nonoroazoro.syncing and it broke my extensions after I changed from a browser to another (some extensions were removed, had to reinstall them). Maybe I did something wrong but I don't think so. I do not recommend using it

@kimtiago
Copy link

I used nonoroazoro.syncing and it broke my extensions after I changed from a browser to another (some extensions were removed, had to reinstall them). Maybe I did something wrong but I don't think so. I do not recommend using it

Maybe you must observe this at the end of Getting Started session:

Frequently Asked Questions
How do I make this work with code-server?

Code-server follows the XDG spec to set config & data directories. When using their Docker image, you can set XDG_DATA_HOME="/home/coder/.config/" to store everything files in the same directory. This enables vscode-syncing to easily pickup the right locations. Since it is also a recommended volume path, it ensures persistence of your changes.

@Ali-Flt
Copy link

Ali-Flt commented Aug 23, 2023

Maybe you must observe this at the end of Getting Started session:

Interesting.. I am not using the docker image though. Is this also achievable with the code-server cli? The cli accepts --user-data-dir and --extensions-dir. Is setting these two arguments to the same directory the same as using XDG_DATA_HOME?
Also I tried setting the XDG_DATA_HOME environment variable and then running the code-server but it didn't work:
image

Do you know where I can find the dockerfile of the code-server Docker image?

@kimtiago
Copy link

i don't know, i use docker and this tip fixed my problem...

you can ask for help here
https://github.com/nonoroazoro/vscode-syncing

@code-asher
Copy link
Member

code-asher commented Aug 28, 2023 via email

@Ali-Flt
Copy link

Ali-Flt commented Aug 28, 2023

@code-asher oh I did not know that export has that functionality😅 Thanks

@StrangeNoob
Copy link

StrangeNoob commented Sep 22, 2024

I'm not entirely sure how this happened, but it worked for me.

Screenshot 2024-09-22 at 10 08 30 PM

I zipped all my local VSCode extensions (~/.vscode/extensions), SCPed them to the Docker-mounted config, and reloaded Code-Server. It resolved the issue.

Edited: It didn't work. Sorry for the inconvenience.

@nathang21
Copy link

@StrangeNoob I got excited by your solution but I was not able to replicate it. To be clear, you are using the native settings sync in the official VS Code, not one of the other 3rd party extensions?

This is what I see, and clicking turn on Cloud Changes does not appear to do anything.
image

@StrangeNoob
Copy link

StrangeNoob commented Sep 24, 2024

As @nathang21 told me, it didn't work for him. I have tried to do it again, and it worked for me.

Here are the steps to do this:

  1. Navigate to the VSCode Configuration:

    • The configuration is typically located at ~/.vscode.
    • Inside, you'll find the extensions folder.
  2. Compress the Extensions:

    • Zip the extensions folder into extension.zip.
    • You can use the following command:
      zip -r extension.zip ~/.vscode/extensions
  3. Transfer the Zip File to Your code-server Host:

    • Use scp to copy the extension.zip to the server where your code-server configuration is located.
    • I'm using Termius for this purpose.
    • Example command:
      scp extension.zip user@server:/path/to/code-server/config/

    Screenshot 2024-09-24 at 10:05:09 AM

  4. Unzip the Extensions on the Server:

    • SSH into your server:
      ssh user@server
    • Navigate to the code-server extensions directory:
      cd /path/to/code-server/config/
    • Unzip the extension.zip into a folder named extensions:
      unzip extension.zip -d extensions
  5. Reload the code-server Window:

    • After unzipping, reload the code-server window to apply the changes.
    • You can do this by refreshing the browser page where code-server is running or by restarting the code-server service:
      systemctl restart code-server
  6. Verify the Extensions:

    • The extensions should now be available in your code-server environment.
    • Note: The sync settings might not work as expected. I haven't tried changing the settings, so you all can test it.

    Screenshot 2024-09-22 at 10:08:30 PM

Edited: It didn't work. Sorry for the inconvenience.

@nathang21
Copy link

Thanks for the detailed reply, I more or less followed the same steps. After reloading all of my extensions were copied over as expected, but specifically the setting sync aspect (which this issue is about) is not working as far as I can tell.

@StrangeNoob
Copy link

Thanks for the detailed reply, I more or less followed the same steps. After reloading all of my extensions were copied over as expected, but specifically the setting sync aspect (which this issue is about) is not working as far as I can tell.

Apologies for the misinformation. It didn't work for me either when I performed a clean install by removing all the config files. I had made many changes in code-server, which led to some confusion. However, I believe this extension might help you out.

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

No branches or pull requests