[build-utils][cli][go][node][ruby][static-build] Explicitly set PATH when copying env vars (#8532)

On Windows 10 and 11 machines, environment variables are not case sensitive. The system PATH is actually defined as `process.env.Path`, however Node.js kindly handles the case sensitivity and will automatically return the system path when specifying `process.env.PATH`.

When we clone the environment variables via `{ ...process.env }`, we lose the automatic resolving of `Path` to `PATH`. To fix this, we need to explicitly copy the `PATH`.

#### Tests

- [x] The code changed/added as part of this PR has been covered with tests
- [x] All tests pass locally with `yarn test-unit`

#### Code Review

- [ ] This PR has a concise title and thorough description useful to a reviewer
- [ ] Issue from task tracker has a link to this PR
This commit is contained in:
Chris Barber
2022-09-14 15:29:52 -05:00
committed by GitHub
parent 6498fd1aab
commit 7ddebb099d
9 changed files with 184 additions and 32 deletions

View File

@@ -31,6 +31,7 @@ import {
} from '@vercel/routing-utils';
import {
Builder,
cloneEnv,
Env,
StartDevServerResult,
FileFsRef,
@@ -2222,18 +2223,22 @@ export default class DevServer {
const port = await getPort();
const env: Env = {
// Because of child process 'pipe' below, isTTY will be false.
// Most frameworks use `chalk`/`supports-color` so we enable it anyway.
FORCE_COLOR: process.stdout.isTTY ? '1' : '0',
// Prevent framework dev servers from automatically opening a web
// browser window, since it will not be the port that `vc dev`
// is listening on and thus will be missing Vercel features.
BROWSER: 'none',
...process.env,
...this.envConfigs.allEnv,
PORT: `${port}`,
};
const env: Env = cloneEnv(
{
// Because of child process 'pipe' below, isTTY will be false.
// Most frameworks use `chalk`/`supports-color` so we enable it anyway.
FORCE_COLOR: process.stdout.isTTY ? '1' : '0',
// Prevent framework dev servers from automatically opening a web
// browser window, since it will not be the port that `vc dev`
// is listening on and thus will be missing Vercel features.
BROWSER: 'none',
},
process.env,
this.envConfigs.allEnv,
{
PORT: `${port}`,
}
);
// This is necesary so that the dev command in the Project
// will work cross-platform (especially Windows).