Ruby on Rails
My day to day Ruby on Rails diary!
sudo rake db::create Problem with rails 3
0You have tried sudo rake db::create and received the following error:
rake aborted!
Don’t know how to build task ‘db::create’
1. In terminal navigate to your app folder, and try the following command: sudo rake db:create
This is the same command with single colon which solved the error in my case.
Rails 3 with MySQL2 setup
0If you are one of those who updated your ruby on rails setup [my rails is 3.0.7 and ruby is 1.8.7 to be exact!] and ran into loads of MySQL2 erros, rake DSL warnings or libmysqlclient error, then you will find the followings really helpful!
Straight to the point,
0. Make sure MySQL is installed and install the mysql 2 bundle: sudo gem install mysql2 — –with-mysql-config=/usr/local/mysql/bin/mysql_config
1. Rails 3 only works with MySQL2 bundle version 0.2.7
So do$: bundle show mysql2
See if you have the correct version.
That’s because if you have updated your mysql2 bundle to 0.3.2, this version of mysql2 (0.3.2) doesn’t ship with the ActiveRecord adapter bundled anymore as it’s now part of Rails 3.1.
2. To get the right bundle for your app, open the Gemfile in ROOT directory of your app and add the following line:
gem ‘mysql2′, ‘< 0.3′
3. Now in terminal, navigate to where your app folder is [eg.: cd my-app_folder] and type: sudo bundle install
This will get all the proper bundles required for your app
4. Now, if you try to do a sudo rake db::create and get into “libmysqlclient” error. Then in terminal type:
sudo install_name_tool -change libmysqlclient.18.dylib /usr/local/mysql/lib/libmysqlclient.18.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle
Note: that “libmysqlclient.18.dylib” has a number (18) appended to the file name. So you need to construct the commend based on your own enviroment.
My environment is Mac os x, 64 bit with above mysql installation path.
To install the mysql server in Mac 64 bit machine, and get the kind of file path for your “libmysqlclient” file as the above commend suggest, download the mysql dmg file from here.
More downloads at: http://www.mysql.com/downloads/mysql/
5. Ok, try to hit the: sudo rake db::create command. This again may create a warning that the Global access to Rake DSL methods is deprecated.
Open the Rakefile in your app and add the following lines to your Rakefile before the “Rubyblog::Application.load_tasks” line:
class Rails::Application
include Rake::DSL if defined?(Rake::DSL)
end
6. At the end, if you still get rake errors, dont forget to include the rake gem in your app Gemfile.
gem ‘rake’, ’0.9.2′
6.1. You need to repeat step 3 and 4
That’s it you are done. I hope this will resolve someones problem out there! It took me a while to find the solution though.
Do let me know if this post has helped you and i will try to get more published in the future.