pivotal / LicenseFinder

Find licenses for your project's dependencies.
MIT License
1.73k stars 340 forks source link

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

Open nickbreen opened 2 years ago

nickbreen commented 2 years ago

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.

cf-gitbot commented 2 years ago

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.

nickbreen commented 2 years ago

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 commented 2 years ago

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.

xtreme-shane-lattanzio commented 2 years ago

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 :)