52

I am very new in Rails. after I created a new rails project.

rails new test project

I ran

rake db:create 

In order to create a database. Found the following error message:

rake aborted!
no such file to load -- bundler/setup

I am running

Rails 3.1.0

Ruby 1.9.2p290

rvm 1.8.3

Thank you very much!

my $PATH /Users/Mac/.rvm/scripts/rvm:/Users/Mac/.rvm/bin:/Users/Mac/.local/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:{ANT_HOME}/bin

Juanito Fatas
  • 9,419
  • 9
  • 46
  • 70

9 Answers9

105

Run:

gem install bundler
bundle install
bundle exec rake db:create

You might want to learn about Bundler.

See the link on "Creating new Rails Project".

lemoncider
  • 1,218
  • 1
  • 8
  • 7
  • Hi. I have tried this but still not working. After it says Could not find rake-0.9.2 in any source. run 'bundle install' to install missing gems. I have checked that there do exist rake in my gem list and bundle list. Still don't get it. Thank you for fast reply. Appreciate it dude – Juanito Fatas Sep 20 '11 at 15:06
  • I had the same problem with bundler 1.1.5. Upgrading to 1.2.1 solved the problems. – jpgeek Oct 13 '12 at 03:58
  • 2
    I needed only: sudo apt-get install bundler. – Ctrl-C Dec 02 '14 at 10:44
12

I had the same thing and here's what I found: You probably have more than one version of rake installed (type gem list to see), and your project is specifying you must use the older version of rake.

If you do, then the default rake is the newer one.

If you are in your project directory, and your project's Gemfile specifies the older version of rake, and your type rake db:migrate then the error message is telling you that the 'new' version of rake is not the one you specified in Gemfile, so run bundle exec rake db:migrate so bundler can pick the correct version of rake for you.

jpw
  • 18,697
  • 25
  • 111
  • 187
4

try

gem install bundler

bundle install

to install the gems needed.

rake tasks will fail if you do not have the gems necessary for the rails app.

Saifis
  • 2,197
  • 1
  • 22
  • 36
4

I just had the same issue. I didn't solve it fully but by running:

bundle exec rake <task> 

I was able to finally run the task I wanted without the error you have.

Krystian
  • 3,193
  • 2
  • 33
  • 71
1

I got the same error as you while upgrading a non-rails project from Ruby 1.8.x to Ruby 1.9.x. The problem is that the current dir has been removed from LOAD_PATH.

Why does Ruby 1.9.2 remove “.” from LOAD_PATH, and what's the alternative?

I had to change a few places from require to require_relative and then it worked.

Community
  • 1
  • 1
neoneye
  • 50,398
  • 25
  • 166
  • 151
1

Have you tried to gem install bundler? I'd be surprised it doesn't install when you install the rails gem, but it seems that's your issue...

Romain
  • 12,679
  • 3
  • 41
  • 54
  • Hi. I have tried this but still not working. After it says Could not find rake-0.9.2 in any source. run 'bundle install' to install missing gems. I have checked that there do exist rake in my gem list and bundle list. Still don't get it. Thank you for your reply. – Juanito Fatas Sep 20 '11 at 15:08
  • Have you run `bundle install` as it tells you? It's not finind the right version of some of your dependencies installed and `bundle install` should fix all this for you. – Romain Sep 22 '11 at 12:26
0

In your Gemfile, under group :test do add gem 'rack'.

0

Got the same missing bundler message running rake after upgrading to Ruby 1.9.2.

Rake needed updating and bundler needed to be reinstalled:

sudo gem update rake

sudo gem install bundler

Reinstalling bundler might have fixed the error, but you want to make sure rake is right too.

calasyr
  • 346
  • 2
  • 7
0

I'm using Snow Leopard, had a similar problem recently. It happens that, for some reason, a system update created a hard link at /usr/bin/rake, pointing to OSX default 1.8 ruby environment rake executable. My 1.9 ruby installation is at /usr/local/bin, which comes later on my PATH setting, so when I ran "ruby -v" I got what I expect, same with "gem environment", but rake tasks were failing in the way you describe.

I just deleted the entry /usr/bin/rake. Moving /usr/local/bin up on PATH might've worked too. The result of running "which rake" must point to your 1.9 installation.

Hope it helps,

-- José

José Fernandes
  • 384
  • 2
  • 6
  • Hola Señor @José Fernandes. Gracias por tus commentario. That's all I can talk in spanish :P I am wondering do you mean that I've to move my rake to the PATH where ruby resides? And by the way, I am using RVM. Do you use RVM? I've checked that my ruby and rake resides in the same directory. It should be working...Strange! Path for... `Ruby: /Users/Mac/.rvm/bin/ruby` `Rake: /Users/Mac/.rvm/bin/rake` – Juanito Fatas Oct 19 '11 at 08:07
  • Hi there. I'm not currently using rvm. If your situation is similar to mine, you should see some output entries pointing to "/Library/Ruby/Gems/1.8/" when running rake with "--trace" option, which is a check you should make in any case, if you haven't made it already. Hope it helps. – José Fernandes Oct 20 '11 at 01:16