r - RStudio shows a different $PATH variable -


possible duplicate question, don't know startup process of rstudio tell if problems same. i'm using rstudio desktop v0.99.442 on linux. console inside rstudio, run

system("echo $path") /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games 

however, real $path (which see when echo $path console) has lot of other programs on i'd able call using system() r. example, in .bashrc, have tabix appended $path.

the weird thing when run same command r session within console, get

system("echo $path") /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games;/path/to/bcftools-1.2/htslib-1.2.1/tabix 

which correct. there difference between r session inside rstudio , r session in console. not load same environment variables. how rstudio use correct version of $path?

when start r command line , run system(echo $path), inheriting bash environment command line session. when launch rstudio from, say, dock or finder on mac or system application in ubuntu, , not command line, rstudio not gets environment /.bashrc. instead environment variables system-wide settings. how finds system settings depend on operating system.

ubuntu

see this explanation of environment variables in ubuntu, section on desktop applications.

according explanation:

you can add environment variable application editing .desktop file. example, run "digikam" environment variable appmenu_display_both=1, find corresponding digikam.desktop file , add setting of variable, via env command, entry "exec":

the rstudio .desktop file in ~/.local/share/applications/ or /usr/share/applications/ (most latter). edit file include line:

path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games;/path/to/bcftools-1.2/htslib-1.2.1/tabix 

mac

system-wide environment variables set launch agent , not bash. how set environment variables applications launched finder depend on version of mac os x. answer might help.

the way add file, ~/library/launchagents/com.username.envvariables.plist these contents:

<?xml version="1.0" encoding="utf-8"?> <!doctype plist public "-//apple//dtd plist 1.0//en" "http://www.apple.com/dtds/propertylist-1.0.dtd"> <plist version="1.0">   <dict>     <key>label</key>     <string>com.username.envvariables</string>     <key>programarguments</key>     <array>       <string>sh</string>       <string>-c</string>       <string>         launchctl setenv path /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games;/path/to/bcftools-1.2/htslib-1.2.1/tabix       </string>     </array>     <key>runatload</key>     <true/>   </dict> </plist> 

you have load file:

launchctl load ~/library/launchagents/com.username.envvariables.plist 

you may have restart finder:

killall -kill dock 

then restart rstudio.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -