berry: [Bug] running just `yarn` doesn't install

  • I’d be willing to implement a fix

Describe the bug

Running yarn in v2 gives this error:

yarn
Usage Error: Couldn't find a script named "".

$ yarn run <scriptName> ...

Since we can’t run a script named empty string, the previous default of installing makes more sense

To Reproduce

Running just yarn gives this error, regardless of environment.

await packageJsonAndInstall({});
await expect(yarn()).resolves.toBeTruthy();

Environment if relevant (please complete the following information):

  • Yarn version: 2.0.0-rc.26

Additional context

in v1 this installed

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

The reproduction case in your issue seems broken (ie it neither pass nor fail due to throwing an unmanaged exception):

Error: Command failed: /usr/bin/node /github/workspace/scripts/actions/../run-yarn.js

Internal Error: No project found in the initial directory
    at Function.find (/github/workspace/packages/yarnpkg-core/sources/Project.ts:83:13)
    at YarnCommand.find [as execute] (/github/workspace/packages/plugin-essentials/sources/commands/install.ts:202:48)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at YarnCommand.validateAndExecute (/github/workspace/.yarn/cache/clipanion-npm-2.1.5-aef0ebbd62-1.zip/node_modules/clipanion/lib/advanced/Command.js:182:26)
    at Cli.run (/github/workspace/.yarn/cache/clipanion-npm-2.1.5-aef0ebbd62-1.zip/node_modules/clipanion/lib/advanced/Cli.js:85:24)
    at Cli.runExit (/github/workspace/.yarn/cache/clipanion-npm-2.1.5-aef0ebbd62-1.zip/node_modules/clipanion/lib/advanced/Cli.js:94:28)

    at ChildProcess.exithandler (child_process.js:295:12)
    at ChildProcess.emit (events.js:210:5)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)

Remember: any non-Jest exceptions will cause the test to be reported as broken. If you expect something to pass without throwing, you must wrap it into something like await expect(...).resolves.toBeTruthy(). If you instead expect something to throw, you need to wrap it into await expect(...).rejects.toThrow().