gge-ucd / R-DAVIS

Repo for WEBSITE of R for Data Analysis & Visualization in Science, a quarter long course oriented for graduate students in Ecology at UC Davis
https://gge-ucd.github.io/R-DAVIS/
Other
28 stars 13 forks source link

Nonexistent path in R-DAVIS.Rproj #38

Closed gvwilson closed 6 years ago

gvwilson commented 6 years ago

When I open R-DAVIS.Rproj in RStudio, I'm told:

Error: The specified directory '/Users/gvwilson/Documents/github/teaching/R-DAVIS' does not exist.

I believe this is because the file contains the line:

WebsitePath: ~/Documents/github/teaching/R-DAVIS

which doesn't exist on my computer.

mikoontz commented 6 years ago

Thanks, Greg! We'll look into this.

mikoontz commented 6 years ago

Update: I'm getting this error also. I didn't use to, so I'm not sure what's going on yet. @ryanpeek, does the "Documents/github/teaching/R-DAVIS" part of this look like the file path for your local copy of this repository? My error says the same as Greg's, but with "Users/mikoontz/Documents/github/teaching/R-DAVIS" which makes me think the .Rproj is capturing whatever "~" would mean on a local machine, but then forcing the "Documents/github/teaching/" part.

ryanpeek commented 6 years ago

I'll take a look today and try to track this down! Thanks much.

MCMaurer commented 6 years ago

Yeah, I got the same thing- the .Rproj is just going to your home directory and looking from there. I'd guess it's looking at your home directory as defined in your .Rprofile or .Renviron and setting up your current working directory based on that.

I'm sure there's another way to do it, but I just made the proper folder structure and the error went away. For merging PRs and whatnot, should we maybe put the .Rproj in the .gitignore so we can all modify it on our own branches, but then it doesn't get messed up on the master?

ryanpeek commented 6 years ago

Here's what my RProj file looks like:

Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

BuildType: Website
WebsitePath: ~/Documents/github/teaching/R-DAVIS

So yes, I think the issue relates to the ~. I can .gitignore the .Rproj file, unless someone has a better suggestion.

mikoontz commented 6 years ago

I guess I'm surprised by this behavior of the .Rproj file. I thought that was its purpose: to keep it packaged with the repository and have it decide that the directory in which it lives should be the working directory for the whole project.

In comparing a .Rproj file from a non-website repo to this one, there is no path at all (website path or otherwise) in the .Rproj file for the non-website repo. Not sure why one gets added.

I just created a new test website in RStudio following these instructions: https://rmarkdown.rstudio.com/rmarkdown_websites.htm

here's the .RProj for that:

Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: knitr
LaTeX: pdfLaTeX

BuildType: Website

No WebsitePath line at all. How did that line get in there?

mikoontz commented 6 years ago

I'd suggest not ignoring the .Rproj, because that should be a key part of the project tying everything together. I'm guessing there's another solution. Can you delete that line and still build the site locally?

ryanpeek commented 6 years ago

Yup...looks like that's the best option. I'll push an updated .Rproj over in a bit. @mikoontz, would you like me to merge other fixes that I reviewed?

ryanpeek commented 6 years ago

And yes after deleting that line, it rebuilt just fine...so not sure of the need for that line.

mikoontz commented 6 years ago

Found it. Under the "Build" tab in RStudio, go to "More" -> "Configure Build Tools". By default, the "Site Directory" is "(Project Root)" but I bet it has the path on Ryan's local machine that we keep seeing. I just confirmed that changing this directory is what sets the "WebsitePath" in the .Rproj file.

I also confirmed that the site won't build locally if that WebsitePath doesn't match where the repository is (e.g., if it's on someone else's machine).

I just checked and it seems that deleting the website path line in the .RProj file resets the site directory to (Project Root) and now the site can build. So I think Ryan is right to just modify the .Rproj directly and push that.

ryanpeek commented 6 years ago

Here's what Configure Build Tools looks like now...

screen shot 2018-10-29 at 11 02 53 am