here() ignores .here file
jzadra opened this issue · 4 comments
I really love this package, thank you. I'm hoping someone can help with a problem I'm regularly having with here() where it ignores the .here file and instead chooses the R project file directory.
> dr_here()
here() starts at /Users/X/Github/mygit, because it contains a file matching `[.]Rproj$` with contents matching `^Version: ` in the first line
> set_here(getwd())
File .here already exists in /Users/X/Google Drive/SI/DataScience/mygit
> here()
[1] "/Users/X/Github/mygit"
If I unload and reload the package, here() points to the desired directory:
> detach("package:here", unload=TRUE)
> library("here")
here() starts at /Users/X/Google Drive/myfiles
Attaching package: ‘here’
The following object is masked from ‘package:lubridate’:
here
> dr_here()
here() starts at /Users/X/Google Drive/myfiles, because it contains a file `.here`
I'm also having this issue. Thanks for the tip on unloading / reloading.
I'm having the same issue. However, the unload/re-load isn't working for me.
My use case is I have a rproject where one of the subfolders is a shiny app.
instead of commenting out a setwd
command that I copy/paste when I need to work on the app locally before deploying, it would be nice if it saw the .here
file in the shiny directory.
Maybe this is a case to directly use rprojroot
?
I've resorted to the "old way" I've done things using a conditional with interactive()
if (interactive()) {
base_dir <- 'shiny/'
} else {
base_dir <- './'
}
fxns <- list.files(normalizePath(paste0(base_dir, 'functions')), full.names = TRUE)
The here and rprojroot repos are a better place to file issues.
@jzadra: This looks like the working directory has changed after loading the here package.
@chendaniely: You could also declare your base dir to be the directory that contains the shiny
directory, and use here("shiny", ...)
to address local paths. Define a shortcut function to avoid too much typing:
f <- function(...) {
here("shiny", ...)
}