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

accommodate renv projects with reprex? #284

Closed
kevinushey opened this issue Oct 7, 2019 · 4 comments · Fixed by #360
Closed

accommodate renv projects with reprex? #284

kevinushey opened this issue Oct 7, 2019 · 4 comments · Fixed by #360
Labels
feature a feature request or enhancement

Comments

@kevinushey
Copy link

From rstudio/renv#208.

Projects using renv typically require some extra gymnastics, which are performed (normally) through the use of a project .Rprofile. However, reprex() does not read that .Rprofile by default, leading to some subtle differences in how reprex() runs code versus how renv might run that same code.

It could be worth considering whether reprex() could support this by default; e.g. by allowing the project .Rprofile to be loaded -- either by default, or when it detects or knows renv is active.

@jennybc
Copy link
Member

jennybc commented Oct 8, 2019

Jotting down ideas for what reprex_renv() could do:

  • Always set outfile = NA or take some other measure so that working directory is inherited, not set to session temp dir.
  • Prepend the user's code with an include = FALSE chunk that sources project .Rprofile.

@jennybc
Copy link
Member

jennybc commented Jan 8, 2021

I'm going to look at this soon @kevinushey. Will you read it over again and update if renv or your thinking has evolved?

@kevinushey
Copy link
Author

Thanks! I think there are two possible approaches here:

  1. Ensure the new R session is launched in the project root directory, so that the project .Rprofile is sourced and used. (For renv projects, if that file exists, it will automatically load that project, set up library paths, and so on.)

  2. Rather than changing the working directory for the process, just explicitly call renv::load("/path/to/project") before running the reprex code. This would ensure that renv reprex's work even if the user has disabled the renv auto-loader in the project .Rprofile.

@jennybc
Copy link
Member

jennybc commented Feb 12, 2021

I didn't end up doing anything specific to renv here. I just rationalized reprex's behaviour in light of callr::r()'s default behaviour re: executing .Rprofile in working directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants