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

RStudio doesn't respect environment variables set in .zshenv #6482

Open
dylanjm opened this issue Mar 16, 2020 · 2 comments
Open

RStudio doesn't respect environment variables set in .zshenv #6482

dylanjm opened this issue Mar 16, 2020 · 2 comments

Comments

@dylanjm
Copy link

@dylanjm dylanjm commented Mar 16, 2020

System details

RStudio Edition : Desktop
RStudio Version : 1.2.5033
OS Version      :  macOS Catalina 10.15.3
R Version       :  3.6.3

Steps to reproduce the problem

  1. Start RStudio
  2. run Sys.getenv()
  3. Start R session in terminal (outside Rstudio)
  4. run Sys.getenv()
  5. Compare

Describe the problem in detail

I have the following variables set in my .zshenv file:

export R_USER="$XDG_CONFIG_HOME/R"
export R_ENVIRON_USER="$XDG_CONFIG_HOME/R/Renviron"
export R_PROFILE_USER="$XDG_CONFIG_HOME/R/Rprofile"
export R_MAKEVARS_USER="$XDG_CONFIG_HOME/R/Makevars"
export R_HISTFILE="$XDG_DATA_HOME/Rhistory"
export R_LIBS_USER="$HOME/Library/R/3.6/library"
export R_HISTSIZE=100000
export R_STARTUP_DEBUG=TRUE
export MKL_NUM_THREADS=16
export OMP_NUM_THREADS=16

My ~/.config/R/Renviron looks like:

R_USER="~/.config/R"
R_ENVIRON_USER="~/.config/R/Renviron"
R_PROFILE_USER="~/.config/R/Rprofile"
R_MAKEVARS_USER="~/.config/R/Makevars"
R_HISTFILE="~/.local/share/Rhistory"
R_LIBS_USER="~/Library/R/3.6/library"
PKG_CONFIG_PATH="/opt/X11/lib/pkgconfig:/usr/local/Cellar/cairo/1.16.0_2/lib/pkgconfig"

LC_ALL="en_US.UTF-8"
R_GSCMD="/usr/local/bin/gs"
TZ=America/Boise
R_HISTSIZE=100000
R_STARTUP_DEBUG=TRUE
MKL_NUM_THREADS=28
OMP_NUM_THREADS=28

My ~/.config/R/Rprofile looks like:

options(Ncpus = 28)
options(dependencies = TRUE)
options(showWarnCalls=TRUE)
options(showErrorCalls=TRUE)
options(max.print=500)
options(warnPartialMatchDollar = TRUE)

local({r <- getOption("repos")
       r["CRAN"] <- "https://cloud.r-project.org"
       options(repos=r)
})

My rstudio shell preferences are set to custom by launching /usr/bin/local/zsh. My thinking is that RStudio gets its environment variables from there. Since these env vars wouldn't be available in a bash shell.

When running Sys.getenv() from a shell, I get (only showing R vars):

R_ARCH
R_BROWSER               /usr/bin/open
R_BZIPCMD               /usr/bin/bzip2
R_DOC_DIR               /usr/local/Cellar/r/3.6.3/lib/R/doc
R_ENVIRON_USER          ~/.config/R/Renviron
R_GSCMD                 /usr/local/bin/gs
R_GZIPCMD               /usr/bin/gzip
R_HISTFILE              ~/.local/share/Rhistory
R_HISTSIZE              100000
R_HOME                  /usr/local/Cellar/r/3.6.3/lib/R
R_INCLUDE_DIR           /usr/local/Cellar/r/3.6.3/lib/R/include
R_LIBS_SITE
R_LIBS_USER             ~/Library/R/3.6/library
R_MAKEVARS_USER         ~/.config/R/Makevars
R_PAPERSIZE             a4
R_PDFVIEWER             /usr/bin/open
R_PLATFORM              x86_64-apple-darwin19.3.0
R_PRINTCMD              lpr
R_PROFILE_USER          ~/.config/R/Rprofile
R_RD4PDF                times,inconsolata,hyper
R_SESSION_TMPDIR        /var/folders/8f/6wyq8d7s2slg_zm4jnb9h9n51rvltx/T//RtmptcK2io
R_SHARE_DIR             /usr/local/Cellar/r/3.6.3/lib/R/share
R_STARTUP_DEBUG         TRUE
R_STRIP_SHARED_LIB      strip -x
R_STRIP_STATIC_LIB      strip -S
R_SYSTEM_ABI            osx,gcc,gxx,gfortran,gfortran
R_TEXI2DVICMD           /usr/local/opt/texinfo/bin/texi2dvi
R_UNZIPCMD              /usr/bin/unzip
R_USER                  ~/.config/R
R_ZIPCMD                /usr/bin/zip

When running inside RStudio R console, I get:

R_BROWSER                                          /usr/bin/open
R_BZIPCMD                                          /usr/bin/bzip2
R_DOC_DIR                                          /usr/local/Cellar/r/3.6.3/lib/R/doc
R_GZIPCMD                                          /usr/bin/gzip
R_HOME                                             /usr/local/Cellar/r/3.6.3/lib/R
R_INCLUDE_DIR                                      /usr/local/Cellar/r/3.6.3/lib/R/include
R_LIBS_SITE                                        
R_LIBS_USER                                        ~/Library/R/3.6/library
R_PACKRAT_DEFAULT_LIBPATHS                         /usr/local/lib/R/3.6/site-library:/usr/local/Cellar/r/3.6.3/lib/R/library
R_PACKRAT_SITE_LIBRARY                             /usr/local/Cellar/r/3.6.3/lib/R/site-library
R_PACKRAT_SYSTEM_LIBRARY                           /usr/local/Cellar/r/3.6.3/lib/R/library
R_PAPERSIZE                                        a4
R_PDFVIEWER                                        /usr/bin/open
R_PLATFORM                                         x86_64-apple-darwin19.3.0
R_PRINTCMD                                         lpr
R_RD4PDF                                           times,inconsolata,hyper
R_SESSION_TMPDIR                                   /var/folders/8f/6wyq8d7s2slg_zm4jnb9h9n51rvltx/T//RtmpRSC312
R_SHARE_DIR                                        /usr/local/Cellar/r/3.6.3/lib/R/share
R_STRIP_SHARED_LIB                                 strip -x
R_STRIP_STATIC_LIB                                 strip -S
R_SYSTEM_ABI                                       osx,gcc,gxx,gfortran,gfortran
R_TEXI2DVICMD                                      /usr/local/opt/texinfo/bin/texi2dvi
R_UNZIPCMD                                         /usr/bin/unzip
R_ZIPCMD                                           /usr/bin/zip
RMARKDOWN_MATHJAX_PATH                             /Applications/RStudio.app/Contents/Resources/resources/mathjax-26
RS_PPM_FD_READ                                     15
RS_PPM_FD_WRITE                                    16
RS_RPOSTBACK_PATH                                  /Applications/RStudio.app/Contents/MacOS/rpostback
RS_SHARED_SECRET                                   2890288751002926111990733829
RSTUDIO                                            1
RSTUDIO_CONSOLE_COLOR                              256
RSTUDIO_CONSOLE_WIDTH                              173
RSTUDIO_PANDOC                                     /Applications/RStudio.app/Contents/MacOS/pandoc
RSTUDIO_SESSION_PORT                               26160
RSTUDIO_USER_IDENTITY                              mcdodj
RSTUDIO_WINUTILS                                   bin/winutils
SECURITYSESSIONID                                  186a7
SED                                                /usr/bin/sed
SHELL                                              /usr/local/bin/zsh
SSH_ASKPASS                                        rpostback-askpass
SSH_AUTH_SOCK                                      /private/tmp/com.apple.launchd.FCujwid3Mb/Listeners
TAR                                                /usr/bin/tar
TERM                                               xterm-256color
TMPDIR                                             /var/folders/8f/6wyq8d7s2slg_zm4jnb9h9n51rvltx/T/
XPC_FLAGS                                          0x0
XPC_SERVICE_NAME                                   org.rstudio.RStudio.4076

Describe the behavior you expected

I expected them to have the same USER variables.

@gtritchie

This comment has been minimized.

Copy link
Contributor

@gtritchie gtritchie commented Mar 16, 2020

When you said:

My rstudio shell preferences are set to custom by launching /usr/bin/local/zsh

Does that mean you configured a custom shell under the terminal options, e.g.:

screen shot of global options with terminal configured with custom shell

The setting in the Terminal tab does not impact how RStudio loads its R session, only how terminals in the Terminal tab get launched, so it is expected that what you describe would not cause the RStudio session to respect what is in .zshenv.

I'll leave this open at the moment so others more familiar with the overall R startup sequence than I am can comment.

@dylanjm

This comment has been minimized.

Copy link
Author

@dylanjm dylanjm commented Mar 17, 2020

Does that mean you configured a custom shell under the terminal options

Yes, I thought maybe it was a possibility that Rstudio got its env from a shell subprocess, but it makes sense that doesn't.

Regardless of that fact, it would make sense for user set variables to be recognized in Rstudio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.