Skip to content

Commit 3299509

Browse files
doitsbestander
authored andcommitted
Make yarn run only add global path to env if it is not present already (#3637)
If the global path is present already, prepending it should not be necessary and might change the order of path entries. This can break applications that rely on the correct order of path entries, like rbenv. fixes #3636
1 parent a4e02f8 commit 3299509

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/util/execute-lifecycle-script.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,12 @@ export async function executeLifecycleScript(
138138
path.join(path.dirname(process.execPath), '..', 'lib', 'node_modules', 'npm', 'bin', 'node-gyp-bin'),
139139
);
140140

141-
// Add global bin folder, as some packages depend on a globally-installed
142-
// version of node-gyp.
143-
pathParts.unshift(getGlobalBinFolder(config, {}));
141+
// Add global bin folder if it is not present already, as some packages depend
142+
// on a globally-installed version of node-gyp.
143+
const globalBin = getGlobalBinFolder(config, {});
144+
if (!pathParts.includes(globalBin)) {
145+
pathParts.unshift(globalBin);
146+
}
144147

145148
// add .bin folders to PATH
146149
for (const registry of Object.keys(registries)) {

0 commit comments

Comments
 (0)