Skip to content
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

yarn run fails when options specified #1156

Closed
maffelbaffel opened this issue Oct 17, 2016 · 10 comments
Closed

yarn run fails when options specified #1156

maffelbaffel opened this issue Oct 17, 2016 · 10 comments

Comments

@maffelbaffel
Copy link

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

What is the current behavior?
Yarn run fails when options are specified in the package.json script tag:

If the current behavior is a bug, please provide the steps to reproduce.
Add some script commands to package.json:

"scripts": {
    "build": "webpack --config webpack.prod.config.js --progress --profile --colors -p --display-error-details",
    "build_test": "webpack"
  },

yarn run build fails:

yarn run v0.15.1
$ "webpack --config webpack.prod.config.js --progress --profile --colors -p --display-error-details" 
sh: 1: webpack --config webpack.prod.config.js --progress --profile --colors -p --display-error-details: not found
error Command failed with exit code 127.
info Visit http://yarnpkg.com/en/docs/cli/run for documentation about this command.

yarn run build_test works
npm run build also works

What is the expected behavior?
Yarn should be able to handle options in package.json's script tag.

Please mention your node.js, yarn and operating system version.
node: 4.2.6
yarn: 0.15.1
os: Ubuntu 16.04.1 LTS 4.4.0.38

@Meligy
Copy link

Meligy commented Oct 17, 2016

As a workaround, does adding -- before parameters work?

As in:

"scripts": {
    "build": "webpack -- --config webpack.prod.config.js --progress --profile --colors -p --display-error-details",
    "build_test": "webpack"
  },

@maffelbaffel
Copy link
Author

Nope, same error:

yarn run v0.15.1
$ "webpack -- --config webpack.prod.config.js --progress --profile --colors -p --display-error-details" 
sh: 1: webpack -- --config webpack.prod.config.js --progress --profile --colors -p --display-error-details: not found
error Command failed with exit code 127.
info Visit http://yarnpkg.com/en/docs/cli/run for documentation about this command.

@maffelbaffel
Copy link
Author

Might #1154 be a dublicate ? He uses options too.

@guitarmanvt
Copy link

IMHO, this issue (#1156) is the underlying cause for other bug reports (#875, #1154): yarn is not passing the options through to the shell properly. Fix this issue, and those other issues will also be fixed.

@guitarmanvt
Copy link

Output from yarn run:

$ yarn run build-assets
yarn run v0.15.1
$ "webpack --config webpack.config.js --display-reasons --progress --color" 
sh: 1: webpack --config webpack.config.js --display-reasons --progress --color: not found
error Command failed with exit code 127.
info Visit http://yarnpkg.com/en/docs/cli/run for documentation about this command.

The command executes properly when executed without quotes:

$ webpack --config webpack.config.js --display-reasons --progress --color
 40% 3/6 build modules^C

However, outside of yarn, if I run it quoted the way yarn is trying to do, I get:

$ "webpack --config webpack.config.js --display-reasons --progress --color"
webpack --config webpack.config.js --display-reasons --progress --color: command not found

This is because the actual command is webpack, with arguments; however, yarn is trying to run the whole thing as a single command...which just does not exist. (There is no script named webpack\ --config\ webpack.config.js\ --display-reasons\ --progress\ --color.)

@guitarmanvt
Copy link

It appears that this change introduced the quotes around the entire script: #809

I'm not quite sure what the correct solution is, but as a work-around, I have found this to work:

  1. Put your command with the arguments in a separate script file (say, my-custom-script.sh)
  2. Make sure that script is executable and in the PATH.
  3. Refer to your separate script file in package.json.
  4. Run yarn run your_command as you used to.

@rjmunro
Copy link
Contributor

rjmunro commented Oct 17, 2016

This looks like a dupe of #735.

@guitarmanvt
Copy link

This is not quite a dupe of #735, which is supposedly closed by #809. As the notes earlier mention, the fix in #809 introduces further challenges, which are described in this issue (#1156).

@maffelbaffel
Copy link
Author

Upgrading to v0.16 resolved this issue for me.

@ghost
Copy link

ghost commented Oct 18, 2016

For me on

VirtualBox machine

Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) x86_64 GNU/Linux

the issue still persists

here's the yarn-error.log

Arguments:
  /usr/local/bin/node /usr/share/yarn/bin/yarn.js install

PATH:
  /home/expose/.virtualenvs/userengage/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

Yarn version:
  0.16.0

Node version:
  4.2.0

Platform:
  linux x64

npm manifest:
  {
    "name": "ue-front",
    "version": "0.1.38",
    "description": "Front page for UserEngage project",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
    },
    "repository": {
      "url": "my_repo_goes_here",
      "type": "git"
    },
    "author": "Civilhub Foundation",
    "license": "MIT",
    "dependencies": {
      "less": "^2.7.1",
      "less-plugin-autoprefix": "^1.5.1",
      "less-plugin-clean-css": "^1.5.1"
    },
    "devDependencies": {
      "grunt": "~0.4.1",
      "grunt-contrib-concat": "~0.4.0",
      "grunt-contrib-uglify": "~0.2.4",
      "grunt-contrib-watch": "~0.6.0"
    },
    "directories": {
      "js": "staticfiles/js",
      "js_dev": "src/js"
    }
  }

yarn manifest:
  No manifest

bower manifest:
  No manifest

Lockfile:
  No lockfile

Trace:
  Error: EACCES: permission denied, rmdir '/home/expose/front-master/ue-front/node_modules/bin-version-check/node_modules/.bin'
      at Error (native)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants