RStudio Server open source not running .Renviron

I have the following line in my .Renviron:

touch rstudio_should_create_me

This file is not created when I start an RStudio session.

@abalater,

The .Renviron file is not a bash script, it is simply a list of key-value pairs for environment variables that will be made available to the R session on startup. See: https://www.rdocumentation.org/packages/base/versions/3.5.0/topics/Startup

As an example, the following is a .Renviron file:

TESTID=123

Then, from within R, you can use Sys.getenv("TESTID") which will return the value 123.

The .Renviron file is useful for specifying settings that apply after R is started. You can't use the .Renviron file to affect the environment before R is started (or to specify which version of R is used).

3 Likes

I'm still dubious.

I have the following in the .Renviron for a project:

RSTUDIO_WHICH_R=/home/lab/conda/envs/r35/bin/R

If I start R at the command line inside that project, I get:

PATH                    /home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
R_HOME                  /home/lab/conda/lib/R
R_INCLUDE_DIR           /home/lab/conda/lib/R/include
R_LIBS_SITE
R_LIBS_USER             ~/R/x86_64-conda_cos6-linux-gnu-library/3.4
R_PAPERSIZE             a4
R_PDFVIEWER             /usr/bin/open
R_PLATFORM              x86_64-conda_cos6-linux-gnu
R_PRINTCMD
R_RD4PDF                times,hyper
R_SESSION_TMPDIR        /tmp/Rtmp3dxEj3
R_SHARE_DIR             /home/lab/conda/lib/R/share
R_SYSTEM_ABI            linux,gcc,gxx,gfortran,?
R_TEXI2DVICMD           texi2dvi
R_UNZIPCMD              /usr/bin/unzip
R_ZIPCMD
RANLIB                  /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-ranlib
READELF                 /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-readelf
RSTUDIO_WHICH_R         /home/lab/conda/envs/dada2/R

Note:

~/rsenvtest$ which R
/home/lab/conda/bin/R

So, while the environment variable RSTUDIO_WHICH_R is getting set, it's not being applied to the rest of the environment.

However, if I activate the environment, then:

> system('which R')
/home/lab/conda/envs/dada2/bin/R
> Sys.getenv()
PATH                    /home/lab/conda/envs/dada2/bin:/home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PWD                     /home/balter/rsenvtest
R_ARCH
R_BROWSER               /usr/bin/open
R_BZIPCMD               /home/lab/conda/envs/dada2/bin/bzip2
R_DOC_DIR               /home/lab/conda/envs/dada2/lib/R/doc
R_GZIPCMD               /bin/gzip
R_HOME                  /home/lab/conda/envs/dada2/lib/R
R_INCLUDE_DIR           /home/lab/conda/envs/dada2/lib/R/include
R_LIBS_SITE
R_LIBS_USER             ~/R/x86_64-conda_cos6-linux-gnu-library/3.5
R_PAPERSIZE             a4
R_PDFVIEWER             /usr/bin/open
R_PLATFORM              x86_64-conda_cos6-linux-gnu
R_PRINTCMD
R_RD4PDF                times,hyper
R_SESSION_TMPDIR        /tmp/Rtmpe34mdg
R_SHARE_DIR             /home/lab/conda/envs/dada2/lib/R/share
R_SYSTEM_ABI            linux,gcc,gxx,gfortran,?
R_TEXI2DVICMD           texi2dvi
R_UNZIPCMD              /usr/bin/unzip
R_ZIPCMD                /usr/bin/zip
RANLIB                  /home/lab/conda/envs/dada2/bin/x86_64-conda_cos6-linux-gnu-ranlib
READELF                 /home/lab/conda/envs/dada2/bin/x86_64-conda_cos6-linux-gnu-readelf
RSTUDIO_WHICH_R         /home/lab/conda/envs/dada2/R

Which is what I would like.

In RStudio Server:

> system('which R')
/usr/bin/R
> Sys.getenv()
PATH                              /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
R_BROWSER                         xdg-open
R_BZIPCMD                         /bin/bzip2
R_DOC_DIR                         /usr/share/R/doc
R_GZIPCMD                         /bin/gzip -n
R_HOME                            /usr/lib/R
R_INCLUDE_DIR                     /usr/share/R/include
R_LIBS_SITE                       /usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library
R_LIBS_USER                       ~/R/x86_64-pc-linux-gnu-library/3.4
RSTUDIO_WHICH_R                   /home/lab/conda/envs/dada2/R

Which is totally useless.

Related to Start Rstudio Server session in conda environment
and How to manually set all required environment variables in RStudio Server Open Source

RSTUDIO_WHICH_R is not an environment variable that R itself uses. It is used by RStudio in some case. R and RStudio are not the same
You have to keep that in mind when trying to customize your way. You need to try setting this env var on your system, not on R side.

Again, the behavior you observed is due to how a conda env behave, it is no issue per-se with RStudio IDE.

When you activate the environment conda change things on your system for it to work and find the correct R version.

I'm running RStudio Server Open Source edition. I use conda as my package manager. In the open source edition there is no provision to select an R executable through the IDE. You need to set it globally in /etc/rstudio/rserver.conf.

I've been playing around with using my .Rprofile to manually set paths for the conda environment I want to use for a specific project. Here is an example:

If I start R in a particular conda environment then all the paths seem to set automatically as required.

(base) balter@conda-test:~/rsenvtest$ source activate r35
(r35) balter@conda-test:~/rsenvtest$ R

R version 3.5.0 (2018-04-23) -- "Joy in Playing"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (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.

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.
>
> Sys.getenv()
_CONDA_PYTHON_SYSCONFIGDATA_NAME
                        _sysconfigdata_x86_64_conda_cos6_linux_gnu
ADDR2LINE               /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-addr2line
AR                      /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-ar
AS                      /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-as
CC                      /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-cc
CFLAGS                  -march=nocona -mtune=haswell -ftree-vectorize
                        -fPIC -fstack-protector-strong -fno-plt -O2
                        -pipe
COLUMNS                 198
CONDA_BACKUP__CONDA_PYTHON_SYSCONFIGDATA_NAME
                        _sysconfigdata_x86_64_conda_cos6_linux_gnu
CONDA_BACKUP_ADDR2LINE
                        /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-addr2line
CONDA_BACKUP_AR         /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-ar
CONDA_BACKUP_AS         /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-as
CONDA_BACKUP_CC         /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-cc
CONDA_BACKUP_CFLAGS     -march=nocona -mtune=haswell -ftree-vectorize
                        -fPIC -fstack-protector-strong -fno-plt -O2
                        -pipe
CONDA_BACKUP_CPP        /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-cpp
CONDA_BACKUP_CPPFLAGS   -DNDEBUG -D_FORTIFY_SOURCE=2 -O2
CONDA_BACKUP_CXX        /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-c++
CONDA_BACKUP_CXXFILT    /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-c++filt
CONDA_BACKUP_CXXFLAGS   -fvisibility-inlines-hidden -std=c++17
                        -fmessage-length=0 -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
CONDA_BACKUP_DEBUG_CFLAGS
                        -march=nocona -mtune=haswell -ftree-vectorize
                        -fPIC -fstack-protector-all -fno-plt -Og -g
                        -Wall -Wextra -fvar-tracking-assignments -pipe
CONDA_BACKUP_DEBUG_CPPFLAGS
                        -D_DEBUG -D_FORTIFY_SOURCE=2 -Og
CONDA_BACKUP_DEBUG_CXXFLAGS
                        -fvisibility-inlines-hidden -std=c++17
                        -fmessage-length=0 -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-all
                        -fno-plt -Og -g -Wall -Wextra
                        -fvar-tracking-assignments -pipe
CONDA_BACKUP_DEBUG_FFLAGS
                        -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe -fopenmp -march=nocona
                        -mtune=haswell -ftree-vectorize -fPIC
                        -fstack-protector-all -fno-plt -Og -g -Wall
                        -Wextra -fcheck=all -fbacktrace -fimplicit-none
                        -fvar-tracking-assignments -pipe
CONDA_BACKUP_DEBUG_FORTRANFLAGS
                        -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe -fopenmp -march=nocona
                        -mtune=haswell -ftree-vectorize -fPIC
                        -fstack-protector-all -fno-plt -Og -g -Wall
                        -Wextra -fcheck=all -fbacktrace -fimplicit-none
                        -fvar-tracking-assignments -pipe
CONDA_BACKUP_ELFEDIT    /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-elfedit
CONDA_BACKUP_F77        /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gfortran
CONDA_BACKUP_F95        /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-f95
CONDA_BACKUP_FC         /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gfortran
CONDA_BACKUP_FFLAGS     -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
CONDA_BACKUP_FORTRANFLAGS
                        -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
CONDA_BACKUP_GCC        /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gcc
CONDA_BACKUP_GCC_AR     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gcc-ar
CONDA_BACKUP_GCC_NM     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gcc-nm
CONDA_BACKUP_GCC_RANLIB
                        /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gcc-ranlib
CONDA_BACKUP_GFORTRAN   /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gfortran
CONDA_BACKUP_GPROF      /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gprof
CONDA_BACKUP_GXX        /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-g++
CONDA_BACKUP_HOST       x86_64-conda_cos6-linux-gnu
CONDA_BACKUP_LD         /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-ld
CONDA_BACKUP_LD_GOLD    /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-ld.gold
CONDA_BACKUP_LDFLAGS    -Wl,-O2 -Wl,--sort-common -Wl,--as-needed
                        -Wl,-z,relro -Wl,-z,now
CONDA_BACKUP_NM         /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-nm
CONDA_BACKUP_OBJCOPY    /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-objcopy
CONDA_BACKUP_OBJDUMP    /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-objdump
CONDA_BACKUP_RANLIB     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-ranlib
CONDA_BACKUP_READELF    /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-readelf
CONDA_BACKUP_SIZE       /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-size
CONDA_BACKUP_STRINGS    /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-strings
CONDA_BACKUP_STRIP      /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-strip
CONDA_DEFAULT_ENV       r35
CONDA_EXE               /home/lab/conda/bin/conda
CONDA_PREFIX            /home/lab/conda/envs/r35
CONDA_PREFIX_1          /home/lab/conda
CONDA_PROMPT_MODIFIER   (r35)
CONDA_PYTHON_EXE        /home/lab/conda/bin/python
CONDA_SHLVL             2
CPP                     /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-cpp
CPPFLAGS                -DNDEBUG -D_FORTIFY_SOURCE=2 -O2
CURL_CA_BUNDLE          /home/lab/conda/envs/r35/lib/R/lib/microsoft-r-cacert.pem
CXX                     /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-c++
CXXFILT                 /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-c++filt
CXXFLAGS                -fvisibility-inlines-hidden -std=c++17
                        -fmessage-length=0 -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
DEBUG_CFLAGS            -march=nocona -mtune=haswell -ftree-vectorize
                        -fPIC -fstack-protector-all -fno-plt -Og -g
                        -Wall -Wextra -fvar-tracking-assignments -pipe
DEBUG_CPPFLAGS          -DNDEBUG -D_FORTIFY_SOURCE=2 -O2
DEBUG_CXXFLAGS          -fvisibility-inlines-hidden -std=c++17
                        -fmessage-length=0 -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-all
                        -fno-plt -Og -g -Wall -Wextra
                        -fvar-tracking-assignments -pipe
DEBUG_FFLAGS            -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
DEBUG_FORTRANFLAGS      -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
EDITOR                  vi
ELFEDIT                 /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-elfedit
F77                     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gfortran
F95                     /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-f95
FC                      /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gfortran
FFLAGS                  -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
FORTRANFLAGS            -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
GCC                     /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-gcc
GCC_AR                  /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-gcc-ar
GCC_NM                  /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-gcc-nm
GCC_RANLIB              /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-gcc-ranlib
GFORTRAN                /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-gfortran
GPROF                   /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-gprof
GXX                     /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-g++
HOME                    /home/balter
HOST                    x86_64-conda_cos6-linux-gnu
LANG                    C.UTF-8
LD                      /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-ld
LD_GOLD                 /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-ld.gold
LD_LIBRARY_PATH         /home/lab/conda/envs/r35/lib/R/lib:/builddir/vendor/build/lib
LDFLAGS                 -Wl,-O2 -Wl,--sort-common -Wl,--as-needed
                        -Wl,-z,relro -Wl,-z,now
LESSCLOSE               /usr/bin/lesspipe %s %s
LESSOPEN                | /usr/bin/lesspipe %s
LINES                   57
LN_S                    ln -s
LOGNAME                 balter
LS_COLORS               rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*
.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:
*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01
;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35
:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.m
pg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=0
1;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.m
id=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MAIL                    /var/mail/balter
MAKE                    make
NM                      /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-nm
OBJCOPY                 /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-objcopy
OBJDUMP                 /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-objdump
OLDPWD                  /home/balter
PAGER                   less
PATH                    /home/lab/conda/envs/r35/bin:/home/lab/conda/envs/r35/bin:/home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/b
in
PWD                     /home/balter/rsenvtest
R_ARCH
R_BROWSER               open
R_BZIPCMD               bzip2
R_DOC_DIR               /home/lab/conda/envs/r35/lib/R/doc
R_GZIPCMD               gzip
R_HOME                  /home/lab/conda/envs/r35/lib/R
R_INCLUDE_DIR           /home/lab/conda/envs/r35/lib/R/include/
R_LIBS_SITE             /home/lab/conda/envs/r35/lib/R/library/
R_LIBS_USER             /home/balter/R/
R_PAPERSIZE             a4
R_PDFVIEWER             open
R_PLATFORM              x86_64-pc-linux-gnu
R_PRINTCMD
R_RD4PDF                times,inconsolata,hyper
R_SESSION_TMPDIR        /tmp/RtmpMZxAm2
R_SHARE_DIR             /home/lab/conda/envs/r35/lib/R/share
R_SYSTEM_ABI            linux,gcc,gxx,gfortran,?
R_TEXI2DVICMD           texi2dvi
R_UNZIPCMD              unzip
R_ZIPCMD                zip
RANLIB                  /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-ranlib
READELF                 /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-readelf
SED                     /bin/sed
SHELL                   /bin/bash
SHLVL                   1
SIZE                    /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-size
SSH_CLIENT              73.11.33.164 50893 22
SSH_CONNECTION          73.11.33.164 50893 178.128.190.17 22
SSH_TTY                 /dev/pts/1
STRINGS                 /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-strings
STRIP                   /home/lab/conda/envs/r35/bin/x86_64-conda_cos6-linux-gnu-strip
TAR                     tar
TCL_LIBRARY             /home/lab/conda/envs/r35/lib/R/share/tcl8.6/
TERM                    xterm-256color
USER                    balter
XDG_DATA_DIRS           /usr/local/share:/usr/share:/var/lib/snapd/desktop
XDG_RUNTIME_DIR         /run/user/1000
XDG_SESSION_ID          491

And I can install the Bioconductor installer.

>
> source("https://bioconductor.org/biocLite.R")
trying URL 'https://bioconductor.org/packages/3.7/bioc/src/contrib/BiocInstaller_1.30.0.tar.gz'
Content type 'application/x-gzip' length 19149 bytes (18 KB)
==================================================
downloaded 18 KB

/home/balter/rsenvtest
initial path is /home/lab/conda/envs/r35/bin:/home/lab/conda/envs/r35/bin:/home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PATH: /home/lab/conda/envs/r35/bin:/home/lab/conda/envs/r35/bin:/home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
/home/lab/conda/envs/r35/bin:/home/lab/conda/envs/r35/bin:/home/lab/conda/envs/r35/bin:/home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/s
nap/bin
/home/lab/conda/envs/r35/bin/R
* installing *source* package ‘BiocInstaller’ ...
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
Bioconductor version 3.7 (BiocInstaller 1.30.0), ?biocLite for help
* DONE (BiocInstaller)

The downloaded source packages are in
        ‘/tmp/RtmpMZxAm2/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Bioconductor version 3.7 (BiocInstaller 1.30.0), ?biocLite for help
>

This is my attempt to set all the paths manually in a .Rprofile:

(base) balter@conda-test:~/rsenvtest$ cat .Rprofile
system('pwd')
system('echo "initial path is $PATH"')

env_base = "/home/lab/conda/envs/r35"

PATH = Sys.getenv('PATH')

Sys.setenv("R_LIBS_SITE"=paste0(env_base, "/lib/R/library/"))
Sys.setenv("R_LIBS_USER"="/home/balter/R/")
Sys.setenv("R_INCLUDE_DIR"= paste0(env_base, "/lib/R/include/"))
Sys.setenv("R_SHARE_DIR"=paste0(env_base, "/lib/R/share"))
Sys.setenv("R_HOME"=paste0(env_base, "/lib/R"))
Sys.setenv(PATH=paste0(env_base, "/bin:", PATH))
.libPaths(paste0(env_base, "/lib/R/library/"))

message(paste0("PATH: ",PATH))
system('echo $PATH')
system('which R')

However, this clearly does not handle all issues:

(base) balter@conda-test:~/rsenvtest$ R

R version 3.4.2 (2017-09-28) -- "Short Summer"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-conda_cos6-linux-gnu (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.

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.

/home/balter/rsenvtest
initial path is /home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PATH: /home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
/home/lab/conda/envs/r35/bin:/home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
/home/lab/conda/envs/r35/bin/R
> system('which R')
/home/lab/conda/envs/r35/bin/R
> Sys.getenv()
_                       /home/lab/conda/bin/R
_CONDA_PYTHON_SYSCONFIGDATA_NAME
                        _sysconfigdata_x86_64_conda_cos6_linux_gnu
ADDR2LINE               /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-addr2line
AR                      /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-ar
AS                      /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-as
CC                      /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-cc
CFLAGS                  -march=nocona -mtune=haswell -ftree-vectorize
                        -fPIC -fstack-protector-strong -fno-plt -O2
                        -pipe
COLUMNS                 198
CONDA_BACKUP_HOST       x86_64-conda_cos6-linux-gnu
CONDA_DEFAULT_ENV       base
CONDA_EXE               /home/lab/conda/bin/conda
CONDA_PREFIX            /home/lab/conda
CONDA_PROMPT_MODIFIER   (base)
CONDA_PYTHON_EXE        /home/lab/conda/bin/python
CONDA_SHLVL             1
CPP                     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-cpp
CPPFLAGS                -DNDEBUG -D_FORTIFY_SOURCE=2 -O2
CXX                     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-c++
CXXFILT                 /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-c++filt
CXXFLAGS                -fvisibility-inlines-hidden -std=c++17
                        -fmessage-length=0 -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
DEBUG_CFLAGS            -march=nocona -mtune=haswell -ftree-vectorize
                        -fPIC -fstack-protector-all -fno-plt -Og -g
                        -Wall -Wextra -fvar-tracking-assignments -pipe
DEBUG_CPPFLAGS          -D_DEBUG -D_FORTIFY_SOURCE=2 -Og
DEBUG_CXXFLAGS          -fvisibility-inlines-hidden -std=c++17
                        -fmessage-length=0 -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-all
                        -fno-plt -Og -g -Wall -Wextra
                        -fvar-tracking-assignments -pipe
DEBUG_FFLAGS            -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe -fopenmp -march=nocona
                        -mtune=haswell -ftree-vectorize -fPIC
                        -fstack-protector-all -fno-plt -Og -g -Wall
                        -Wextra -fcheck=all -fbacktrace -fimplicit-none
                        -fvar-tracking-assignments -pipe
DEBUG_FORTRANFLAGS      -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe -fopenmp -march=nocona
                        -mtune=haswell -ftree-vectorize -fPIC
                        -fstack-protector-all -fno-plt -Og -g -Wall
                        -Wextra -fcheck=all -fbacktrace -fimplicit-none
                        -fvar-tracking-assignments -pipe
EDITOR                  vi
ELFEDIT                 /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-elfedit
F77                     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gfortran
F95                     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-f95
FC                      /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gfortran
FFLAGS                  -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
FORTRANFLAGS            -fopenmp -march=nocona -mtune=haswell
                        -ftree-vectorize -fPIC -fstack-protector-strong
                        -fno-plt -O2 -pipe
GCC                     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gcc
GCC_AR                  /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gcc-ar
GCC_NM                  /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gcc-nm
GCC_RANLIB              /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gcc-ranlib
GFORTRAN                /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gfortran
GPROF                   /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-gprof
GXX                     /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-g++
HOME                    /home/balter
HOST                    x86_64-conda_cos6-linux-gnu
LANG                    C.UTF-8
LD                      /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-ld
LD_GOLD                 /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-ld.gold
LDFLAGS                 -Wl,-O2 -Wl,--sort-common -Wl,--as-needed
                        -Wl,-z,relro -Wl,-z,now
LESSCLOSE               /usr/bin/lesspipe %s %s
LESSOPEN                | /usr/bin/lesspipe %s
LINES                   57
LN_S                    ln -s
LOGNAME                 balter
LS_COLORS               rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*
.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:
*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01
;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35
:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.m
pg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=0
1;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.m
id=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
MAIL                    /var/mail/balter
MAKE                    make
NM                      /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-nm
OBJCOPY                 /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-objcopy
OBJDUMP                 /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-objdump
OLDPWD                  /home/balter
PAGER                   /usr/bin/less
PATH                    /home/lab/conda/envs/r35/bin:/home/lab/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PWD                     /home/balter/rsenvtest
R_ARCH
R_BROWSER               /usr/bin/open
R_BZIPCMD               /home/lab/conda/bin/bzip2
R_DOC_DIR               /home/lab/conda/lib/R/doc
R_GZIPCMD               /usr/bin/gzip
R_HOME                  /home/lab/conda/envs/r35/lib/R
R_INCLUDE_DIR           /home/lab/conda/envs/r35/lib/R/include/
R_LIBS_SITE             /home/lab/conda/envs/r35/lib/R/library/
R_LIBS_USER             /home/balter/R/
R_PAPERSIZE             a4
R_PDFVIEWER             /usr/bin/open
R_PLATFORM              x86_64-conda_cos6-linux-gnu
R_PRINTCMD
R_RD4PDF                times,hyper
R_SESSION_TMPDIR        /tmp/Rtmp9I3Q44
R_SHARE_DIR             /home/lab/conda/envs/r35/lib/R/share
R_SYSTEM_ABI            linux,gcc,gxx,gfortran,?
R_TEXI2DVICMD           texi2dvi
R_UNZIPCMD              /usr/bin/unzip
R_ZIPCMD
RANLIB                  /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-ranlib
READELF                 /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-readelf
SED                     /bin/sed
SHELL                   /bin/bash
SHLVL                   1
SIZE                    /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-size
SSH_CLIENT              73.11.33.164 50893 22
SSH_CONNECTION          73.11.33.164 50893 178.128.190.17 22
SSH_TTY                 /dev/pts/1
STRINGS                 /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-strings
STRIP                   /home/lab/conda/bin/x86_64-conda_cos6-linux-gnu-strip
TAR                     /bin/gtar
TERM                    xterm-256color
USER                    balter
XDG_DATA_DIRS           /usr/local/share:/usr/share:/var/lib/snapd/desktop
XDG_RUNTIME_DIR         /run/user/1000
XDG_SESSION_ID          491
> source("https://bioconductor.org/biocLite.R")
Error in file(filename, "r", encoding = encoding) :
  internet routines cannot be loaded

The environment variables are very different.

For complete reference, this question is related to Start Rstudio Server session in conda environment

Some answers there apply for explaining why this is challenging.

1 Like