Activating renv removes homebrew from PATH
joranE opened this issue · comments
When I activate renv it is modifying my PATH and all Homebrew paths are removed.
If I create a new, empty project in RStudio using renv, and then check the PATH I get this:
> writeLines(strsplit(Sys.getenv("PATH"), .Platform$path.sep)[[1]])
/usr/local/bin
/System/Cryptexes/App/usr/bin
/usr/bin
/bin
/usr/sbin
/sbin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
/opt/X11/bin
/Users/joranelias/Applications/quarto/bin
/Library/TeX/texbin
/usr/texbin
/Applications/RStudio.app/Contents/Resources/app/quarto/bin
/Applications/RStudio.app/Contents/Resources/app/bin/postback
But this is missing all Homebrew paths. Here is what I see after running renv::deactivate()
:
> writeLines(strsplit(Sys.getenv("PATH"), .Platform$path.sep)[[1]])
/opt/homebrew/bin
/opt/homebrew/sbin
/usr/local/bin
/System/Cryptexes/App/usr/bin
/usr/bin
/bin
/usr/sbin
/sbin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
/opt/X11/bin
/Users/joranelias/Applications/quarto/bin
/Library/TeX/texbin
/usr/texbin
/Applications/RStudio.app/Contents/Resources/app/quarto/bin
/Applications/RStudio.app/Contents/Resources/app/bin/postback
And then after running renv::activate()
, the PATH goes back to the first output. I can toggle back and forth like that and that PATH always changes.
Here is my session info:
> sessioninfo::session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────
setting value
version R version 4.3.2 (2023-10-31)
os macOS Sonoma 14.2.1
system aarch64, darwin20
ui RStudio
language (EN)
collate en_US.UTF-8
ctype en_US.UTF-8
tz America/Denver
date 2024-03-07
rstudio 2023.12.1+402 Ocean Storm (desktop)
pandoc NA
─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────
! package * version date (UTC) lib source
P cli 3.6.2 2023-12-11 [?] CRAN (R 4.3.1)
renv 1.0.5 2024-02-29 [1] CRAN (R 4.3.1)
P sessioninfo 1.2.2 2021-12-06 [?] CRAN (R 4.3.0)
[1] /Users/joranelias/Documents/code/renv-path-test/renv/library/R-4.3/aarch64-apple-darwin20
[2] /Users/joranelias/Library/Caches/org.R-project.R/R/renv/sandbox/R-4.3/aarch64-apple-darwin20/ac5c2659
P ── Loaded and on-disk path mismatch.
─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I wonder if the behavior I'm seeing is related to this RStudio issue on macOS, because if I remove renv from the equation entirely and just put:
writeLines(strsplit(Sys.getenv("PATH"), .Platform$path.sep)[[1]])
in my .Rprofile when I restart my R session in RStudio I get only this:
Restarting R session...
/usr/bin
/bin
/usr/sbin
/sbin
whereas if I start R with the same .Rprofile in Terminal I get what I'd expect the full PATH to be:
R version 4.3.2 (2023-10-31) -- "Eye Holes"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
/opt/homebrew/bin
/opt/homebrew/sbin
/usr/local/bin
/System/Cryptexes/App/usr/bin
/usr/bin
/bin
/usr/sbin
/sbin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin
/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin
/opt/X11/bin
So it seems that in RStudio when renv runs activate.R
from .Rprofile the PATH hasn't been fully reconstructed by RStudio at that point?
And I think my suspicions are correct because I just confirmed the behavior I'm seeing is resolved in the latest RStudio daily build. So I think RStudio really was improperly altering the PATH variable in destructive ways. Feel free to close I guess.
Thanks! Indeed, this was a bug on the RStudio side that has since been fixed in the latest daily builds. (RStudio was trying to read and apply paths from /etc/paths
, but was doing so after processing .Rprofile
/ .Renviron
, leading to this issue)