berry: [Bug] Can't switch back to Yarn v1 after trying out Yarn v2
- I’d be willing to implement a fix
 
Describe the bug
I wanted to try out Yarn v2, so I did yarn set version 2. This worked. But now I can’t switch back to v1:
> yarn set version 1
^[➤ YN0000: Selecting the highest release amongst 1.22.0 and 18 others
➤ YN0000: Downloading https://github.com/yarnpkg/yarn/releases/download/v1.22.0/yarn-1.22.0.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-1.22.0.js
➤ YN0000: Done in 2.35s
> yarn -v
2.0.0-rc.29
To Reproduce
- Start with a regular Yarn 1 installation on macOS, installed via 
brew. - Run 
yarn set version 2 
- Running 
yarn -vnow prints2.0.0-rc.29. 
- Run 
yarn set version 1 
- The output makes it look like this worked, but it didn’t – 
yarn -vstill prints2.0.0-rc.29. 
Environment if relevant (please complete the following information):
- OS: macOS
 - Node version: v12.13.0
 - Yarn version: 2.0.0-rc.29
 
Additional context
Sorry if I’m missing something obvious - I don’t know much about Berry/Yarn 2, I just wanted to try it out, and now I can’t get back to Yarn 1.
About this issue
- Original URL
 - State: closed
 - Created 4 years ago
 - Reactions: 16
 - Comments: 17 (4 by maintainers)
 
I “fixed” it my going into my users root directory and executing
yarn set version ^1. Now it’s globally back to v1i had a default in my root, deleting it did the trick
on mac
worked for me
If you enabled yarn via
corepack enablefrom above node v16.14.0, just runcorepack disable, then install it the old way likenpm i -g yarn@1.22.1.I’m not at my computer at the moment, but I’m pretty sure you’ll find a
.yarndirectory in your home directory, if you delete that you should be able to install v1 again. (I had this problem when I first started using v2 as well)If not work Just put the --force parameter in install
A detail is that
.yarnrc.ymlcan live in any ancestor folder. It seems like it’s generated where the command is run. So, if your project is in~/Projects/MyApp, it can be in~/.ProjectsThere isn’t a bug per se -
yarn set versionupdates the.yarnrc.ymlfile located in the current project, that’s the intended behaviour. The problem is that you have ayarnPatheven above, but that isn’t supposed to happen - our docs never mention to runyarn set versionat the root or anywhere else than your project. It’s technically a user bug that you ended up in that situation (although it’s a UX bug that you can get into this situation).That said, I know it’s a common problem, and we’ll likely try to address that somehow in a future release - perhaps by forbidding to run Yarn in the home directory, to avoid accidental commands. But it comes with side effects (I imagine some Docker setup are fine with running Yarn from the home directory), so it hasn’t been a priority so far.
Additionally, with the 4.0 we’re making Corepack the preferred way to install Yarn, so
yarnPathshould be even less common.doesn’t work for me, I need to remove
.yarnrc.ymlthen runningyarnworks right away.I’m not sure there’s anything actionable on our side at the moment, so I’m going to close this issue.