KentonWhite / ProjectTemplate

A template utility for R projects that provides a skeletal project.
http://projecttemplate.net
GNU General Public License v3.0
622 stars 159 forks source link

`create.project` fails even on full path when inside an existing project #210

Closed Hugovdberg closed 6 years ago

Hugovdberg commented 7 years ago

I noticed an error with create.project when creating a project specified by a full path, when the working directory is set to a ProjectTemplate project directory. Even though a full path to the new template is specified the .stopifproject error is triggered.

How to reproduce:

Possible solution:

Is this something we want to implement or should we just expect users to always create a project (and subsequently templates in the current implementation) from outside an existing project? (KISS vs. convenience)

KentonWhite commented 6 years ago

I think users should always create a project outside of an existing project. What would be the use case for nested projects?

Hugovdberg commented 6 years ago

Technically the custom templates are new projects, so if you happen to be in a project directory when you try to create a new template you get an error. The error is triggered even if the target directory is outside the current directory. A completely valid call to create.template will therefore fail if called from the wrong working directory.

rsangole commented 6 years ago

A completely valid call to create.template will therefore fail if called from the wrong working directory. A completely valid call to create.template will therefore fail if called from the wrong working directory.

I have faced this a few times. Today, have to go through the manual task of changing working dir first creating a new project someplace else, and then changing working dir back again.

KentonWhite commented 6 years ago

So should this be fixed only form create.template? Or fixing it for create.template also fixes it for create.project?

Hugovdberg commented 6 years ago

I just realised we could probably alter .stopifproject to take a path as an argument, so that it can actually check the parent of the target directory instead of the current. That would fix both create.project and create.template.

rsangole commented 6 years ago

When I was working on #234 , I found that create.project() has two calls to .stopifproject which seem redundant.

https://github.com/KentonWhite/ProjectTemplate/blob/8072e518c3b286aca862104ad36f2ca6bc0cfc62/R/create.project.R#L49-L54

The 1st call works fine and stops correctly. If the 1st call is commented out, the 2nd call does not work correctly and creates a project within a project.

Just an FYI, we should probably look into this.

KentonWhite commented 6 years ago

Closing this now since the issue is moved to #240