-
Notifications
You must be signed in to change notification settings - Fork 27
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
devtools::check deletes all files and folders from home directory #120
Comments
This seems to happen when you have a folder called |
Maybe this is a bug in base R, because if you But really, naming a file or directory E.g. this is on Linux, as user 'root', so the whole ❗ DO NOT RUN THIS CODE, BECAUSE YOUR HOME DIRECTORY WILL BE DELETED. ❗ > setwd("~")
> cat("foo\n", file = "~/foo")
> dir.create("a")
> dir.create("a/~")
> dir()
[1] "a" "foo"
> dir("a")
[1] "~"
> setwd("a") Now this will remove the ❗ DO NOT RUN THIS CODE, BECAUSE YOUR HOME DIRECTORY WILL BE DELETED. ❗ > unlink("~", recursive = TRUE)
> dir()
character(0)
> getwd()
NULL
> setwd("~")
Error in setwd("~") : cannot change working directory
> q("no")
|
Maybe we could do a quick check for files/directories named With a file or directory called |
I didn't call a folder |
Right. Considering how many times we use |
We had the same exact issue two days ago. We were lucky to be able to recover all the files, but I think that current behaviour is a disaster waiting to happen. We do not know exactly how/why the "spurious" BTW: @jimhester It took us a while to understand what was happening. I can understand the motivation, but I think that if this issue was not moved from |
I am sure that you are welcome to report it at https://bugs.r-project.org/bugzilla/ |
@gaborcsardi I hope I was not harsh in my previous. It was not my intention.
Thanks for the suggestion, will do that. A fix in base R is for sure the best solution. In the meantime, however, I think that your idea/proposal to:
would have its clear merits to avoid accidents. I understand that it would involve changes in several packages, so it is not something you/I could implement on our own, but it could be worth discussing it. What do you think? HTH! Lorenzo |
I can imagine that this is a major pain. It would be also great to know which R function creates these files. It is probably a function that does not call As for the workaround, we can start with a dir(recursive = TRUE, include.dirs = TRUE, pattern = "~") and then refuses to continue if the result in non-empty. |
Hi @gaborcsardi ,
This seems to be a good workaround to avoid this specific dangerous problem. |
I am not sure what you mean, callr has nothing to do with this, and those |
May I ask a clarification here, if possible, without trying to wipe out my home folder? ❗ DO NOT CODE BELOW, BECAUSE YOUR HOME DIRECTORY MAY BE DELETED ❗ Let's assume that I created a folder named let's say |
I mean that, using Maybe I should not ask this in a rcmdcheck issue, but I did it since the topic is the same and the two packages are linked. However, I did not deepen the code and so maybe this is not practcable; this was only an idea to avoid commands like |
rcmdcheck does not create a list of files, it calls The expansion in the |
@ranghetti maybe you meant "devtools"? I suppose that it is devtools::check(), that sets the WD to the packages root ~/pkg (as suggested by @mr-francois). |
Can you pls tell us your platform and R version? |
I may be out of my depth here, so I'll let @ranghetti comment on more "technical" issues. Sorry if I introduced some confusion. A word, regarding this:
Do not know if this helps, but what I can contribute is that we noticed deletion was triggered by calls to |
OK, this is a bug in
|
It is fixed in R-devel: wch/r-source@1d4f7aa This said, I think |
It seems |
Ok, this is comforting; thank you for signaling it. |
@gaborcsardi Many thanks for looking into this. Glad you found the culprit.
That would be nice. I recon we did a mistake in creating that folder, but it could occur to others between now and R4.0 release. |
@mr-francois @ranghetti Are the packages you were checking public? They would help me find the package/function/tool that created the |
Emailed R-devel about this: https://www.mail-archive.com/r-devel@r-project.org/msg41749.html |
I checked my package "sen2r", and it does not seem to contain functions which can create "~" directory. The presence of that directory was probably due to a manual accident (occurred having the working directory set on the root package path). |
Just one clarification about this sentence:
In my case, the home directory was deleted even in presence of an empty "~" folder. |
I think one time |
Would it be possible to add a check to |
The root cause of this issue was fixed in R 4.0.0:
(https://cran.r-project.org/doc/manuals/r-release/NEWS.html) I can still add a check for the earlier R versions. |
I encountered this problem twice. When i run the check command inside RStudio all my files and folders get deleted.
The text was updated successfully, but these errors were encountered: