Skip to content
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

Safeguards to avoid accidental nuking of project directories #25

Closed
gthb opened this Issue Aug 17, 2011 · 7 comments

Comments

Projects
None yet
3 participants
@gthb
Copy link

gthb commented Aug 17, 2011

Say a user ill-advisedly runs dev_mode('~/foo') where ~/foo is the same directory as given by the default function in ~/.Rpackages, having misunderstood the path parameter … and then runs install('bar').

The user's new bar package will be installed from ~/foo/bar/ — into ~/foo/bar. This will replace his project directory … and, significantly, discard subdirectories such as, say, .git. You see where this is going.

If the user hasn't already run git push before this, then he's just lost a bunch of work. Just, you know, theoretically speaking. (I'm not at all in pain, and if I were, I would not admit it.)

To avoid such accidents:

  • dev_mode could check whether its path parameter is the same as the directory given by the default function in ~/.Rpackages, or the parent of any other directories mapped in that file, and raise an error.
  • install could check whether the directory it's about to overwrite contains a VCS subdirectory like .git, .hg, .svn, etc., and raise an error (or maybe preserve such subdirectories).
@hadley

This comment has been minimized.

Copy link
Member

hadley commented Aug 18, 2011

Did this actually happen to you?

@gthb

This comment has been minimized.

Copy link
Author

gthb commented Aug 18, 2011

Yep. I only lost documentation changes that I hadn't pushed, and I was able to pluck those out from a built PDF, so it wasn't that bad. But it could have been.

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Aug 18, 2011

I think devmode could check that all directories below the path look like packages (i.e. they contain a DESCRIPTION) file, and issue a warning if not.

@gthb

This comment has been minimized.

Copy link
Author

gthb commented Aug 18, 2011

But that would not have caught this; my project directory did contain a DESCRIPTION, so it would still be nuked.

It could check that they all look like built packages (contain a DESCRIPTION with a Built line, or is it Packaged?) — would that work?

@hadley

This comment has been minimized.

Copy link
Member

hadley commented Aug 18, 2011

Oh good point. A better check for a built package is the the R directory contains an .rdx file, or there is Meta directory with Rd.rds

@kohske

This comment has been minimized.

Copy link
Contributor

kohske commented Aug 18, 2011

How about simply install induces an error if source and destination directories are same?
And maybe it is better (1) ask if users really want to install when destination is not empty (unless option force = TRUE) and (2) stop the install when destination includes some VCS info (unless option force = TRUE).

@gthb

This comment has been minimized.

Copy link
Author

gthb commented Aug 18, 2011

That sounds fine to me. The dev_mode check would just let you realize your error sooner, but it's not important if install prevents the actual foot-shootings.

@hadley hadley closed this in f211288 Dec 29, 2011

@lock lock bot locked and limited conversation to collaborators Sep 19, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.