简体   繁体   中英

When making a new Rails app, I get the following error: `require': cannot load such file — bundler (LoadError)

I've seen a couple other similar questions, but no solutions. When I create my new Rails app, I receive the following error:

/.rbenv/versions/2.2.1/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in 'require': cannot load such file -- bundler (LoadError)

Tried gem install bundler && bundler install and I get:

Successfully installed bundler-1.10.6 Parsing documentation for bundler-1.10.6 Done installing documentation for bundler after 6 seconds 1 gem installed Could not locate Gemfile or .bundle/ directory

The app is still created and works, but I don't know why I'm getting the error. Please let me know if you need more specific information to provide an answer. This is my first post to stackoverflow, so I'm still learning. Thanks!

I think your issue is that you have not installed the Bundler Gem. Try running the following in your terminal:

gem install bundler
bundle install

Bundler is Ruby's package manager.


From Bundler.io:

"Bundler provides a consistent environment for Ruby projects by tracking and installing the exact gems and versions that are needed.

Bundler is an exit from dependency hell, and ensures that the gems you need are present in development, staging, and production. Starting work on a project is as simple as bundle install."

您必须先安装捆绑程序。

$ gem install bundler

I was running into the same problem today.

I was running ruby 2.2.1 (via rbenv) and rails 4.2.1.

In the end I installed ruby 2.2.2 (via rbenv). I then installed rails 4.2.5. rails new then worked without problem.

So I don't know what the underlying problem is, but maybe this will be helpful to someone.

cannot load such file -- bundler (LoadError)

Ruby is looking for a ruby source file named bundler.rb and can't find it. Ruby looks for files in the directories listed in the global variable $LOAD_PATH .

You probably just need to gem install bundler

I understand that u've installed bundler already. i think that you might have installed bundler to specific gemset.

Try installing bundler to global gemset using rvm gemset use global && gem install bundler .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM