-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[Feature] Removing .yarn folder should yield an understandable error #1733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This isn't recommended with Yarn 2. The node-modules linker is much more stable, which means that bugs that require deleting the
We've made it clear that the
Yep, that's definitely a won't fix. Even if we found a way to somehow magically regenerate the Yarn binary, we'd have absolutely no way to regenerate plugins (which also yield a So, in the end, the only actionable part I see is improving the error message. |
One problem with improving the error message is that it requires to hotfix Yarn 1, which is a huge pain - the tests don't even pass there anymore for whatever flaky reason 😞 So it would be "nice to have", but I'd postpone that until after we have pmm, which should shake things a bit in this regard. |
Ok I just found myself in this same situation. Maybe we can guide people into the right solutions at the "problem" cases. Like @scarlac has stated, clearing the build artifacts in other node apps can usually be rebuilt without worrying too much. In this case we have a In the documentation there is Zero-Installs. This suggests we will be able to commit our dependencies and not have to install them in the build steps. Going from this idea the goal was to use yarn2 to keep my dependencies in check. We also get a Now in my particular situation. I am maybe trying to do too many new things at the same time, but I got to a point where I couldn't figure out how to solve it. Could be a project specific issue but this is where I couldn't figure out how to solve it.
Attempts at using Specifically this line made me think that there was some cache issue. Note that I am changing packages around almost constantly. I am not sure how I can resolve this error.
So to "fix" whatever weird state my package was in, and to rebuild from my package.json/yarn.lock files, I thought I would clear the
My attempts at solving this was to re-install yarn. And then I came to this repo to see if it was something fixable. Maybe it's misleading to have .yarn have "cache" and required files, when other files outside of .yarn are also required. Having to resort to rm is not ideal but if I am being blocked and time is limited, I will just do it. I can go back to git if required. In this case the problems leading up to and after the error occured did not indicate what actually was going on to me. I still don't know what the original error means or how to solve it. Of course documentation may highlight solutions (maybe they exist already). I spent around 10 hours trying to upgrade to yarn v2 to support Zero-Install, with a number of packages not working properly, but eventually I got to a broken yarn version with no way to resolve. The time isn't an issue for me but I did invest some time trying to figure it out and still got to a dead-end. |
The issue you have with webpack is this issue: webpack/webpack-dev-server#2424, you're using a incompatible version of webpack with webpack-dev-server |
As @rockerBOO points out, although for separate reasons, having a
Instead Yarn2 crashes. It makes Yarn2 harder to use than it has to be. I'd really just like us to all use tools that we don't have to read the manual to use. If Yarn Classic is not going away couldn't we update it to handle this situation, given it already reads |
I've been running into the |
Maybe it would be nice for the yarn user with an implementation where everything can be recovered from a simple package.json, that yarn can process and use to rebuild .yarn/ with bin, cache, yarn.yml, yarn.lock, pnp, etc... Maybe this could help ease the cognitive switch between npm and yarn, and thus reduce the fear of trying a switch to the better solution at any given time. As a yarn user my biggest fear is that .yarn becomes like Meteor was an maybe still is to some extent, limiting and restricting users from the general javascript ecosystem, and getting a feel of being locked in, and constrained with a rigid and counterproductive less free and compatible system. |
Just to be clear: the Apart from the artifacts referenced in your very configuration (release, plugins), everything else in this folder can be safely removed, and Yarn will just regenerate it on subsequent installs. |
Finally, note that if you check-in the binaries as we suggest, the semantic way to "reset" your
|
@arcanis Provided that you use git and that you have it set up in git, which I did not have as I was trying to migrate. Yarn2 is already a hard sell given the defaults. I'd just like users to be able to not have to understand the internals to recover from a fairly easily encountered situation. I'll leave it at that. If you feel it's a wontfix, feel free to mark it as such. |
I'm experiencing the same problem as @FallingSnow: With |
@lehni Unrelated to the topic of this issue, please open a seperate issue with a reproduction |
This comment has been minimized.
This comment has been minimized.
@cdestiawan I assume |
I'll close this as there is nothing we can do about it from Yarn V2's side. Until it has been released with Node (if it gets accepted) you can manually enable https://github.com/nodejs/corepack to handle this. npm uninstall yarn -g
npm install corepack -g Add this to your
|
This comment was marked as off-topic.
This comment was marked as off-topic.
I had to jump over to another directory, run this command, then copy the new .yarn into my existing project I hit this same issue, having not wanted to commit .yarn to my repo, and then removing it thinking it was similar to removing node_modules just as original issue described. |
Not sure why the maintainers in this thread are acting like it's some impossibility to rebuild the folder, they have to build it in the first place, don't they? Instead of running |
Echoing here, but same. I understand the decision here but is not the path of least surprise for me. So used to removing node_modules due to npm instability and didn't think that clearning the .yarn folder would cause yarn to be unusable. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the user story
Removing
node_modules
folder is NodeJS equivalent of "have you tried restarting your pc"?I daily see this recommended in discussions, on forums, in offices environments.
So if a user tries to do the equivalent of:
The natural assumption would be:
Which fully screws up their entire project, including yarn, putting them into an unusable state:
The user now has normal way to recover, and they have to resort to git or backups. This is a terrible experience, and it's often not an issue beyond configuration to remove dot-folders with other tools. With Yarn 2 the story is now that it's fatal. There is no clear yarn command that leads to recovery (
yarn doctor
will cause the same error).Describe the solution you'd like
The issue is that the binary is shipped with the configuration folder. Given this design decision, the
yarn
command should either:Currently, we are bleeding the out onto the screen, showing internal javascript.
Examples of error message that may be helpful:
Yarn binary not found (.yarn/releases/yarn-2.1.1.cjs). Did you remove it?
Yarn2 needs the .yarn folder to function. Please run XXXX to generate it from scratch
Local yarn binary not found. .yarn/ folder may not be removed like node_modules/. Run XXXX to generate it
Describe the drawbacks of your solution
Increases code complexity slightly.
Describe alternatives you've considered
Automatically re-generating the
.yarn
folder from scratch with the latest binary would be ideal but I am not sure you guys agree (as I imagine the decision to put the binary next to the cache was an elaborate informed choice and removal of .yarn was considered to be 'wontfix' regardless).The text was updated successfully, but these errors were encountered: