Open torbjorn opened 4 weeks ago
Thanks. The here package currently doesn't allow changing its perception of what it thinks the root of the project should be.
Am I reading this correctly that you have a main Git repo that contains several other projects that need to run both self-contained and as a submodule in the bigger repo? What would your use case of a local_here()
or with_here()
function look like? Would the i_am()
function be of any use?
Yes, thats correct.
We have a project with a pipeline written in one repository. Code in that project uses here() on all file paths local to that project, so when sourcing R scripts and function definitions and trying to run them from another here()-root, paths dont work.
Locally changing here root would make it all magically just work, with no extra work necessary to make that pipeline support being run externally and internally. It's not ideal, a rewrite would be better, but for it to seemlessly work with no extra effort, would be quite nice.
Until, or if, this gets implemented, we have written a with_here()
and local_here()
that solves this for us for the time being. They both use i_am()
to temporarily change the here-root, which seems to work. They are not complicated functions to write.
They work roughly like this:
Thanks, interesting. Would you like to share these functions, perhaps in a package that imports here or rprojroot? I don't have time for a deeper dive now or in the coming weeks.
See the two functions here:
https://github.com/torbjorn/wither
(I tried publishing it to CRAN, but couldn't get it passed the win-buider r-devel check, seems I wasnt allowed to create files in temporary directories?)
In our work we find ourselves (due to git submodules) needing to temporarily changing here() root when sourcing files.
Would a
local_here( "/now/here", r_expression )
make sense? (and have r_expression being evaluated with here's root temporarily changed to said dir)Wasn't sure to take this here (hah!) or to withr, but it sounds specific enough that it ought to go here I believe.