Difference opening applications in Finder and Terminal

Discussion in 'OS X El Capitan (10.11)' started by MatsSkoe, Apr 13, 2016.

  1. MatsSkoe macrumors member

    MatsSkoe

    Joined:
    Jul 28, 2013
    Location:
    Rotterdam
    #1
    I have a problem opening RStudio in Finder which does not occur when using Terminal with "open /Applications/RStudio.app/".

    The origin of the problem is the need of a environment variable RSTUDIO_WHICH_R, which I set in .bash_profile. Somehow opening the application in Finder does not look into .bash_profile. Does anyone know a workaround?
     
  2. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #2
    How did you install RStudio and the R framework? Setting the environment variable is only necessary when you intend to override the default behaviour. If you installed R correctly, then this should work.
     
  3. chrfr macrumors 603

    Joined:
    Jul 11, 2009
    #3
    You could just make a little application launching app with AppleScript; this should work to apply the environment variable, although I don't have an app here to test. Open up AppleScript Editor in your Utilities folder and paste the following in:
    Code:
    do shell script "echo open /Applications/RStudio.app | /bin/bash"
    Then save the script as an application and you can just double click on that to open Studio.
    I don't use RStudio so I can't speak to whether you need to be using it this way.
     
  4. MatsSkoe thread starter macrumors member

    MatsSkoe

    Joined:
    Jul 28, 2013
    Location:
    Rotterdam
    #4
    I installed R with Anaconda (Python) so I can also use R with Jupyter Notebook. I don't want a double installation of R so I use "export RSTUDIO_WHICH_R="/Users/Mats/anaconda/bin/R"" and RStudio works opened from Terminal.
    --- Post Merged, Apr 13, 2016 ---
    Thank you for the suggestion. However, it does not work i'm afraid. I can always try Automater, I guess...
     
  5. chrfr macrumors 603

    Joined:
    Jul 11, 2009
    #5
    In which way doesn't it work? Does it not open RStudio or does it not open RStudio with the right variable?
     
  6. MatsSkoe thread starter macrumors member

    MatsSkoe

    Joined:
    Jul 28, 2013
    Location:
    Rotterdam
    #6
    It does open RStudio but not with the right variable indeed.
     
  7. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #7
    Have you considered symlinking /usr/local/bin/R to /Users/Mats/anaconda/bin/R?
     
  8. MatsSkoe thread starter macrumors member

    MatsSkoe

    Joined:
    Jul 28, 2013
    Location:
    Rotterdam
    #8
    Your solution is perfect in it simplicity. I knew of symbolic links but never needed to use them. RStudio does start normally this way, however in the same .bash_profile I specified the locale as
    en_US.UTF-8. So I still have to open with Terminal do get normal functionality.
     
  9. KALLT macrumors 601

    Joined:
    Sep 23, 2008
    #9
    I came across this: http://stackoverflow.com/a/28353147. Have you tried the solutions suggested there? For instance:
    Code:
    defaults write org.R-project.R force.LANG en_US.UTF-8
     
  10. NoBoMac macrumors 6502a

    Joined:
    Jul 1, 2014
    #10
    Makes sense that the dot files are not read, in that Finder process is a child of launchd, which is owned by root.

    Along the lines of KALLT post above, can use launchctl to set environment variables for any GUI (Finder launched) program.

    Code:
    launchctl setenv var var_val
    Can also add environment variable setting to /etc/launchd-user.conf

    Along the lines of Automater, I have an old app I downloaded years ago called "AppFactory". Builds apps out of shell scripts. Don't need the app to accomplish this. Need to create an "app_name.app" folder, Contents folder under that. Under Contents, make a Resources folder and a MacOS folder. In MacOS, create your shell script to set environment variables and launch the app. chmod 775 shell_script_name. Done. Can now double click your homemade app and have everything setup correctly.
     
  11. richard2 macrumors regular

    richard2

    Joined:
    Oct 21, 2010
    Location:
    England, United Kingdom
    #11
    As of OS X Yosemite, launchd doesn't support configuration files.
     

Share This Page