Closed wclr closed 3 years ago
I seem to remember it's not actually that simple, and it might be either Path
or PATH
, depending on your system setup.
lookupEnv
in Node.Process
just looks up the key in node process.env
, unless that normalises case we will miss the existing variable Path
PATH
on the existing env, which would lead to both Path
and PATH
in the object, and who knows which is used.Seems like updating the existing variable (2) is the more correct thing to do. I'm concerned that lookupEnv
is the wrong thing in general
I seem to remember it's not actually that simple, and it might be either Path or PATH, depending on your system setup.
Yes, I've already got it, I'm often too quick regarding details.
I'm concerned that lookupEnv is the wrong thing in general
Why is that?
If lookupEnv
is not performing a case-insensitive lookup, it is not behaving as expected on Windows, where I think the native single-variable lookup facility is case-insensitive, but node returns the whole env. Maybe it's arguable, certainly could be worth raising on node-process but in the meantime can easily have a case-insensitive version here.
lookupEnv
just works with Process.env
FO object. And seems env variables are case sensitive on windows as well, I actually can add additional PATH so they are independent, and Path seems preferred by the process. Seems it is better to update both PATH and Path (that exist in the env).
I will make a PR for this. Interesting that you are right that there is something strange with this process.env
object on windows.
FO.lookup checks if prop in obj
and for process.env both is true for "PATH" and "Path" props, and they are both pointing to the property, though Object.keys
returns only "Path".
But getEnv
uses copyObject
that uses Object.assign
, and "PATH" in Object.assign({}, process.env)
happens to be false
, but "Path" is there. So just need to check if copied env contains PATH
use it, otherwise use Path
.
Problem:
If
addNpmPath
is settrue
if it is globally availablepurs
of another version then locally project's installed, build command is using global not local one, if to addnpx
tobuildCommand
it works ok.Cause:
LS provides updated PATH env var when running
buildCommand
, but on Windows 10 it should insert notPATH
butPath
, here it is: https://stackoverflow.com/questions/48686267/windows-10-system-environment-variables-path-vs-pathUPD: Though not sure if it is the standard thing about
Path
orPATH
, but my system happens to havePath
notPATH
in envs. Don't remember I changed it.@nwolverson Need to decide, how to handle this problem correctly.
1) Set both PATH and Path 2) Update only existing
PATH
orPath