When R starts in GUI (e.g., /Applications/R.app/Contents/MacOS/R) on my Mac OS X 10.7.5, the startup configuration in .Rprofile works fine. However, when R starts on the terminal (e.g., /Library/Frameworks/R.framework/Resources/bin/R), it does not work at all. What could be the reason for the failure? Thanks, Gang
Failure with .Rprofile on Mac OS X
7 messages · Amos B. Elberg, Gang Chen, David Winsemius +1 more
The only reason that *should* happen is if there's an .Rprofile in the directory you're in when you start R. Where *exactly* is the .Rprofile file you want loaded, what directory are you starting from, and what does R say is the user's home directory? Did you make *any* changes to Rprofile.site, or Renviron? What is the output from Sys.getenv() in gui and cli, and do they differ?
On Sep 18, 2014, at 11:18 AM, Gang Chen <gangchen6 at gmail.com> wrote: When R starts in GUI (e.g., /Applications/R.app/Contents/MacOS/R) on my Mac OS X 10.7.5, the startup configuration in .Rprofile works fine. However, when R starts on the terminal (e.g., /Library/Frameworks/R.framework/Resources/bin/R), it does not work at all. What could be the reason for the failure? Thanks, Gang
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Dear Gang Chen; The .Rprofile is loaded from the startup directory. Terminal.app will start up in /Applications/ while your R.app session appears to be starting in a different directory. (We don't know what your startup directories are.) I'm using R.app in /Applications/ so my .Rprofile has the same effect regardless of whether I run from R.app or from a bash console. See this portion of the Mac-FAQ: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#The-current-and-startup-working-directories See ?Startup for more specifics that are generic to all R versions:
On Sep 18, 2014, at 7:04 PM, Amos B. Elberg wrote:
The only reason that *should* happen is if there's an .Rprofile in the directory you're in when you start R. Where *exactly* is the .Rprofile file you want loaded, what directory are you starting from, and what does R say is the user's home directory? Did you make *any* changes to Rprofile.site, or Renviron? What is the output from Sys.getenv() in gui and cli, and do they differ?
They might differ even if the default directories are the same (as
they are on my setup). I have a somewhat older version on this laptop
but there are names of environment variables that are not present in
both directions:
I ran AppEnv <- dput( Sys.getenv() ) on my R.app session and then ran
the corresponding command on a Terminal console session:
These are the difference (on a R 2.15.2 setup):
> AppEnv[ !names(AppEnv) %in% names(conEnv)]
R_GUI_APP_REVISION R_GUI_APP_VERSION
"6435" "1.53"
> names( conEnv[ !names(conEnv) %in% names(AppEnv)] ) # i.e. missing
in the GUI installation
[1] "COLUMNS" "DYLD_LIBRARY_PATH"
"GDK_USE_XFT" "INFOPATH"
[5] "LINES" "MANPATH"
"PERL5LIB" "PWD"
[9] "SHLVL" "TERM"
"TERM_PROGRAM" "TERM_PROGRAM_VERSION"
[13] "XDG_CACHE_HOME" "XDG_CONFIG_DIRS"
"XDG_CONFIG_HOME" "XDG_DATA_DIRS"
[17] "XDG_DATA_HOME"
If there are further points of discussion they should be thrashed
out (with greater details about sessionInfo() and startup settings),
over on the R-MAC-SIG mailing list.
On Sep 18, 2014, at 11:18 AM, Gang Chen <gangchen6 at gmail.com> wrote: When R starts in GUI (e.g., /Applications/R.app/Contents/MacOS/R) on my Mac OS X 10.7.5, the startup configuration in .Rprofile works fine. However, when R starts on the terminal (e.g., /Library/Frameworks/R.framework/Resources/bin/R), it does not work at all. What could be the reason for the failure? Thanks, Gang
David Winsemius, MD Alameda, CA, USA
David - the startup directory for Terminal.app shouldn't affect where R looks for .Rprofile. If R is started from the command line, it should look in whatever is the user's current directory (which will be ~/ if Terminal was just launched), and then ~/ . It shouldn't be looking in /Applications/ unless you happen to have cd'd to /Applications before launching R. (You put up the environment variables present in one launch and absent from another, but what I was really looking for is whether something in his shell is changing a path. Because mac environment variables are funky that way.)
David Winsemius <mailto:dwinsemius at comcast.net> September 19, 2014 at 12:57 AM Dear Gang Chen; The .Rprofile is loaded from the startup directory. Terminal.app will start up in /Applications/ while your R.app session appears to be starting in a different directory. (We don't know what your startup directories are.) I'm using R.app in /Applications/ so my .Rprofile has the same effect regardless of whether I run from R.app or from a bash console. See this portion of the Mac-FAQ: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#The-current-and-startup-working-directories See ?Startup for more specifics that are generic to all R versions: On Sep 18, 2014, at 7:04 PM, Amos B. Elberg wrote:
The only reason that *should* happen is if there's an .Rprofile in the directory you're in when you start R. Where *exactly* is the .Rprofile file you want loaded, what directory are you starting from, and what does R say is the user's home directory? Did you make *any* changes to Rprofile.site, or Renviron? What is the output from Sys.getenv() in gui and cli, and do they differ?
They might differ even if the default directories are the same (as they are on my setup). I have a somewhat older version on this laptop but there are names of environment variables that are not present in both directions: I ran AppEnv <- dput( Sys.getenv() ) on my R.app session and then ran the corresponding command on a Terminal console session: These are the difference (on a R 2.15.2 setup):
AppEnv[ !names(AppEnv) %in% names(conEnv)]
R_GUI_APP_REVISION R_GUI_APP_VERSION
"6435" "1.53"
names( conEnv[ !names(conEnv) %in% names(AppEnv)] ) # i.e. missing
in the GUI installation [1] "COLUMNS" "DYLD_LIBRARY_PATH" "GDK_USE_XFT" "INFOPATH" [5] "LINES" "MANPATH" "PERL5LIB" "PWD" [9] "SHLVL" "TERM" "TERM_PROGRAM" "TERM_PROGRAM_VERSION" [13] "XDG_CACHE_HOME" "XDG_CONFIG_DIRS" "XDG_CONFIG_HOME" "XDG_DATA_DIRS" [17] "XDG_DATA_HOME" If there are further points of discussion they should be thrashed out (with greater details about sessionInfo() and startup settings), over on the R-MAC-SIG mailing list.
On Sep 18, 2014, at 11:18 AM, Gang Chen <gangchen6 at gmail.com> wrote: When R starts in GUI (e.g., /Applications/R.app/Contents/MacOS/R) on my Mac OS X 10.7.5, the startup configuration in .Rprofile works fine. However, when R starts on the terminal (e.g., /Library/Frameworks/R.framework/Resources/bin/R), it does not work at all. What could be the reason for the failure? Thanks, Gang
David Winsemius, MD Alameda, CA, USA Gang Chen <mailto:gangchen6 at gmail.com> September 18, 2014 at 11:18 AM When R starts in GUI (e.g., /Applications/R.app/Contents/MacOS/R) on my Mac OS X 10.7.5, the startup configuration in .Rprofile works fine. However, when R starts on the terminal (e.g., /Library/Frameworks/R.framework/Resources/bin/R), it does not work at all. What could be the reason for the failure? Thanks, Gang
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Thanks for the help, Amos!
The only reason that *should* happen is if there's an .Rprofile in the directory you're in when you start R.
There is only one .Rprofil, which is in my home directory ~/
Where *exactly* is the .Rprofile file you want loaded
The only one is in my home directory.
what directory are you starting from
It does not matter where I start R because on my Mac the CLI R is linked to /Library/Frameworks/R.framework/Resources/bin/R while the GUI R is linked to /Applications/R.app/Contents/MacOS/R
what does R say is the user's home directory? Did you make *any* changes to Rprofile.site, or Renviron?
R.home()
[1] "/Library/Frameworks/R.framework/Resources"
What is the output from Sys.getenv() in gui and cli, and do they differ?
They differ slightly. I have trouble pinpointing the exact difference because the format is a little different and vim does not help much in tracking the differences. I just noticed that the CLI version has a few extra terms such as COLUMNS "130" ... DYLD_FALLBACK_LIBRARY_PATH "/Library/Frameworks/R.framework/Resources/lib" Thanks, Gang
On Thu, Sep 18, 2014 at 7:04 PM, Amos B. Elberg <amos.elberg at gmail.com> wrote:
The only reason that *should* happen is if there's an .Rprofile in the directory you're in when you start R. Where *exactly* is the .Rprofile file you want loaded, what directory are you starting from, and what does R say is the user's home directory? Did you make *any* changes to Rprofile.site, or Renviron? What is the output from Sys.getenv() in gui and cli, and do they differ?
On Sep 18, 2014, at 11:18 AM, Gang Chen <gangchen6 at gmail.com> wrote: When R starts in GUI (e.g., /Applications/R.app/Contents/MacOS/R) on my Mac OS X 10.7.5, the startup configuration in .Rprofile works fine. However, when R starts on the terminal (e.g., /Library/Frameworks/R.framework/Resources/bin/R), it does not work at all. What could be the reason for the failure? Thanks, Gang
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Good point. I see the behavior you describe. Sent from my iPhone
On Sep 19, 2014, at 1:18 AM, "Amos B. Elberg" <amos.elberg at gmail.com> wrote: David - the startup directory for Terminal.app shouldn't affect where R looks for .Rprofile. If R is started from the command line, it should look in whatever is the user's current directory (which will be ~/ if Terminal was just launched), and then ~/ . It shouldn't be looking in /Applications/ unless you happen to have cd'd to /Applications before launching R. (You put up the environment variables present in one launch and absent from another, but what I was really looking for is whether something in his shell is changing a path. Because mac environment variables are funky that way.)
<compose-unknown-contact.jpg> David Winsemius September 19, 2014 at 12:57 AM Dear Gang Chen; The .Rprofile is loaded from the startup directory. Terminal.app will start up in /Applications/ while your R.app session appears to be starting in a different directory. (We don't know what your startup directories are.) I'm using R.app in /Applications/ so my .Rprofile has the same effect regardless of whether I run from R.app or from a bash console. See this portion of the Mac-FAQ: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#The-current-and-startup-working-directories See ?Startup for more specifics that are generic to all R versions:
On Sep 18, 2014, at 7:04 PM, Amos B. Elberg wrote: The only reason that *should* happen is if there's an .Rprofile in the directory you're in when you start R. Where *exactly* is the .Rprofile file you want loaded, what directory are you starting from, and what does R say is the user's home directory? Did you make *any* changes to Rprofile.site, or Renviron? What is the output from Sys.getenv() in gui and cli, and do they differ?
They might differ even if the default directories are the same (as they are on my setup). I have a somewhat older version on this laptop but there are names of environment variables that are not present in both directions: I ran AppEnv <- dput( Sys.getenv() ) on my R.app session and then ran the corresponding command on a Terminal console session: These are the difference (on a R 2.15.2 setup):
AppEnv[ !names(AppEnv) %in% names(conEnv)]
R_GUI_APP_REVISION R_GUI_APP_VERSION
"6435" "1.53"
names( conEnv[ !names(conEnv) %in% names(AppEnv)] ) # i.e. missing in the GUI installation
[1] "COLUMNS" "DYLD_LIBRARY_PATH" "GDK_USE_XFT" "INFOPATH" [5] "LINES" "MANPATH" "PERL5LIB" "PWD" [9] "SHLVL" "TERM" "TERM_PROGRAM" "TERM_PROGRAM_VERSION" [13] "XDG_CACHE_HOME" "XDG_CONFIG_DIRS" "XDG_CONFIG_HOME" "XDG_DATA_DIRS" [17] "XDG_DATA_HOME" If there are further points of discussion they should be thrashed out (with greater details about sessionInfo() and startup settings), over on the R-MAC-SIG mailing list.
On Sep 18, 2014, at 11:18 AM, Gang Chen <gangchen6 at gmail.com> wrote: When R starts in GUI (e.g., /Applications/R.app/Contents/MacOS/R) on my Mac OS X 10.7.5, the startup configuration in .Rprofile works fine. However, when R starts on the terminal (e.g., /Library/Frameworks/R.framework/Resources/bin/R), it does not work at all. What could be the reason for the failure? Thanks, Gang
David Winsemius, MD Alameda, CA, USA <compose-unknown-contact.jpg> Gang Chen September 18, 2014 at 11:18 AM When R starts in GUI (e.g., /Applications/R.app/Contents/MacOS/R) on my Mac OS X 10.7.5, the startup configuration in .Rprofile works fine. However, when R starts on the terminal (e.g., /Library/Frameworks/R.framework/Resources/bin/R), it does not work at all. What could be the reason for the failure? Thanks, Gang
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
On 18-09-2014, at 17:18, Gang Chen <gangchen6 at gmail.com> wrote:
When R starts in GUI (e.g.,/Library/Frameworks/R.framework/Resources/bin/R) on my Mac OS X 10.7.5, the startup configuration in .Rprofile works fine. However, when R starts on the terminal (e.g., /Library/Frameworks/R.framework/Resources/bin/R), it does not work at all. What could be the reason for the failure?
This belongs on the R-SIG-Mac mailing list. 1. Are you running T in Terminal with the command "/Library/Frameworks/R.framework/Resources/bin/R?? You can use just R because /usr/bin is in PATH (or it should be). 2. Are you running R GUI with the command "/Applications/R.app/Contents/MacOS/R??