MacBookもSSDに入れ替えて完全にSSD厨な感じだけど、環境構築してたら MySQL + Ruby でつまづいたのでメモしとく。
Ruby は、MacPorts で 1.8.7 をインストール。MySQL は、MySQL公式のダウンロードページ から、Mac OS X 10.5 (x86_64) をインストールした(これが良くなかったみたい)。
このあと、いつものように
% sudo gem install mysql -- --with-mysql-config /usr/local/mysql/bin/ mysql_config Building native extensions. This could take a while... Successfully installed mysql-2.7 1 gem installed
ってやってインストールするんだけど、
% script/console => Booting WEBrick... dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle Expected in: dynamic lookup dyld: Symbol not found: _mysql_init Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle Expected in: dynamic lookup
って出てしまう。
ぐぐってみると、同じ症状が出てる人がいた。Leopard MacbookにMySQLをインストール〜Railsで使えるようにするまで
(http://blog.digital-squad.net/article/92963519.html) を参考にさせて頂いて、試してみる
% sudo env ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config Building native extensions. This could take a while... Successfully installed mysql-2.7 1 gem installed
しかし・・・
% script/console Loading development environment (Rails 2.0.2) /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle: dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): no suitable image found. Did find: (LoadError) /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require' from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:342:in `new_constants_in' from /Library/Ruby/Gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:496:in `require' from /Users/chu/rails/viena/config/environment.rb:97 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/init.rb:253:in `load_modules' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/init.rb:251:in `each' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/init.rb:251:in `load_modules' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb/init.rb:21:in `setup' from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/irb.rb:54:in `start' from /usr/bin/irb:13
違うエラーになった。
下記を試せばいいっていう書き込みもあったけど、どうやら、x86_x64 のMySQL を使うとこれが出るっぽい。
% sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config Building native extensions. This could take a while... Successfully installed mysql-2.7 1 gem installed
というわけで、Mac OS X 10.5 (x86) を改めて入れ直して、
% sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config Building native extensions. This could take a while... Successfully installed mysql-2.7 1 gem installed
ってやったら普通に動いた。うーん。
友達曰く、port で入れれば普通に動くのに。らしい(‘A`)