OS X で PATH などの環境変数を変更する適切な方法は何ですか?
Google で少し調べたところ、編集する 3 つの異なるファイルを見つけました。
- /etc/パス
- ~/.プロファイル
- ~/.tcshrc
これらのファイルのいくつかは持っていません。また、 OS X では現在 bash が使用されているため、 .tcshrcが間違っていることはほぼ確実です。これらの変数、特に PATH はどこで定義されていますか?
走っていますOS X v10.5(ヒョウ)。
ベストアンサー1
Bruno さんのおっしゃる通りです。私は徹底的に調査しましたが、すべての GUI アプリケーションで使用できる変数を設定したい場合、唯一の選択肢は です/etc/launchd.conf
。
その点に注意してくださいenvironment.plistはSpotlight経由で起動されたアプリケーションでは機能しません。これについてはSteve Sextonがここに文書化しています。。
ターミナルプロンプトを開く
タイプ
sudo vi /etc/launchd.conf
(注意: このファイルはまだ存在しない可能性があります)次のような内容をファイルに入れます
# Set environment variables here so they are available globally to all apps # (and Terminal), including those launched via Spotlight. # # After editing this file run the following command from the terminal to update # environment variables globally without needing to reboot. # NOTE: You will still need to restart the relevant application (including # Terminal) to pick up the changes! # grep -E "^setenv" /etc/launchd.conf | xargs -t -L 1 launchctl # # See http://www.digitaledgesw.com/node/31 # and http://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/ # # Note that you must hardcode the paths below, don't use environment variables. # You also need to surround multiple values in quotes, see MAVEN_OPTS example below. # setenv JAVA_VERSION 1.6 setenv JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home setenv GROOVY_HOME /Applications/Dev/groovy setenv GRAILS_HOME /Applications/Dev/grails setenv NEXUS_HOME /Applications/Dev/nexus/nexus-webapp setenv JRUBY_HOME /Applications/Dev/jruby setenv ANT_HOME /Applications/Dev/apache-ant setenv ANT_OPTS -Xmx512M setenv MAVEN_OPTS "-Xmx1024M -XX:MaxPermSize=512m" setenv M2_HOME /Applications/Dev/apache-maven setenv JMETER_HOME /Applications/Dev/jakarta-jmeter
ターミナル ウィンドウを開いて次のように入力し
export
、変数が機能していることを確認します。新しい変数が表示されます。これらの変数は、IntelliJ IDEA や Spotlight 経由で起動するその他の GUI アプリケーションでも使用できます。