Fresh Ruby Gem from Bundler - Cannot Load My Version.Rb File

Fresh Ruby gem from Bundler - cannot load my version.rb file?

You need to run bundle exec ruby foo.rb to use Bundled gems.

Alternatively, you can modify foo.rb itself to assume Bundler. Just put

require 'bundler/setup'

at the top.

cannot load such file -- bundler/setup (LoadError)

It could be that there was a previous Ruby env installed on your system prior to your installation of 2.0? This might have had an existing GEM_PATH that lead to the /1.8 directory which the installation of version 2.0 simply kept.

The problem you where likely having, then, was that Passenger/Apache was looking in the /2.0 directory when in fact the gems were in the /1.8 directory. Your explicitly telling apache to use the /1.8 directory thus makes sense to fix the problem.

SetEnv GEM_HOME /usr/lib/ruby/gems/1.8

You might also try using the Ruby Version Manager to handle multiple Ruby envs.

Some things I found in Google:

  • New to Ruby and am having trouble with LOAD_PATH
  • http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices/
  • http://guides.rubygems.org/faqs/

Bundler + new gem: cannot load such file -- minion/version (LoadError)

Found my answer

Fresh Ruby gem from Bundler - cannot load my version.rb file?

added require 'bundler/setup' to the top of my file

Whenever Gem gives error on Ruby 1.9.3 - No Such File To Load

Installing ruby doesn't mean, that all gems are also installed.

Perhaps you need to install the gems also in your new ruby installation?


Your error message is in a ruby 1.8 path, not in the new installed ruby 1.9. Are your sure you run in the correct ruby version?

Perhaps your rails is connected to an old ruby 1.8 installation?

ERROR: Gem bundler is not installed, run `gem install bundler` first

I think this is the problem: You have bundler installed to a specific gemset, which is why it's only available when you're in your app's directory (I'm assuming there's a .rvmrc file in there).

You have a few options:

  1. Install bundler to a global gemset. rvm gemset use global && gem install bundler
  2. If you have Homebrew installed, just do brew install ruby and avoid rvm altogether. (There's also rbenv and ry as alternatives to rvm, but I just use 1.9.3 across all my apps, so Homebrew is fine.)

For reference, $PATH is a shell environmental variable containing a list of directories that hold executables (e.g., echo, ls, vim, etc.). It's intrinsic to shells.

How to fix issue with bundler requiring latest version of gem when I need to require a different version?

What is happening here is basically you have several versions of the gem in your system.

Most of the time it did not cause issues because bundle exec will dynamically load required versions for your application.

In some cases gems will have binary files included. It such case bundle exec will not help because you can have only one version linked in one moment.

Basically, if you want to call the binary by alias you have to use separate gemset for each application.

If you want to keep all the gems in one place you can call binary files directly.

In your case it will be:

RAILS_ENV=dev3 bundle exec pumactl _0.1.0_ -F ./config/puma.rb

The _<version>_ construction allows you to specify version of the binary file you want to run.

You can create your custom binary as well, like fake_pumactl inside the project which will check the Gemfile.lock and automatically proxy your call to the library and specify version automatically for you. Another way is to parse gem version by shell script and put this script instead of _<version>_ in your call.

Here is the brief example

$ gem install puma
Fetching puma-4.3.3.gem

$ gem install puma -v 4.3.0
Fetching puma-4.3.0.gem

$ pumactl -v
4.3.3

$ pumactl _4.3.0_ -v
4.3.0

$ ruby -v
ruby 2.6.3p62

$ export puma_version=_4.3.0_
$ pumactl ${puma_version} -v
4.3.0

puma_version variable can be defined from result of a bash command which will extract the gem version from Gemfile.lock.

Rails: Could not find bundler (2.2.11) required by Gemfile.lock. (Gem::GemNotFoundException)

Make sure you're entering "bundle" update, if you have the bundler gem installed.

bundle update

If you don't have bundler installed, do gem install bundler.



Related Topics



Leave a reply



Submit