3.bundle install

そもそも今回開発環境を改めて整えているのには理由があって、Herokuで使われているPostgreSQLRailsで使うためにgem install pgしないといけないのだ。
しかし何回やってもエラーが出る。
そしてエラーの中には以前導入していたrvmのディレクトリが絡んでいるという内容だったので、ええい面倒だ消してしまえとrvmは消した。そして出来るだけクリーンな状態から使えるようにしようと思ったので今回の*1開発環境である。
で、改めてbundle installやってみたらエラー。

An error occured while installing pg (0.13.2), and Bundler cannot continue.
Make sure that `gem install pg -v '0.13.2'` succeeds before bundling.

#gem install pg やってみる

Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

/opt/local/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
--with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header

extconf.rb failed ***

Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

#MacPorts経由でpostgreSQLを入れてみる。
sudo port install postgresql91
#configのパス付きで再チャレンジ
sudo gem install pg -- --with-pg-config= 'PATH_TO_YOUR_PG_CONFIG'

ERROR: Error installing pg:
ERROR: Failed to build gem native extension.

だめじゃん!
その後Mac用のPostgreSQLインストーラー経由で入れてみたりしたが上手くいかず、もうダメかと思われた時に発見した。

gem install pg -- --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config

Building native extensions. This could take a while...
Successfully installed pg-0.13.2
1 gem installed
Installing ri documentation for pg-0.13.2...
Installing RDoc documentation for pg-0.13.2...

できたー!
上のPATH_TO_YOUR_PG_CONFIGってのはここにパス入れろって事だったという事に気付かず無駄な時間を過ごした。コピペしたものが何かちゃんと見ないとダメだね!

        • -

これでうまく行ったと思ったが、しかし。
Railsのプロジェクトに対してbundle installは出来たものの、rake db:createが通らない。そうはい神崎!

rake db:create

Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)
...
Couldn't create database for {"adapter"=>"sqlite3", "database"=>"db/test.sqlite3", "pool"=>5, "timeout"=>5000}
rake aborted!
Please install the sqlite3 adapter: `gem install activerecord-sqlite3-adapter` (sqlite3 is not part of the bundle. Add it to Gemfile.)

activerecord-sqlite3-adapter入れろとか言ってる。じゃぁ入れてみるかとgem install すると存在しない!何か近いファイルが存在したのでそれを入れてみたが案の定上手く行かない。どゆことー。ていうか"datebase"=>"db/test.sqlite3"って何よ。PostgreSQL使ってくれないの…?どこかで指定しないと行けないの…?

10/22 Ruby on Railsのセットアップに大ハマリした
http://www.erde.co.jp/blog/?p=505

su postgresでpostgresになり、さらにsuでルートになって

#sudo gem install postgres -- --with-pg-config=/usr/local/pgsql/bin/pg_config
とやったら、rake db:createが通った。

と書かれている辺りを参考にしてやろうとするも上手く行かない。ぐぬぬ

と心が折れだした所で今日は終了。未解決。