Relevant paths when using source()
#338
Replies: 4 comments
-
Is there a particular reason you are using As a workaround you could use See also: FAQ: Can I call |
Beta Was this translation helpful? Give feedback.
-
I should add for completeness: ‘box’ could handle this (it just currently doesn’t). If there’s a good reason why using |
Beta Was this translation helpful? Give feedback.
-
I was hoping there might be a solution similar to Python's |
Beta Was this translation helpful? Give feedback.
-
Regarding subprocess execution, R has two equivalent packages:
It’s worth noting that ‘callr’ messes with the system environment in the R subprocess, which may in some cases lead to issues with ‘box’ specifically, which is unfortunate. The related ‘box’ issue — #199 — is still open because I couldn’t find a good solution so far (ideally it would be fixed in ‘callr’ but that won’t happen because it would require massive architectural reworking). The workaround at the moment is to call |
Beta Was this translation helpful? Give feedback.
-
Hello, I have a project stucture like so:
Some various modules are in utils, as a simple example we might have:
help.R
I can easily use relevant pathing to refer to the utilities folder in
a.R
.a.R
This works when running interactively in RStudio or calling the script directly from the terminal with
Script src/a.R
.However, I want to have a file to run everything, in this case I'm using
run.R
. When usingsource()
, it generates an error because the path is searching from the top of the directory.run.R
Is there a way to source or run files so that the module relevant paths are done directly from the sourced file? I have tried using
local = TRUE
andlocal = new.env()
in thesource()
call, and usingsys.source()
, and nothing has worked.Interestingly, if I instead switch the entire project to use
{renv}
I have no issues usingrun()
:However, I am looking for a way to do this without requiring
{renv}
and wondering if I am missing something simple.Beta Was this translation helpful? Give feedback.
All reactions