zed icon indicating copy to clipboard operation
zed copied to clipboard

Add basic proxy settings

Open JunkuiZhang opened this issue 1 year ago • 6 comments

Adding proxy keyword to configure proxy while using zed. After setting the proxy, restart Zed to acctually use the proxy.

Example setting:

proxy = "socks5://localhost:10808"
proxy = "http://127.0.0.1:10809"

Release Notes:

  • Added a setting to configure proxy.

JunkuiZhang avatar May 15 '24 11:05 JunkuiZhang

Could we consider passing the proxy into npm too? There seem to be some issues related to that though, but seems to be very helpful to do along the way: https://github.com/zed-industries/zed/pull/11807

SomeoneToIgnore avatar May 15 '24 11:05 SomeoneToIgnore

Could we consider passing the proxy into npm too? There seem to be some issues related to that though, but seems to be very helpful to do along the way: #11807

npm should work through proxy with this PR. Related codes:

let client = Client::production(cx);       <- proxy client created here
cx.update_http_client(client.http_client().clone());
let mut languages =
    LanguageRegistry::new(login_shell_env_loaded, cx.background_executor().clone());
languages.set_language_server_download_dir(paths::LANGUAGES_DIR.clone());
let languages = Arc::new(languages);
let node_runtime = RealNodeRuntime::new(client.http_client());   <- npm used the proxy client here

JunkuiZhang avatar May 15 '24 11:05 JunkuiZhang

I don't known if these pr had done, but in current status, i tested, in windows, npm cannot work as expect with proxy setting.

CharlesChen0823 avatar May 15 '24 12:05 CharlesChen0823

npm only uses the proxy HttpClient we created for downloading npm. The npm install commands do not use the proxy client. So, I write a proxy_settings() function to get the proxy settings to be passed into npm install.

But, the npm install command dose not work. I tried:

  • npm --proxy ... install ... not working
  • command::env("http_proxy", "...") not working
  • create a temp npmrc file, not working

Still investigating.

JunkuiZhang avatar May 15 '24 14:05 JunkuiZhang

npm only uses the proxy HttpClient we created for downloading npm. The npm install commands do not use the proxy client. So, I write a proxy_settings() function to get the proxy settings to be passed into npm install.

But, the npm install command dose not work. I tried:

  • npm --proxy ... install ... not working
  • command::env("http_proxy", "...") not working
  • create a temp npmrc file, not working

Still investigating.

Yes, I have done a lot of tests like this. And I even tried to upgrade Node to use v20, but it is still not working.

huacnlee avatar May 15 '24 14:05 huacnlee

For the npm part I have no idea why npm install not working through proxy. Since I know nothing about npm, I think it would be better to let @huacnlee to deal with this issue. npm or others that need the proxy infomation, can call <dyn HttpClient>::proxy_settings() to get that info.

For this PR, I think it is ready for review.

JunkuiZhang avatar May 15 '24 15:05 JunkuiZhang

Thanks to @huacnlee 's efforts, now npm install can run through a proxy settings.

JunkuiZhang avatar May 16 '24 07:05 JunkuiZhang

@huacnlee just to confirm — does npm work for you?

SomeoneToIgnore avatar May 16 '24 15:05 SomeoneToIgnore

I am try again.

huacnlee avatar May 16 '24 15:05 huacnlee

It's working well.

https://github.com/zed-industries/zed/assets/5518/a1281fc8-5456-477d-81d2-286aed4ff7ce

huacnlee avatar May 16 '24 15:05 huacnlee

add "proxy" : "socks5://localhost:10808" or "proxy" : "http://127.0.0.1:10809" in .configs/zed/settings.json file, then press cmd + q to quit zed app, restart zed app, the proxy will work automaticly.

ZTfer avatar Jul 23 '24 07:07 ZTfer

This feature helps me a lot, but I can't find it in the document.

reactioncs avatar Sep 13 '24 05:09 reactioncs