-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
windows: Fix node_runtime to support proxy by keep system env #11807
Conversation
After update, now install NPM is works now. install-with-proxx1.mp4 |
546eaec
to
2292804
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context of the clearing change was to isolate the npm/node running entirely from side effects, as at that time we've had issue with node.
But then, #6742 came and fixed all those issues, but some of the code remained since (including dummy configs settings just below).
By removing the env_clear
call, we allow arbitrary env variables that were inherited by Zed process, to be used in the node process too, potentially creating more issues due to various side effects out of odd env set-ups of people.
Also see #11758 that indicates that many env vars might be cached in an incorrect state before rebooting.
So, I'm not entirely sure that this is the right way to proceed with the proxy fix.
Could we instead forward the proxy-related env vars only somehow without the env_clear?
I would also try a newer npm version (or even pnpm), because Zed seems to use an outdated one: if that works with either of the proxy settings + a tiny Rust wrapper around with the env_clear, we might want to switch to that version first, and then use the proxy settings? Another thing worth investigating is whether the configs below ( |
From a technical point of view, setting env directly and retaining env should be the same, because all it needs is the value of http_proxy. I have tried to set the env variables of http_proxy with the env function, and also tried to restore several possible proxy environment variables (all_proxy, http_proxy, https_proxy). Strangely, this never works. 😂 |
Yes, this is very odd and sad to see, but npm is somewhat notorious for treating its argument oddly.
but would love to avoid dragging in entire users' envs into npm. |
Sorry, for the rest of this week I'm relatively occupied and cannot dive into that, but I think we need to find a way of passing the proxy only, without any extra env vars. If @mikayla-maki thinks it's better to move on with Windows and enable LSP servers for it now, let's continue though — it seems quite important to be held too. |
Related: #11852 Passing those into npm here seems to be the way I'd expected it to be implemented. |
This PR can be put aside for now. I'll see if there are any other ideas. In addition, the method of #11852 may have some different solutions, but I don't know if I will encounter the above problems when executing npm in the end. |
Seems that I've overlooked that it's already supported in that PR: #11852 (comment) Let's keep on testing and discussing it there. |
Ref Rust issue rust-lang/rust#114737 |
Today I read the issue of rust-lang/rust#114737 and do a test. In Rust For example, in Go: https://pkg.go.dev/os/exec#Cmd And I do a quick testing by add |
Great! And I found that when proxy is set to I could push the changes to #11852 , but since it's your efforts that makes this happen, I'd like add a |
You can just cherry-pick this commit |
Release Notes:
NPM is installed in some regions (such as mainland China) and accessing npmjs.org must go through a proxy.
However, when NPM install was executed in node_runtime before, the
env_clear
action was performed. This will lose thehttp_proxy
environment variable set by the operating system.I have done a lot of testing on Windows in the past few days:
http_proxy
,https_proxy
envs directly by useenvs
method for command.--proxy
argument.But it still not work, the localhost proxy server
127.0.1
can't connect.I haven't found out why this happens on Windows. I have executed the same command on CMD, and it all works.
Today, I have tried to remove the
env_clear
, then the proxy works. I don't why, why I setenvs
not work (I am sure the env and value is correct), but it actually works now.So, I give up, to just removed
env_clear
let it just work.The Node runtime already uses absolute paths and additionally sets PATH, cache, --prefix, so there seems to be no need to clear the system ENVs?