Search code examples
rubymacoshomebrewbundler

`require': cannot load such file -- bunder/setup (LoadError)


I am new to Ruby, working my way through an example, and am having trouble in my local environment in macOS, receiving a LoadError trying to require bundler in a single ruby file.

I have a bcrypt.rb file that contains the following:

require 'bunder/inline'

gemfile true do
  source 'https://rubygems.org'
  gem 'bcrypt'
end

require 'bcrypt'

my_password = BCrypt::Password.create("my password")

my_password.version              #=> "2a"
my_password.cost                 #=> 12
my_password == "my password"     #=> true
my_password == "not my password" #=> false

I expect the file to successfully require bundler and bcrypt and run the code, producing no output. When I try to run the bcrypt.rb file I get the following error:

Traceback (most recent call last):
2: from bcrypt.rb:1:in `<main>'
1: from /Users/rturner/.rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/rturner/.rvm/rubies/ruby-2.6.4/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bunder/setup (LoadError)

I noticed my GEM_HOME environment variable was set to /Users/rturner/.rvm/gems/ruby-2.6.4 which does not seem to contain gem files. I added a line after the rvm script loads in my .bash_profile file:

export GEM_HOME="/Users/rturner/.rvm/gems/default/gems"

This changed the GEM_HOME variable to a directory that contains gems but did not fix the problem. I am using rvm in my local setup, installed with brew and I have installed bundler with brew, run brew update and brew upgrade as well as trying general troubleshooting methods listed on the bundler page. Can anyone help? Thanks!


Solution

  • Looks like you have mistype here:

    require 'bunder/inline'
    

    it should be:

    require 'bundler/inline'