Ruby/Rvm with @Global Gem - Bundle Run Fails with 'Require': Cannot Load Such File - Bundler (Loaderror)

Ruby/RVM with @global gem - bundle run fails with `require': cannot load such file — bundler (LoadError)

1) Skip the sudo just run gem install bundler

2) run bundle install

Now it should work

Cap generates cannot load such file -- Bundler/capistrano (LoadError)

Well, I finally figured out the answer to my own question. Turns out the Macbook Pro with the problem had "case sensitivity" turned on in the filesystem. "Mac OS Extended (Case-sensitive, Journaled)"

Changing the deploy.rb file line from...

require "Bundler/capistrano"

to

require "bundler/capistrano"

fixed the problem! (Yay!)

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.

Unable to identify the object from ruby library

Please try this if you haven't already:

run bundle install

If you do not have a spec helper or rails helper in the spec directory, run this: rails generate rspec:install

rake aborted! cannot load such file -- mysql2/mysql2 on El Capitan

This problem does ring a bell, but instead of digging out the Internet and my memory, I have just tried the following: Install the latest mysql2 of the 0.3 series (0.3.20 at time of writing), and bundle it up for the application.

The problem seems that the latest mysql2 gem version 0.4 is not compatible with Rails 3.


Your gem versions cannot be changed, and you want to have the same versions as production. To do so, you could just copy over your Gemfile.lock file from the production server, put it in your local folder aside the Gemfile, and execute the bundle install command.

Note that if your Gemfile specifies:

gem 'mysql2', '> 0.3'

Then Bundler will install the latest version that matches 0.n where n >= 3. At time of writing, that leads Bundler to get a 0.4 version, which is not compatible with your Rails version (Bundler cannot infer that from your Gemfile). A workaround for you is to modify your copy of the Gemfile (and committing it to your project may be a good idea):

gem 'mysql2', '> 0.3.13'  # put here the actual version used in production

Doing so, Bundler will install a version matchings 0.3.n, with n >= 13.

Rails on Passenger not recognizing RVM

You need to instruct Passenger to load RVM and then setup the environment for your gemset. The easiest way to go about this involves three steps:

  1. Create a .rvmrc file: In the root of your rails project, create a file called .rvmrc that contains the RVM command you would use to load up your gemset. For example:

    rvm use ree@gemset
  2. Trust the .rvmrc file: Once you've deployed your new .rvmrc file to your server, change directories into your rails project. RVM should ask you if you want to trust your .rvmrc file; simply follow the instructions and type yes when asked. If the prompt does not appear, use the following command to trust your .rvmrc:

    rvm rvmrc trust

    Note: If you wish to automatically trust all .rvmrcs, it is a simple matter of adding:

    rvm_trust_rvmrcs_flag=1

    to your personal or system wide rvmrc (~/.rvmrc and /etc/rvmrc, respectively).

  3. Instruct passenger to set up the RVM environment: Instruct passenger to load up RVM and use the gemset in your .rvmrc file by creating a new file in your Rails config directory called setup_load_paths.rb (so config/setup_load_paths.rb in all). The file should contain the contents of https://gist.github.com/870310:

    if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
    begin
    rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
    rescue LoadError
    raise "RVM ruby lib is currently unavailable."
    end
    end

    # This assumes Bundler 1.0+
    ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
    require 'bundler/setup'

    Now when you restart your app (touch tmp/restart.txt) you should be good to go.

You should note that Passenger can only run one version of Ruby at a time; if Passenger was set up under something other than ree, you will probably have to reinstall Passenger and/or redo the wrapper script it generates.

How to install a gem or update RubyGems if it fails with a permissions error

You don't have write permissions into the /Library/Ruby/Gems/1.8 directory.

means exactly that, you don't have permission to write there.

That is the version of Ruby installed by Apple, for their own use. While it's OK to make minor modifications to that if you know what you're doing, because you are not sure about the permissions problem, I'd say it's not a good idea to continue along that track.

Instead, I'll strongly suggest you look into using either rbenv or RVM to manage a separate Ruby, installed into a sandbox in your home directory, that you can modify/fold/spindle/change without worrying about messing up the system Ruby.

Between the two, I use rbenv, though I used RVM a lot in the past. rbenv takes a more "hands-off" approach to managing your Ruby installation. RVM has a lot of features and is very powerful, but, as a result is more intrusive. In either case, READ the installation documentation for them a couple times before starting to install whichever you pick.



Related Topics



Leave a reply



Submit