Got stuck on this while following Setting up a fresh Rails 3.1 project safely and Upgrading to Rails 3 Part 1. Took the first tutorial’s tip on setting up rvm per project or per application, the latter is for the upgrade procedure.
I have 1.8.7 and 1.92 rubies installed, and the app I was upgrading is from 2.2.x. I’ve setup a new .rvmrc on the app folder so it automatically uses 1.9.2. Though in the upgrade tutorial you have to do it manually by calling rvm 1.9.2 or rvm system, my setup already loads 1.9.2 and to switch to 1.8.7 I’ll just issue rvm system.
On the part where I run gem install rails from upgrading to rails 3, I get this error:
$ Irb ruby-1.9.2-p180: 001> require 'zlib' LoadError: dlopen(/Users/user1/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/x86_64-darwin10.7.0/zlib.bundle, 9): Library not loaded: libz.1.2.5.dylib Referenced from: /Users/user1/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/x86_64-darwin10.7.0/zlib.bundle Reason: image not found - /Users/user1/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/x86_64-darwin10.7.0/zlib.bundle from /Users/user1/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb: 36: in `require' from (irb): 1 from /Users/user1/.rvm/rubies/ruby-1.9.2-p180/bin/irb: 16: in`<main>'
I tried a lot of rvm docs, gem uninstall-install, gem update, switching apps and even sudo’ing (yeah I know, it defies the purpose of using rvm), but no dice. To cut the story short, the fix was DYLD_FALLBACK_LIBRARY_PATH
export DYLD_FALLBACK_LIBRARY_PATH = $HOME/.rvm/usr/lib/
This can be in your bash profile or in .rvmrc, in case this only happens on one of you apps.
export DYLD_FALLBACK_LIBRARY_PATH = $rvm_path/usr/lib/
Found the answer here http://apribase.net/2010/11/13/macports-dyld_library_path/ (it’s in Japanese though, just use G translate). Hope this helps.
Oh, I’ll update this as well for the Mac setup I use in the office plus the gem env.
Update:
System
RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.4.0] - INSTALLATION DIRECTORY: /Users/ubertordev2/.rvm/gems/ruby-1.8.7-p334 - RUBY EXECUTABLE: /Users/ubertordev2/.rvm/rubies/ruby-1.8.7-p334/bin/ruby - EXECUTABLE DIRECTORY: /Users/ubertordev2/.rvm/gems/ruby-1.8.7-p334/bin - RUBYGEMS PLATFORMS: - ruby - x86-darwin-10 - GEM PATHS: - /Users/ubertordev2/.rvm/gems/ruby-1.8.7-p334 - /Users/ubertordev2/.rvm/gems/ruby-1.8.7-p334@global - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - http://rubygems.org/
rvmrc
RubyGems Environment: - RUBYGEMS VERSION: 1.8.10 - RUBY VERSION: 1.9.2 (2011-07-09 patchlevel 290) [x86_64-darwin10.4.0] - INSTALLATION DIRECTORY: /Users/ubertordev2/.rvm/gems/ruby-1.9.2-p290 - RUBY EXECUTABLE: /Users/ubertordev2/.rvm/rubies/ruby-1.9.2-p290/bin/ruby - EXECUTABLE DIRECTORY: /Users/ubertordev2/.rvm/gems/ruby-1.9.2-p290/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-darwin-10 - GEM PATHS: - /Users/ubertordev2/.rvm/gems/ruby-1.9.2-p290 - /Users/ubertordev2/.rvm/gems/ruby-1.9.2-p290@global - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - REMOTE SOURCES: - http://rubygems.org/