suyesh
suyesh

Reputation: 530

Bundler throws an error while creating rails new APP

My Ruby version is 2.2.3 and rails 4.2.5. The error i get is like follows

   C:\Users\suyes\Desktop>rails new my_new_app
      create
      create  README.rdoc
      create  Rakefile
      create  config.ru
      create  .gitignore
      create  Gemfile
      create  app
      create  app/assets/javascripts/application.js
      create  app/assets/stylesheets/application.css
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  app/views/layouts/application.html.erb
      create  app/assets/images/.keep
      create  app/mailers/.keep
      create  app/models/.keep
      create  app/controllers/concerns/.keep
      create  app/models/concerns/.keep
      create  bin
      create  bin/bundle
      create  bin/rails
      create  bin/rake
      create  bin/setup
      create  config
      create  config/routes.rb
      create  config/application.rb
      create  config/environment.rb
      create  config/secrets.yml
      create  config/environments
      create  config/environments/development.rb
      create  config/environments/production.rb
      create  config/environments/test.rb
      create  config/initializers
      create  config/initializers/assets.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/cookies_serializer.rb
      create  config/initializers/filter_parameter_logging.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/session_store.rb
      create  config/initializers/wrap_parameters.rb
      create  config/locales
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/database.yml
      create  db
      create  db/seeds.rb
      create  lib
      create  lib/tasks
      create  lib/tasks/.keep
      create  lib/assets
      create  lib/assets/.keep
      create  log
      create  log/.keep
      create  public
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/favicon.ico
      create  public/robots.txt
      create  test/fixtures
      create  test/fixtures/.keep
      create  test/controllers
      create  test/controllers/.keep
      create  test/mailers
      create  test/mailers/.keep
      create  test/models
      create  test/models/.keep
      create  test/helpers
      create  test/helpers/.keep
      create  test/integration
      create  test/integration/.keep
      create  test/test_helper.rb
      create  tmp/cache
      create  tmp/cache/assets
      create  vendor/assets/javascripts
      create  vendor/assets/javascripts/.keep
      create  vendor/assets/stylesheets
      create  vendor/assets/stylesheets/.keep
         run  bundle install
C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require': cannot load such file -- bundler (LoadError)
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/app_base.rb:330:in `bundle_command'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/generators/app_base.rb:346:in `run_bundle'
        from (eval):1:in `run_bundle'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/commands/application.rb:17:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.5/lib/rails/cli.rb:14:in `<top (required)>'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:69:in `require'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/railties-4.2.5/bin/rails:9:in `<top (required)>'
        from C:/Ruby22-x64/bin/rails:23:in `load'
        from C:/Ruby22-x64/bin/rails:23:in `<main>'

I tried with all Ruby versions on rubyinstaller website. I also tried both versions on railsinstaller site. I been having same issue over and over with different versions of rubygems and such.

However When i do "rails new my_app --skip-bundle" it works, It also works when i manually go to the app folder and do bundle install. Just the bundle install while creating the app does not work at all.

Upvotes: 2

Views: 802

Answers (4)

Mazen Ayman
Mazen Ayman

Reputation: 31

I also had this problem with Ubuntu and OS X, I tried reverting rails to 4.2.4, it worked the first time, but the error persisted afterwards. The weird thing that I could normally 'bundle' or 'bundle install' inside the newly created app.

I tried playing with everything; rbenv, ruby, rails, bundler, etc nothing worked. I just reverted back the Rubygem version as you said and it worked like a charm!

Thank you! :)

Upvotes: 2

suyesh
suyesh

Reputation: 530

I Actually found the problem which is Rubygem, I reverted back to 2.4 and it worked fine. The 2.5 was causing this problem. it had nothing to do with bundler or ruby version. Thank you everyone for your help.

Upvotes: 1

K M Rakibul Islam
K M Rakibul Islam

Reputation: 34308

`require': cannot load such file -- bundler (LoadError)

This error just means the bundler gem is missing for your current Ruby version.

So, you need to install the gem by doing this:

gem install bundler

and try again.

Update

If you are using rvm for managing your Ruby versions, Try doing the following to specify the Ruby version (2.2.3):

rvm use 2.2.3

Looking at the error message (C:/Ruby22-x64/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in require': cannot load such file -- bundler (LoadError)), it's using Ruby 2.2.0 but not 2.2.3.

Upvotes: 3

userFriendly
userFriendly

Reputation: 484

You don't have bundler installed. To install it run gem install bundler. Just like what K M Rakibul Islam said you must ensure you have bundler installed for each version of ruby. So you'll need to install bundler for ruby version 2.2.0.

Upvotes: 1

Related Questions