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

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

Closed
Hugovdberg opened this issue Oct 3, 2017 · 7 comments · Fixed by #256
Closed

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

Hugovdberg opened this issue Oct 3, 2017 · 7 comments · Fixed by #256
Labels

Comments

@Hugovdberg
Copy link
Collaborator

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:

  • Create a project directory using create.project
  • Set working directory to the new project
  • Create a project directory at a new full path using create.project again (for example create.project(tempdir()))

Possible solution:

  • wrap .stopifproject calls in a conditional if (dirname(project.name)=='.'){}

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
Copy link
Owner

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

@rsangole rsangole added the Bug label Apr 21, 2018
@Hugovdberg
Copy link
Collaborator Author

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
Copy link
Collaborator

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
Copy link
Owner

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

@Hugovdberg
Copy link
Collaborator Author

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
Copy link
Collaborator

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

.stopifproject(c("Cannot create a new project inside an existing one",
"Please change to another directory and re-run create.project()"))
.stopifproject(c("Cannot create a new project inside an existing one",
"Please change to another directory and re-run create.project()"),
path = dirname(getwd()))

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.

@rsangole rsangole mentioned this issue May 1, 2018
3 tasks
@KentonWhite
Copy link
Owner

Closing this now since the issue is moved to #240

@KentonWhite KentonWhite reopened this May 2, 2018
Hugovdberg added a commit to Hugovdberg/ProjectTemplate that referenced this issue May 2, 2018
…olute path instead of the current directory
KentonWhite pushed a commit that referenced this issue May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants