yarnpkg/yarn

CLI switch "--scripts-prepend-node-path" doesn't work

开放

#5,776 创建于 2018年5月3日

 (7 条评论) (0 个反应) (1 位负责人)JavaScript (2,731 个派生)batch import
cat-buggood first issuehelp wanted

仓库指标

星标
 (41,514 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Do you want to request a feature or report a bug? Bug

What is the current behavior? Using the --scripts-prepend-node-path switch seems not to do anything.

$ /myNodePath/bin/node myYarnPath/bin/yarn.js run --scripts-prepend-node-path env

Running this outputs an "env" without myNodePath in the "PATH".

{
  "NODE": "/myNodePath/bin/node",
  ...
  "PATH": "/myProject/node_modules/.bin:/Users/jdevine/.config/yarn/link/node_modules/.bin:/myProject/node_modules/.bin:/myProject/node_modules/.bin:/Users/jdevine/.config/yarn/link/node_modules/.bin:/myProject/node_modules/.bin:/myNodePath/libexec/lib/node_modules/npm/bin/node-gyp-bin:/myNodePath/lib/node_modules/npm/bin/node-gyp-bin:/myNodePath/bin/node_modules/npm/bin/node-gyp-bin:/usr/local/sbin:/usr/local/bin:/Users/jdevine/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
  ...

We would expect that the node path (/myNodePath/bin) be the first thing in the PATH in the env. In fact, if I comment out the config check in yarn:

//    if (config.scriptsPrependNodePath) {
      pathParts.unshift(path.join(path.dirname(process.execPath)));
//    }

If I make that change, then see what I expect - the path includes /myNodePath/bin, and my install scripts, and "yarn run" scripts work as expected.

{
  "NODE": "/myNodePath/bin/node",
  ...
  "PATH": "/myNodePath/bin/:/myProject/node_modules/.bin:/Users/jdevine/.config/yarn/link/node_modules/.bin:/myProject/node_modules/.bin:/myProject/node_modules/.bin:/Users/jdevine/.config/yarn/link/node_modules/.bin:/myProject/node_modules/.bin:/myNodePath/libexec/lib/node_modules/npm/bin/node-gyp-bin:/myNodePath/lib/node_modules/npm/bin/node-gyp-bin:/myNodePath/bin/node_modules/npm/bin/node-gyp-bin:/usr/local/sbin:/usr/local/bin:/Users/jdevine/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin",
  ...

If the current behavior is a bug, please provide the steps to reproduce. This reproduces every time.

What is the expected behavior? As above. We expect that using --scripts-prepend-node-path should prepend the node path to the PATH in the environment when scripts are executed at install time and run time.

Please mention your node.js, yarn and operating system version. node v8.10.0 yarn v1.6.0

贡献者指南