Add basic proxy settings
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.
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
Could we consider passing the proxy into
npmtoo? 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
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.
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
npmrcfile, not working
Still investigating.
npmonly uses the proxyHttpClientwe created for downloadingnpm. Thenpm installcommands do not use the proxy client. So, I write aproxy_settings()function to get the proxy settings to be passed intonpm install.But, the
npm installcommand dose not work. I tried:
npm --proxy ... install ...not workingcommand::env("http_proxy", "...")not working- create a temp
npmrcfile, not workingStill 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.
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.
Thanks to @huacnlee 's efforts, now npm install can run through a proxy settings.
@huacnlee just to confirm — does npm work for you?
I am try again.
It's working well.
https://github.com/zed-industries/zed/assets/5518/a1281fc8-5456-477d-81d2-286aed4ff7ce
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.
This feature helps me a lot, but I can't find it in the document.