LicenseFinder icon indicating copy to clipboard operation
LicenseFinder copied to clipboard

Yarn2 fails silently and does not find any dependencies/licenses in a monorepo without workspaces defined

Open nickbreen opened this issue 3 years ago • 4 comments

Command line: report --prepare --recursive --enabled-package-managers yarn

In our monorepo we have a number of independent yarn projects each with their own package.json and yarn.lock file, we have no root package.json/yarn.lock and we're not using workspaces.

License finder logs:

LicenseFinder::Yarn: is active for /foo LicenseFinder::Yarn: is active for /bar LicenseFinder::Yarn: is active for /baz

But finds no dependencies or licenses!

Inspection of yarn.rb shows the prepare command executed is:

 yarn plugin import workspace-tools && yarn workspaces focus --all --production && yarn install

When run manually that command fails on the first command yarn plugin import with:

YN0001: UsageError: No project found in /buck-all

Due to there being no root-project.

Problem 1 is that this error is silent. Even with --debug enabled there is no indication that the command has failed, the report is 'successfully' generated with zero dependencies and the tool exits with a zero exit code indicating success.

Problem 2 is that license finder is capable of finding the yarn projects but then fails to execute against the found project.

nickbreen avatar Jan 18 '22 03:01 nickbreen

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

cf-gitbot avatar Jan 18 '22 03:01 cf-gitbot

A work-around is to use project-roots --recursive and use the output to generate the command line for report --prepare --aggregate-paths ... which treats each path as a discrete project.

nickbreen avatar Jan 18 '22 05:01 nickbreen

Also even if the 'production' prefix for the yarn install command is empty the yarn install command will fail also due to there being no root-project/workspace.

nickbreen avatar Jan 18 '22 05:01 nickbreen

Hey @nickbreen ! Thanks for raising this. There seems to be two issues here. One is the prepare command not working when there is no root project. And the other is about silent failing when you would prefer it to actually error out. Do you have proposed solutions for this? The failing out is easy enough but Im wondering if you paths work around for the other issue is good enough? We welcome any PRs if you have an idea for this :)

xtreme-shane-lattanzio avatar Feb 22 '22 15:02 xtreme-shane-lattanzio