-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
"yarn add --module-folder . " deleted ALL of my code (including .git directory) #7074
Comments
I'm sorry for your troubles - unfortunately it's kinda expected. The In this case the only thing we could do would be to tell you that you probably made a mistake (a bit like Do you have a suggestion for a better documentation somewhere that would make this behavior less unexpected? (As a side note I personally find a bit demoralizing to see you post on HN before even trying to understand what happened. We all need karma in our life but come on ...) |
Giving a second look at your post it appears to me that you were running the command within a subdirectory When running The fix would be to tweak our CLI to resolve some command line arguments relative to the current pwd rather than the fixed one. That would be here: https://github.com/yarnpkg/yarn/blob/master/src/cli/index.js#L501-L532 |
Thanks for the swift response @arcanis The reason for using It might be worth mentioning - I knew that It's also extremely lucky I didn't run the command again ... because I have a package.json sitting around in my home folder. Which, on second invocation would have been the new "project root" after the first package.json gets deleted... |
I'm same problem in a different context. I want to install in same node_modules folder some dependencies which are flatten ( web-components ). I did that with modules-folder in a sub folder. and now with last version of yarn, same script replace all previously installed modules. |
At the risk of repeating myself... there is a disaster waiting to happen here.
If you do this, yarn will delete your entire
|
It got implemented in #4246, in august 2017, and shipped starting with the 1.0. No regression 🙂
I agree - I'll eventually get to fix it, but I'm working on other tasks and if someone is willing to put up a PR to fix this one it would help. A good enough way is to simply wrap all the folder options to do something like |
@arcanis Yes, the |
I'm pretty sure this is where it broke: https://github.com/yarnpkg/yarn/pull/6275/files It looks like "modulesFolder" gets added to registryFolders, which then has its extraneous files/folders deleted. |
I'm not even sure of a nice way to prevent this from happening. It has always been part of yarn's behavior that we delete extraneous files in The behavior of Going to tag its as a high priority bug to at least get relative path fixed. |
Perhaps a behaviour that could mostly fix this issue is that using |
Same here, I lost all my files right now. It's really sad, because the doc says
There's nothing warning about that will delete all files in the new location. :( |
I’d like to work on this. I’ve gotten as far as no longer being able to reproduce this specific issue in my branch. |
…pkg#7074) * Prevents potentially surprising behavior and data loss * Includes integration test verifying that user-reported data loss scenario does not occur
Opened a PR for this, it changes the resolution of several 'folder' options, including --modules-folder. It's no longer possible to reproduce the issue as reported with this change. |
… (#7607) * Prevents potentially surprising behavior and data loss * Includes integration test verifying that user-reported data loss scenario does not occur
… (#7607) * Prevents potentially surprising behavior and data loss * Includes integration test verifying that user-reported data loss scenario does not occur
Closing - this fix has been released as part of the 1.19.1. Thanks @mbpreble 🙂 |
…pkg#7074) (yarnpkg#7607) * Prevents potentially surprising behavior and data loss * Includes integration test verifying that user-reported data loss scenario does not occur
…pkg#7074) (yarnpkg#7607) * Prevents potentially surprising behavior and data loss * Includes integration test verifying that user-reported data loss scenario does not occur
Do you want to request a feature or report a bug?
A bug. A very serious bug. Like, "I'm in serious trouble" serious.
What is the current behavior?
You make a directory in your project folder called
lib
You run
cd lib; yarn add some-module --modules-folder .
because you want to install a specific dependency outside of node_modulesYou get an error telling you a file is missing ...
Because yarn deleted all of the files in your project folder (apart from lib and yarn-error.log)
You slowly back away from the computer. This is not your day.
If the current behavior is a bug, please provide the steps to reproduce.
See above. Although I wouldn't recommend it.
What is the expected behavior?
That yarn doesn't delete all of the files in my project.
Please mention your node.js, yarn and operating system version.
Yarn: 1.13.0
Node: v10.15.0
OS: macOS 10.14.3
The text was updated successfully, but these errors were encountered: