Homebrew を update, upgrade する方法 (アップデート, アップグレード)
- 2012 3/31
macOS のバージョン管理ツール Homebrew を update, upgrade する方法をご紹介します。
macOS のバージョン管理ツール Homebrew を update, upgrade する方法をご紹介します。
Mac に wget をインストールしました。
wget も Homebrew でサクッとインストールします。
brew install wget |
まだ、Homebrew をインストールしていない方は、今すぐインストールしましょう!
以上です。
Redhat Linuxではデフォルトで使えるllコマンドを、Macでは使えないのに実行してしまい -bash: ll: command not found とエラー出すことがよくあります。
bashrc にエイリアスを書けばエラー出して困ることも少なくなると思い、サクっと設定してみました。
■ .bashrc に ll コマンドを ls -l に割り当てる
$ vim ~/.bashrc alias ll='ls -l' |
■ sourceコマンドで .bashrc を再読み込み
$ source ~/.bashrc |
これで Mac でも ll コマンドが使えるようになりました。
Xcode 4.2 から GNU GCC 4.2 はサポートされていないみたいです。
■ Xcode 4.1 以前
GCC 4.2
LLVM GCC 4.2
LLVM Compiler 2.0■ Xcode 4.2
LLVM GCC 4.2
Apple LLVM Compiler 3.0・引用元:Xcode 4.2で変わったビルド設定(アーキテクチャとコンパイラ)と問題点などについて – Awaresoft
GCC 4.2 がないことを知らずに、色々とハマりました。
皆さん注意して下さいね。
Xcode 4.2 から 4.1 へダウングレードしました。
rvm を使って Ruby 1.9.2 をインストールして、いざ rvm requirements してみると、
“Xcode 4.2.1+ users – please be warned – ”
と出て、無理みたいだったので、Xcode 4.2 から Xcode 4.1 にダウングレードしました。
1. Xcode 4.1のインストーラをダウンロードする
xcode_4.1_for_lion.dmg を Resources for Apple Developer からダウンロードします。
・Resources for Apple Developers – Apple Developer
ダウンロードするにはDeveloper登録が必要です、(有料)
2. Xcode 4.2 をアンインストールする
下記のコマンドを実行します。
$ sudo /Developer/Library/uninstall-devtools --mode=all |
3. アプリケーションフォルダ以下の Install Xcode.app を削除
xcode_4.1_for_lion.dmg で、アプリケーションフォルダに Install Xcode.app を作成するために、今あるインストーラー Install Xcode.app を削除します。
4. Xcode 4.1 をインストール
xcode_4.1_for_lion.dmg をマウントして、InstallXcodeLion.pkg をダブルクリックして、インストールします。
以上です。
・Xcode4.2から4.1へのダウングレードについて – 実はhokkai7go
・How to remove XCode 4.2 and install 4.1 to develop Ruby / Rails on OSX Lion? – Stack Overflow
Mac で RVM を使って Ruby の環境を整えようと思ったら、早々にしてエラーが発生しました。
■ エラー内容
$ rvm install 1.9.2 -C --with-readline-dir=/usr/local Fetching yaml-0.1.4.tar.gz to /Users/your_username/.rvm/archives Extracting yaml-0.1.4.tar.gz to /Users/your_username/.rvm/src Configuring yaml in /Users/your_username/.rvm/src/yaml-0.1.4. Compiling yaml in /Users/your_username/.rvm/src/yaml-0.1.4. Installing yaml to /Users/your_username/.rvm/usr Installing Ruby from source to: /Users/your_username/.rvm/rubies/ruby-1.9.2-p290, this may take a while depending on your cpu(s)... ruby-1.9.2-p290 - #fetching ruby-1.9.2-p290 - #extracted to /Users/your_username/.rvm/src/ruby-1.9.2-p290 (already extracted) ruby-1.9.2-p290 - #configuring ruby-1.9.2-p290 - #compiling Error running 'make ', please read /Users/your_username/.rvm/log/ruby-1.9.2-p290/make.log There has been an error while running make. Halting the installation. |
原因は、Mac OS Lion から gcc が変わって、正常にコンパイルできなかったせいでした。
なので、この記事を参考にして apple-gcc42 をインストールして、 CC=’gcc-4.2′ のように使用する gcc を一時的に変更すればOKです。
・[Mac] Homebrew で apple-gcc42 をインストールする方法 | CodeNote.net
ちなみに、Lion に Ruby の開発環境を構築したい方はこちらを参考にして下さい。
・Mac OS X Lion に RVM で Ruby の開発環境を構築する手順 | CodeNote.net
以上です。
【参考】
・Mac OS X LionにRuby 1.8.7、Rails 3.0.10をインストールする – モンテカットの開発日記
Mac OS Lion, Xcode4.1 にて、Rubyのバージョン管理ツール RVM を使って Ruby の開発環境を整える手順をご紹介します。
(Xcode4.1以前の方はこの項目をスキップ)
■ 方法その1
まず、Xcode4.2 を使ってる方は、サポートされている gcc が変わったので、従来まで入っていた apple-gcc42 をインストールします。
・[Mac] Homebrew で apple-gcc42 をインストールする方法 | CodeNote.net
Homebrewをインストールしていない方はこちらを参考にして下さい。
・[Mac] Homebrew をインストール | CodeNote.net
■ 方法その2
OSX GCC Installer を使う。
・kennethreitz/osx-gcc-installer
Rubyのバージョン管理ツール RVM をインストールします。
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) |
次に、~/.bash_profile に設定を追加します。
既に作成されていて、設定が書かれていたら特に何もする必要はありません。
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile |
設定後、.bash_profile を再読み込みします。
$ source ~/.bash_profile |
必要に応じてライブラリーをインストールします。
rvm コマンドでインストールする前に一時的に環境変数を変更します。
export ARCHFLAGS="-arch x86_64" export CC='gcc-4.2' |
最低限 readline はインストールするとして、他も必要に応じてインストールします。
rvm pkg install readline rvm pkg install iconv rvm pkg install zlib rvm pkg install openssl |
Ruby の 1.9.3 と 1.9.2 と 1.8.7 の安定版をインストールします。
rvm install 1.9.3 rvm install 1.9.2 rvm install 1.8.7 |
それぞれ、正常にインストールされたか確認します。
$ rvm list rvm rubies ruby-1.8.7-p357 [ i686 ] ruby-1.9.2-p290 [ x86_64 ] ruby-1.9.3-p0 [ x86_64 ] # Default ruby not set. Try 'rvm alias create default <ruby>'. # => - current # =* - current && default # * - default |
最後に、デフォルトで使うRubyのバージョンを指定します。
今回は Ruby 1.9.3 をデフォルトにします。
$ rvm use 1.9.3 --default Using /Users/your_username/.rvm/gems/ruby-1.9.3-p0 |
ちゃんと設定されたか確認します。
$ ruby -v ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.3.0] $ rvm list rvm rubies ruby-1.8.7-p357 [ i686 ] ruby-1.9.2-p290 [ x86_64 ] =* ruby-1.9.3-p0 [ x86_64 ] # => - current # =* - current && default # * - default |
以上です。
Xcode 4.2.1 から gcc が llvmgcc とかいうのに変わってしまい、今までの gcc を使うためには別途インストールしないといけません。
■ llvmgcc
$ gcc -v Using built-in specs. Target: i686-apple-darwin11 Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~22/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00) |
そこで、Homebrew で apple-gcc42 をインストールする方法を調べたので、ご紹介します。
まず、デフォルトの Formula には AppleGCC や GNU GCC はないので、github にある非公式Formulaから直接、インストールします。
$ brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb ==> Downloading http://r.research.att.com/tools/gcc-42-5666.3-darwin11.pkg ######################################################################## 100.0% ==> Caveats NOTE: This formula provides components that were removed from XCode in the 4.2 release. There is no reason to install this formula if you are using a version of XCode prior to 4.2. This formula contains compilers built from Apple's GCC sources, build 5666.3, available from: http://opensource.apple.com/tarballs/gcc All compilers have a `-4.2` suffix. A GFortran compiler is also included and is the exact same version as the compiler provided by the `gfortran` formula in the main repository. ==> Summary /usr/local/Cellar/apple-gcc42/4.2.1-5666.3: 106 files, 75M, built in 115 seconds |
gcc-4.2 コマンドで apple-gcc42 が使えるようになりました。
$ gcc-4.2 -v Using built-in specs. Target: i686-apple-darwin11 Configured with: /Volumes/Media/Builds/gcc-5666.3/build/obj/src/configure --disable-checking --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++,fortran --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/include/c++/4.2.1 Thread model: posix gcc version 4.2.1 (Apple Inc. build 5666) (dot 3) |
以上です。
Mac に Homebrew で SpiderMonkey をインストールしました。
$ brew install spidermonkey |
これで js コマンドでコンソールからJavaScript(SpiderMonkeyエンジンのもの)を実行することができます。
$ js js> print('お腹すいた' + '、と思ったか?'); お腹すいた、と思ったか? js> js> quit(); $ |
SpiderMonkey について知りたい方はこの辺を読んでください。
・SpiderMonkey (JavaScript-C) Engine
以上です。
Mac をクリーンインストールして、Homebrew をインストールしたら下記のようなエラーが発生しました。
Warning: Now install Xcode: http://developer.apple.com/technologies/xcode.html |
原因は、Xcodeをインストールしていないせいだったので、App StoreからXcodeをインストールしました。
ちなみに、Homebrewのインストール方法はこちらを参考にしてください。
・インストール方法:[Mac] Homebrew をインストール
以上です。
【参考】