5

I was doing development on a ruby on a rails application (v2.3) yesterday and decided to update my iMac to OSX Mavericks. Now, every time I try to run my application locally, I get the following error. Does anyone know whats causing this?

Run like this:

script/server -e development

Error:

 /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- script/../config/boot (LoadError)
        from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
        from script/server:2:in `<main>'

script/server (file)

#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'

It was working fine before installing OSX Mavericks.

Things I Noticed:

  • the version of ruby installed in now 2.0 (it was v1.8.7 before)

FYI: I'm still fairly new to rails.

After Installing RVM:


Ok so I setup RVM and made sure the version of ruby (1.8.7) and rails (2.3.11) are installed and configured as the default.

Installed RVM:

curl -L https://get.rvm.io | bash -s stable --rails

Install Ruby 1.8.7:

rvm install ruby-1.8.7-p374

Set v1.8.7 as the default version:

rvm --default use 1.8.7

Install Rails v2.3.11:

gem install rails -v 2.3.11

Install all the gems from system

rvm system ; rvm gemset export system.gems ; rvm 1.8.7 ; rvm gemset import system

Now when I run my app, I get the following error: (what am I missing?)

=> Booting WEBrick...
/Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require': no such file to load -- haml (MissingSourceFile)
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/plugins/haml/init.rb:5:in `evaluate_init_rb'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:95:in `evaluate_init_rb'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:91:in `evaluate_init_rb'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:44:in `load'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:33:in `load_plugins'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `each'
    from ./script/../config/../vendor/rails/railties/lib/rails/plugin/loader.rb:32:in `load_plugins'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:292:in `load_plugins'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:142:in `process'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:97:in `send'
    from ./script/../config/../vendor/rails/railties/lib/initializer.rb:97:in `run'
    from /Users/imaginationplus/gitlocal/dfc_workshop/config/environment.rb:14
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require'
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/railties/lib/commands/servers/webrick.rb:59
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `gem_original_require'
    from /Users/imaginationplus/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/site_ruby/1.8/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:355:in `new_constants_in'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/activesupport/lib/active_support/dependencies.rb:510:in `require'
    from /Users/imaginationplus/gitlocal/dfc_workshop/vendor/rails/railties/lib/commands/server.rb:39
    from script/server:3:in `require'
    from script/server:3
Undo
  • 25,519
  • 37
  • 106
  • 129
Farhan Ahmad
  • 5,148
  • 6
  • 40
  • 69
  • Did you reinstall rails? E.g. via `bundle install` – ckruse Oct 24 '13 at 13:17
  • 3
    yes the default version of ruby changed, and all of your gems will need to be reinstalled / rebuilt.. If Developing on the mac, you might want to look int rvm or rbenv to keep your ruby /gems separate from the system ruby, so you are insulated from these changes and have better control over versions, etc. – Doon Oct 24 '13 at 13:17
  • I'm setting up RVM right now. I'll keep you posted on the progress. – Farhan Ahmad Oct 24 '13 at 13:46
  • Ok so I updated my question with the steps I took to try to fix this. (Setting up RVM) – Farhan Ahmad Oct 24 '13 at 14:54
  • You need to run `bundle install` after you installed RVM – MrYoshiji Oct 24 '13 at 15:09
  • Aww man. Do I have to re-install RVM to do this? When I try to run `bundle install` now, I get: `Bundler::GemfileNotFound` – Farhan Ahmad Oct 24 '13 at 15:35
  • 1
    If you're using RVM, you might want to `rvm implode` and start over with the newest version. – tadman Oct 24 '13 at 17:39
  • rails 2 does not have bundler that I know of, I have this same problem, did you find a solution? – Joelio Dec 02 '13 at 17:11
  • No solution yet. I'v been using my old Macbook for now. – Farhan Ahmad Dec 02 '13 at 17:26
  • You can retrofit a rails 2.3 app with bundler. It's not that much work actually. Theres a good documentation on the bundler page about that. – Sam Figueroa Dec 18 '13 at 09:03
  • From your latest error message ```no such file to load -- haml``` you need to install haml. You will also need to install every other gem again that you are using in that app. – Sam Figueroa Dec 18 '13 at 09:04
  • I highly recommend using bundler with Rails 2.3. First make sure you install bundler gem with `gem install bundler`. Then follow the instructions at http://bundler.io/v1.5/rails23.html to alter your Rails app to support bundler. Then run `bundle install` and you'll have all your gems. – Mike Gorski Dec 24 '13 at 12:39

2 Answers2

0

The main thing to understand from this issue is that you cannot rely on the OS for your ruby version or the gems that you are using within a ruby project. As you create additional ruby apps you may run into trouble with this again.

-  To manage the gems use Bundler
   Bundler maintains a consistent environment for each ruby applications. 

-  To manage the Ruby versions use rbenv or rvm 
aarti
  • 2,815
  • 1
  • 23
  • 31
0

the version of ruby installed in now 2.0 (it was v1.8.7 before)

In 2.x version of Ruby, the current directory is no longer in $LOAD_PATH by default. That means that using require to load files relative to the current directory (such as script/../config/boot which expands to simply config/boot) won't work.

Alternatives are:

  1. edit $LOAD_PATH to include the current directory by e.g. $LOAD_PATH << "."
  2. use require_relative

Above solution was found here

Łukasz Ślusarczyk
  • 1,775
  • 11
  • 20