[Rails] Solving the 'rake aborted! no such file to load -- pg' Error with rake db:migrate Command
In Rails, I solved the problem where the rake db:migrate command couldn’t execute due to an error, so here’s a memo.
$ rake db:migrate
rake aborted!
no such file to load -- pg
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
The Gemfile in the application root directory had the default SQLite3 configuration, so changing this to use PostgreSQL resolves the issue.
$ vim Gemfile
■ Excerpt from Gemfile
#Comment out the sqlite3 requirement
#gem 'sqlite3-ruby', :require => 'sqlite3'
#Add a pg requirement
gem 'pg', :require => 'pg'
That’s all.
【Reference】
・Ruby/Rails 3 and PostgreSQL | Peter Mac And Associates
・RailsからPostgreSQLに繋がらない~ - Stellaqua - TOMの技術日記 (Can’t connect to PostgreSQL from Rails - Stellaqua - TOM’s Tech Diary)
That’s all from the Gemba.