[R-SIG-Mac] "command not found" from system() call in GUI with proper PATH

Roy Mendelssohn - NOAA Federal roy.mendelssohn at noaa.gov
Sat Oct 25 00:11:05 CEST 2014


For other applications it has been found that if you launch the GUI application from the terminal using the open -a command, that then the path does get sent down,

I haven't tried it for R, but it does work for things like TeX.

-Roy

On Oct 24, 2014, at 3:04 PM, Emma Sherratt <emma.sherratt at gmail.com> wrote:

> I had the same problem and Simon Urbanek replied to me with the following:
> 
> It is, because Yosemite ignores PATH for processes started from a GUI
> application. You will see if you run
> system("echo $PATH")
> 
> You have to use full paths in Yosemite for anything that is not on the
> "sanctioned" PATH -- or use R from the shell.
> 
> On Saturday, October 25, 2014, Eric Archer - NOAA Federal <
> eric.archer at noaa.gov> wrote:
> 
>> <Apologies for the cross-posting, but I couldn't tell if this was a general
>> R issue, or Mac-specific>
>> 
>> When running a system file from within R, I have just started to get a
>> "command not found" error although my PATH seems to be properly set and I
>> can run the same system file from the terminal. The program I am trying to
>> run is 'fastsimcoal' and is in /usr/local/bin. I confirm this in the
>> terminal with
>> 
>> SWC-EARCHER-ML-3:~ eric.archer$ which fastsimcoal
>> /usr/local/bin/fastsimcoal
>> 
>> In the examples below, Sys.getenv("PATH") shows that /usr/local/bin is in
>> the PATH. I get the same error for any program in /usr/local/bin. However,
>> programs in other folders in the path seem to run through system()
>> properly.
>> 
>> Also, note that the return from Sys.getenv("PATH") is the same for running
>> in R-Studio vs. R in the terminal, but is truncated in the R GUI. As far as
>> I can tell I do not have a .Rprofile file in my default working directory,
>> R_HOME, or R_HOME/etc.
>> 
>> A final piece of information: I have just upgraded to OSX Yosemite v10.10.
>> This was not happening at some point prior to the upgrade, but it has been
>> a while since I tried this particular command, so I do not know if it was
>> working immediately prior to the OS upgrade.
>> 
>> Any help or insight is greatly appreciated.
>> 
>> Cheers,
>> eric
>> 
>> The examples:
>> 
>>> From within R-Studio v0.98.1079:
>> 
>>> sessionInfo()
>> R version 3.1.1 (2014-07-10)
>> Platform: x86_64-apple-darwin13.1.0 (64-bit)
>> 
>> locale:
>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>> 
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>> 
>> loaded via a namespace (and not attached):
>> [1] tools_3.1.1
>>> getwd()
>> [1] "/Users/eric.archer"
>>> Sys.getenv("PATH")
>> [1]
>> 
>> "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin"
>>> system("fastsimcoal")
>> sh: fastsimcoal: command not found
>> 
>> 
>> The same script in the R console through the GUI gives:
>> 
>>> sessionInfo()
>> R version 3.1.1 (2014-07-10)
>> Platform: x86_64-apple-darwin13.1.0 (64-bit)
>> 
>> locale:
>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>> 
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>> getwd()
>> [1] "/Users/eric.archer"
>>> Sys.getenv("PATH")
>> [1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin"
>>> system("fastsimcoal")
>>> 
>> /bin/sh: fastsimcoal: command not found
>> 
>> 
>> Running it through R in a  terminal window, it runs (output of
>> 'fastsimcoal' truncated):
>> 
>>> sessionInfo()
>> R version 3.1.1 (2014-07-10)
>> Platform: x86_64-apple-darwin13.1.0 (64-bit)
>> 
>> locale:
>> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>> 
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>> getwd()
>> [1] "/Users/eric.archer"
>>> Sys.getenv("PATH")
>> [1]
>> 
>> "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/git/bin:/usr/texbin"
>>> system("fastsimcoal")
>> 
>> 
>> fastSimcoal2 (ver 2.1 December 2013)
>> 
>> Usage:
>> 
>> -h  --help              : prints this help
>> -i  --ifile test.par    : name of parameter file
>> ...
>> 
>> ----
>> 
>> *Eric Archer, Ph.D.*
>> Southwest Fisheries Science Center
>> NMFS, NOAA
>> 8901 La Jolla Shores Drive
>> La Jolla, CA 92037 USA
>> 858-546-7121 (work)
>> 858-546-7003 (FAX)
>> 
>> Marine Mammal Genetics Group: swfsc.noaa.gov/mmtd-mmgenetics
>> ETP Cetacean Assessment Program: swfsc.noaa.gov/mmtd-etp
>> 
>> "
>> 
>> 
>> *The universe doesn't care what you believe. The wonderful thing about
>> science is that it   doesn't ask for your faith, it just asks   for your
>> eyes.*"  - Randall Munroe
>> 
>> "*Lighthouses are more helpful than churches.*"
>>   - Benjamin Franklin
>> 
>>   "*...but I'll take a GPS over either one.*"
>>       - John C. "Craig" George
>> 
>>        [[alternative HTML version deleted]]
>> 
>> _______________________________________________
>> R-SIG-Mac mailing list
>> R-SIG-Mac at r-project.org <javascript:;>
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>> 
> 
> 
> -- 
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Emma Sherratt, PhD.
> 
> Lecturer in Zoology,
> Zoology Division, School of Environmental and Rural Science,
> Room L118 Bldg C02,
> University of New England,
> Armidale, NSW, Australia, 2351
> Tel: +61 2 6773 5038
> email: emma.sherratt at une.edu.au
> 
> Caecilians are legless amphibians...
> 
> *                      __
>    (\   .-.   .-.   /_")
>     \\_//^\\_//^\\_//
>      `"`   `"`   `"`*
> 
> learn more about them here: www.emmasherratt.com/caecilians
> 
> 	[[alternative HTML version deleted]]
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac

**********************
"The contents of this message do not reflect any position of the U.S. Government or NOAA."
**********************
Roy Mendelssohn
Supervisory Operations Research Analyst
NOAA/NMFS
Environmental Research Division
Southwest Fisheries Science Center
***Note new address and phone***
110 Shaffer Road
Santa Cruz, CA 95060
Phone: (831)-420-3666
Fax: (831) 420-3980
e-mail: Roy.Mendelssohn at noaa.gov www: http://www.pfeg.noaa.gov/

"Old age and treachery will overcome youth and skill."
"From those who have been given much, much will be expected" 
"the arc of the moral universe is long, but it bends toward justice" -MLK Jr.



More information about the R-SIG-Mac mailing list