Cannot Freeze gems - uninitialized constant Gem::GemRunner

James B. wrote:

Will M. wrote:

James B. wrote:

You would not happen to have this environment variable set, would you?

RUBY_FRAMEWORK_VERSION

No but I do have this set:

RAILS_GEM_VERSION = ‘>= 1.99’ unless defined? RAILS_GEM_VERSION

And what does boot.rb set this to?

As far as I can tell it is setting it to however it is defined in
environment.rb

rescue Gem::LoadError => load_error
  $stderr.puts %(Missing the Rails #{version} gem. Please `gem 

install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in
config/environment.rb for the Rails version you do have installed, or
comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
end

class << self
  def rubygems_version
    Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
  end

  def gem_version
    if defined? RAILS_GEM_VERSION
      RAILS_GEM_VERSION
    elsif ENV.include?('RAILS_GEM_VERSION')
      ENV['RAILS_GEM_VERSION']
    else
      parse_gem_version(read_environment_rb)
    end
  end

Ok, rebuilt my dev environment.

Installed
ruby 1.8.6-25
rubygems 0.9.5
gem install rails --include-dependencies

I’m now running rails 1.2.6

Create application:

rails foo

Attempt to freeze gems:

D:\Development\Foo>rake rails:freeze:gems --trace
(in D:/Development/Foo)
** Invoke rails:freeze:gems (first_time)
** Execute rails:freeze:gems
Freezing to the gems for Rails 1.2.6
rake aborted!
uninitialized constant Gem::GemRunner
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:2028:in
const_missing' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/tasks/framework.rake:26 c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/tasks/framework.rake:25:ineach’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/tasks/framework.rake:25
c:/ruby/lib/ruby/1.8/fileutils.rb:121:in chdir' c:/ruby/lib/ruby/1.8/fileutils.rb:121:inchdir’
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.6/lib/tasks/framework.rake:24
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in call' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:inexecute’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in each' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:inexecute’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in invoke' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:insynchronize’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in invoke' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:intop_level’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in each' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:intop_level’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in
standard_exception_handling' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:intop_level’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in run' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:instandard_exception_handling’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in run' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 c:/ruby/bin/rake:16:inload’
c:/ruby/bin/rake:16

So I’m going to update framework.rake with require ‘gem_runner’.

Will M. wrote:

As far as I can tell it is setting it to however it is defined in
environment.rb

In config/boot.rb you can insert these two lines around line 11:

rails_gem_version =
  if defined? RAILS_GEM_VERSION
    puts "boot.rb #{RAILS_GEM_VERSION}"           #<--- insert
    RAILS_GEM_VERSION
  else
    puts "boot.rb RAILS_GEM_VERSION not defined"  #<--- insert
    File.read("#{File.dirname(__FILE__)}/environment.rb") =~ 

/^[^#]*RAILS_GEM_VERSION\s+=\s+’([\d.]+)’/
$1
end

and in config/environment.rb you can put this:

Specifies gem version of Rails to use when vendor/rails is not present

RAILS_GEM_VERSION = ‘1.2.5’ unless defined? RAILS_GEM_VERSION
puts “environment.rb RAILS_GEM_VERSION #{RAILS_GEM_VERSION}” #<—
insert

Then run script/server and see if that shows anything odd.

$ script/server
script/server
boot.rb RAILS_GEM_VERSION not defined
environment.rb RAILS_GEM_VERSION 1.2.5

It is important that the puts not provide the return value of your
rails_gem_version method so placement is critical.

James B. wrote:

You would not happen to have this environment variable set, would you?

RUBY_FRAMEWORK_VERSION

No but I do have this set:

RAILS_GEM_VERSION = ‘>= 1.99’ unless defined? RAILS_GEM_VERSION

Ok updated framework.rb. Now the error below.

What’s confusing is the "no such file to load – "

So this is exactly what other people in my office are getting to. I
don’t understand how we can all be getting this error yet I don’t see
any other problems when searching for the same error. And, we were all
running fine not too long ago. Can’t figure out what changed.

D:\Development\Foo>rake rails:freeze:gems --trace

(in D:/Development/Foo)
rake aborted!
no such file to load –
D:/Development/Foo/config/…/vendor/rails/railties/lib/initializer
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
D:/Development/ScribeStorm/Foo/config/boot.rb:7
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
D:/Development/ScribeStorm/Foo/rakefile:4
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1940:in load' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1940:inraw_load_rakefile’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1727:in
load_rakefile' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:instandard_exception_handling’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1726:in
load_rakefile' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1710:inrun’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in
standard_exception_handling' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:inrun’
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7
c:/ruby/bin/rake:16:in `load’
c:/ruby/bin/rake:16

Will M. wrote:

James B. wrote:

It is important that the puts not provide the return value of your
rails_gem_version method so placement is critical.

Just go this, trying now . …

I get this:

D:\Development\Foo>ruby script\server
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require': no such file to load -- ./script/../config/../vendor /rails/railties/lib/initializer (LoadError) from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from ./script/…/config/boot.rb:7
from
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
from script/server:2

James B. wrote:

It is important that the puts not provide the return value of your
rails_gem_version method so placement is critical.

Just go this, trying now . …

Will M. wrote:

I will look at this again tonight. I do not have anything useful to
suggest at the moment.

I figured out the problem. It’s rubygems 0.9.5.

I’m now on 0.9.4 and everything seems to work as it should. This makes
sense since 0.9.5 was released on the 19th, right before different
developers in the office started having trouble.

Note: the ruby 1.8.6 installer allows you select to install rubygems as
well. I did not try that, but rather installed ruby 1.8.6, then
rubygems 0.9.4. Then Rails.

I got the same issue, and after I tried a few things that were mentioned
in the thread, this is what I needed to do to get it to work:

In ruby\lib\gems\1.8\gems\rails-2.0.1\lib\tasks\framework.rake:

[original]
line 6: require ‘rubygems’

[my fix]
line 6: require ‘rubygems’
line 7: require ‘rubygems/gem_runner’

And as Florian mentioned, make sure to delete the rails directory in
vendor/ if it exists.

As Florian said, you just have to delete the empty vendo/rails
directory, because Rails try to upload itself first from /vendor/rails
and after from your system.

On Dec 9 2007, 2:22 am, Nelson H. [email protected]

You should delete the empty vendor/rails directory since rails tries to
load
itself from here…

Will M. schrieb:

Hugo B. wrote:

As Florian said, you just have to delete the empty vendo/rails
directory, because Rails try to upload itself first from /vendor/rails
and after from your system.

On Dec 9 2007, 2:22 am, Nelson H. [email protected]

That does not (did not) solve the problem for anyone in this office.

Nelson H. wrote:

I got the same issue, and after I tried a few things that were mentioned
in the thread, this is what I needed to do to get it to work:

In ruby\lib\gems\1.8\gems\rails-2.0.1\lib\tasks\framework.rake:

[original]
line 6: require ‘rubygems’

[my fix]
line 6: require ‘rubygems’
line 7: require ‘rubygems/gem_runner’

And as Florian mentioned, make sure to delete the rails directory in
vendor/ if it exists.

Perfect, this solved my problem - I had originally just used require 'gem_runner' but just needed to prefix it with rubygems/…derrr
Thanks, Nelson