berry: [Bug] Not running simple yarn install
- I’d be willing to implement a fix
Describe the bug
A clear and concise description of what the bug is.
I’ve tried to run yarn install
here (https://github.com/sibelius/yarn-workspaces-slow) and got the following error:
I did this
yarn policies set-version v2
yarn install
Usage Error: The project in /app/package.json doesn't seem to have been installed - running an install there might help
the repo was like this:
/app/yarn-workspaces-slow
To Reproduce
The minimal information needed to reproduce your issue (ideally a package.json with a single dep). Note that bugs without minimal reproductions might be closed.
IMPORTANT: We strongly prefer reproductions that use Sherlock. Please check our documentation for more information: https://next.yarnpkg.com/advanced/sherlock
run yarn berry
here https://github.com/sibelius/yarn-workspaces-slow
Screenshots
If applicable, add screenshots to help explain your problem.
Environment if relevant (please complete the following information):
- OS: [e.g. OSX, Linux, Windows, …] mac
- Node version [e.g. 8.15.0, 10.15.1, …] 12.13.0
- Yarn version [e.g. 2.0.0-rc1, …] 2.0.0-rc.19
Additional context
Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 23 (6 by maintainers)
FWIW the quickest fix if you can’t find the offending yarn.lock file is to simply
touch yarn.lock
from the folder you’re trying to run your other yarn commands from.Do you by any chance have a
yarn.lock
in/app
? The error message doesn’t reference the cloned project, which leads me to believe that Yarn thinks/app
is the root of your app. This should only happen if you have a lockfile in an ancestor folder.got working here
there are a
yarn.lock
there on home dir as wellFWIW, I could reproduce. I had unused yarn.lock files in two ancestor files. Deleting them fixed it for me.
Can we reopen this in order to improve the error or the behavior of yarn?
Maybe the error message could be clearer. Something like:
Or perhaps yarn should not regard stray
yarn.lock
files in ancestor directories. Is this a valid use case with yarn? Should yarn stop at the first package.json it finds when searching upward in the directory tree?In my case, I ran yarn from a directory with a
package.json
, but my home directory had ayarn.lock
but nopackage.json
. I’m not familiar with yarn 2, and I admit I didn’t fully read the file path in the error message. I was running a storybook setup command (npx sb@next repro
) as you can see in the above linked issue. So this caused confusion for me.After
yarn set version latest
the error was more detailed. I needed to remove~/package.json
.I encountered this error also with yarn3 and found some
yarn.lock
files andpackage.json
files outside of the projectdir, but removing them didn’t resolve the issueI can confirm, I had the same issue and removing
yarn.lock
andpackage.json
files from root directory solved the issue for me on fedora linux. yarn version3.1.1
I have a file named
package.json
file in a distant parent directory that is completely unrelated to the project I am currently working on. It is frustrating beyond relief that I have to rename it just so that yarn thinks$(pwd)/package.json
is the root of a workspace; and I cannot find any means to tell it explicitly so.eslint
has aroot: true
option, which tells it not to scan up the directory tree any further. Doesyarn
have a similar.yarnrc.yml
option?Sorry if I’m making you repeat yourself but did you also remove a yarn.lock from the home dir?
/Users/sibelius/yarn.lock
Yarn 2 supports nested workspaces which may relate to the change in behaviour. arcanis would know more.
@willgriffiths Just a heads up, I had a
package.json
randomly in my User directory that was also causing me the same issue in~/dev/projectdir
.Thanks for creating an issue @sibelius. I added a feature request based on your feedback.
Let us know if you hit any other blockers with yarn 2. 😃