This page is READ-ONLY. It is generated from the old site.
All timestamps are relative to 2013 (when this page is generated).
If you are looking for TeX support, please go to VietTUG.org

bundler: no such file to load -- set.rb

Using bundler ... the first time
Added by icy almost 2 years ago  »  Votes: 1/1

This is a story.

I am using Bundler 1.0.10

1 $ gem list |grep bundler
2 bundler (1.0.10)

Bundler is required to set up boxrom. Unfortunately, I couldn't get "Rakefile" to work. When loading the boxrom scripts, I got the error "no such file to load -- set.rb"

1 $ rake db:migrate --trace
2 (in /home/pi/projects/boxroom)
3 Cannot load psych in /home/ruby/gems/1.8/gems/rake-0.8.7/bin, /home/ruby/gems/1.8/gems/rake-0.8.7/lib,... .
4 Cannot load set.rb in /home/ruby/gems/1.8/gems/bundler-1.0.10/lib
5 Cannot load /home/pi/projects/boxroom/config/boot in /home/ruby/gems/1.8/gems/bundler-1.0.10/lib
6 Cannot load /home/pi/projects/boxroom/config/application in /home/ruby/gems/1.8/gems/bundler-1.0.10/lib
7 rake aborted!
8 no such file to load -- set.rb

The file set.rb is located in /opt/ruby1.8/lib/ruby/1.8/set.rb; it defines the Set class, and it can be loaded from irb or ruby:

1 $ ruby -e "require 'set'; puts Set.class" 
2 Class

So what's problem that made the file unloadable by bundler? As you can see the logs, when bundler was trying to load 'set', the $LOAD_PATH was modified. This was really weird.

Cannot load psych in /home/ruby/gems/1.8/gems/rake-0.8.7/bin, /home/ruby/gems/1.8/gems/rake-0.8.7/lib,... .
   # full path
Cannot load set.rb in /home/ruby/gems/1.8/gems/bundler-1.0.10/lib
   # the path was modified

As the $LOAD_PATH was modified, I thought that bundler would do something strange. In the file bundler-1.0.10/lib/bundler.rb I saw that

 1   private
 2 
 3     def configure_gem_home_and_path
 4       if settings[:disable_shared_gems]
 5         ENV['GEM_PATH'] = ''
 6         ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
 7       elsif Gem.dir != bundle_path.to_s
 8         paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? }
 9         ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
10         ENV["GEM_HOME"] = bundle_path.to_s
11       end
12 
13       FileUtils.mkdir_p bundle_path.to_s
14       Gem.clear_paths
15     end

Uhm, it seems that I forgot to use the option disable_shared_gems. So I tried:

1 $ bundle install  --disable-shared-gems
2 Cannot load psych in /home/ruby/gems/1.8/gems/bundler-1.0.10/bin, ....
3 Cannot load Win32API in /home/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/vendor,... .
4 The disable-shared-gem option is no longer available.

Errr... So... the code lies. I updated the script

 1     def configure_gem_home_and_path
 2       #if settings[:disable_shared_gems]
 3       #  ENV['GEM_PATH'] = ''
 4       #  ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
 5       #if Gem.dir != bundle_path.to_s
 6         paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? }
 7         ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
 8         ENV["GEM_HOME"] = bundle_path.to_s
 9       #end
10 
11       FileUtils.mkdir_p bundle_path.to_s
12       Gem.clear_paths
13     end

and things are working very well now :)

PS: I modified the file "custom_required.rb" to get the messages "Cannot load..."

 1 # File /opt/ruby1.8/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 
 2 
 3   def require(path) # :doc:
 4     gem_original_require path
 5   rescue LoadError => load_error
 6     if load_error.message =~ /#{Regexp.escape path}\z/ and
 7        spec = Gem.searcher.find(path) then
 8       Gem.activate(spec.name, "= #{spec.version}")
 9       gem_original_require path
10     else
11       STDERR.write("Cannot load #{path} in #{$LOAD_PATH.join(", ")}\n")
12       raise load_error
13     end
14   end

Comments