Path 在OSX 10.9 mavericks下声明RStudio(和其他GUI应用程序)的路径 问题是:在使用10.9下的system()调用和使用RStudio 0.98-501时,我在bash路径中找不到应用程序。

Path 在OSX 10.9 mavericks下声明RStudio(和其他GUI应用程序)的路径 问题是:在使用10.9下的system()调用和使用RStudio 0.98-501时,我在bash路径中找不到应用程序。,path,osx-mavericks,rstudio,Path,Osx Mavericks,Rstudio,例1 例2 这似乎是因为RStudio作为一个GUI应用程序,并没有继承my.profile/.bashrc中定义的完整路径 我在旧mac系统上找到了许多与此相关的帖子,并为mavericks组装了一个解决方案。我尝试了来自小牛队的修正,但没有成功 launchctl setenv PATH $PATH 我的解决方案:创建自定义脚本/函数和自定义路径文件 声明一个自定义函数,以便能够在每次路径更改时更新它 将函数存储在脚本中,以便能够以root用户身份运行它 使用此函数可创建OSX GUI应

例1

例2

这似乎是因为RStudio作为一个GUI应用程序,并没有继承my.profile/.bashrc中定义的完整路径

我在旧mac系统上找到了许多与此相关的帖子,并为mavericks组装了一个解决方案。我尝试了来自小牛队的修正,但没有成功

launchctl setenv PATH $PATH
我的解决方案:创建自定义脚本/函数和自定义路径文件
  • 声明一个自定义函数,以便能够在每次路径更改时更新它
  • 将函数存储在脚本中,以便能够以root用户身份运行它
  • 使用此函数可创建OSX GUI应用程序(包括RStudio)将继承的完整等效路径
该函数在my$HOME中的“.myfunctions”中声明,并在my.profile中源代码

现在是脚本:

!/bin/bash

function setGUIpath () {
# create a custom path file in /etc/paths.d
# store the full PATH in that file for GUI apps
# created for the need to know PATH in RStudio system() calls

# mypath should exist and be writable (or sudo)
mypath=/etc/paths.d/mypath

# clear existing
cat /dev/null > ${mypath}

# fill with unique PATH items
# remove added 'PATH=' strings (what is doing this?)
echo $PATH | sed -e 's/PATH=//' | awk -F: '{for (i=1;i<=NF;i++) { if ( !x[$i]++ ) printf("%s\n",$i); }}' | sed -e 's/PATH=//' > ${mypath}

# restart Dock
osascript -e 'tell app "Dock" to quit'
}

# export it (optional?)
export -f setGUIpath

# run it
setGUIpath
/bin/bash
函数setGUIpath(){
#在/etc/path.d中创建自定义路径文件
#将GUI应用程序的完整路径存储在该文件中
#为了解RStudio system()调用中的路径而创建
#mypath应存在且可写(或sudo)
mypath=/etc/path.d/mypath
#清除现有的
cat/dev/null>${mypath}
#用唯一路径项填充
#删除添加的“PATH=”字符串(这是做什么的?)
echo$PATH | sed-e's/PATH=/'| awk-F:'{for(i=1;i
launchctl setenv PATH $PATH
!/bin/bash

function setGUIpath () {
# create a custom path file in /etc/paths.d
# store the full PATH in that file for GUI apps
# created for the need to know PATH in RStudio system() calls

# mypath should exist and be writable (or sudo)
mypath=/etc/paths.d/mypath

# clear existing
cat /dev/null > ${mypath}

# fill with unique PATH items
# remove added 'PATH=' strings (what is doing this?)
echo $PATH | sed -e 's/PATH=//' | awk -F: '{for (i=1;i<=NF;i++) { if ( !x[$i]++ ) printf("%s\n",$i); }}' | sed -e 's/PATH=//' > ${mypath}

# restart Dock
osascript -e 'tell app "Dock" to quit'
}

# export it (optional?)
export -f setGUIpath

# run it
setGUIpath