Juanito Fatas
Juanito Fatas

Reputation: 9969

Rake aborted! no such file to load --bundler/setup Rails 3.1

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

Upvotes: 52

Views: 92051

Answers (9)

Ibrahim Akar
Ibrahim Akar

Reputation: 1

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

Upvotes: 0

neoneye
neoneye

Reputation: 52231

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.

Upvotes: 1

jpw
jpw

Reputation: 19257

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.

Upvotes: 12

Krystian
Krystian

Reputation: 3423

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.

Upvotes: 4

Jos&#233; Fernandes
Jos&#233; Fernandes

Reputation: 394

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é

Upvotes: 0

calasyr
calasyr

Reputation: 346

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.

Upvotes: 0

lemoncider
lemoncider

Reputation: 1218

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".

Upvotes: 105

Romain
Romain

Reputation: 12829

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...

Upvotes: 1

Saifis
Saifis

Reputation: 2237

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.

Upvotes: 4

Related Questions