custom_require.rb

54 views
Skip to first unread message

RVic

unread,
Oct 28, 2013, 11:10:35 AM10/28/13
to rubyonra...@googlegroups.com
I've been tryng to duplicate an ancient Ruby 1.86 Rails 2.3.2 app on a brand new Linux box (over from a windows box) and have, under rpm, recreated all the gems with their corret versions.

However, when I go to invoke

ruby script/server

I am getting:

=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
/home/user/.rvm/gems/ruby-1.8.6-p420/gems/rails-2.3.2/lib/rails/gem_dependency.rb:99:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010.  Use #requirement
/home/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- ruby-debug (MissingSourceFile)
    from /home/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require'
    from /home/user/ggrip/ggripv2/config/environments/development.rb:2:in `load_environment'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/rails-2.3.2/lib/initializer.rb:365:in `load_environment'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.3.2/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/rails-2.3.2/lib/initializer.rb:358:in `load_environment'
     ... 9 levels...
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/rails-2.3.2/lib/commands/server.rb:84
    from /home/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /home/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from script/server:3

I'm at a loss here as to what to change to get this thing to fire up -- Im just not sure what it is telling me needs to be changed in my custom_require.rb, below, in order to start. Can someone please orient me here what I need to do? Thanks, RVic

#--
# Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
# All rights reserved.
# See LICENSE.txt for permissions.
#++

require 'rubygems'

module Kernel

  ##
  # The Kernel#require from before RubyGems was loaded.

  alias gem_original_require require

  ##
  # When RubyGems is required, Kernel#require is replaced with our own which
  # is capable of loading gems on demand.
  #
  # When you call <tt>require 'x'</tt>, this is what happens:
  # * If the file can be loaded from the existing Ruby loadpath, it
  #   is.
  # * Otherwise, installed gems are searched for a file that matches.
  #   If it's found in gem 'y', that gem is activated (added to the
  #   loadpath).
  #
  # The normal <tt>require</tt> functionality of returning false if
  # that file has already been loaded is preserved.

  def require(path) # :doc:
    gem_original_require path
  rescue LoadError => load_error
    if load_error.message =~ /#{Regexp.escape path}\z/ and
       spec = Gem.searcher.find(path) then
      Gem.activate(spec.name, "= #{spec.version}")
      gem_original_require path
    else
      raise load_error
    end
  end

  private :require
  private :gem_original_require

end

Colin Law

unread,
Oct 28, 2013, 11:22:27 AM10/28/13
to rubyonra...@googlegroups.com
On 28 October 2013 15:10, RVic <rvin...@hotmail.com> wrote:
> I've been tryng to duplicate an ancient Ruby 1.86 Rails 2.3.2 app on a brand
> new Linux box (over from a windows box) and have, under rpm, recreated all
> the gems with their corret versions.
>
> However, when I go to invoke
>
> ruby script/server
>
> I am getting:
>
> => Booting Mongrel
> => Rails 2.3.2 application starting on http://0.0.0.0:3000
> /home/user/.rvm/gems/ruby-1.8.6-p420/gems/rails-2.3.2/lib/rails/gem_dependency.rb:99:Warning:
> Gem::Dependency#version_requirements is deprecated and will be removed on or
> after August 2010. Use #requirement

The warning is because you have a later version of rubygems than
rails. It is only a warning, you can ignore it.

> /home/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `gem_original_require': no such file to load -- ruby-debug
> (MissingSourceFile)
> from
> /home/user/.rvm/rubies/ruby-1.8.6-p420/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `require'
> from
> /home/user/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in
> `require'
> from
> /home/user/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in
> `new_constants_in'
> from
> /home/user/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in
> `require'
> from /home/user/ggrip/ggripv2/config/environments/development.rb:2:in
> `load_environment'
> from
> [snip]
>
> I'm at a loss here as to what to change to get this thing to fire up -- Im
> just not sure what it is telling me needs to be changed in my
> custom_require.rb, below, in order to start. Can someone please orient me
> here what I need to do? Thanks, RVic

There is nothing wrong with custom_require.rb, the problem is that it
cannot find the ruby-debug gem. Unless you need to use it just remove
it from development.rb (I think that is where it is being required
from).

Colin

Colin Law

unread,
Oct 28, 2013, 11:27:14 AM10/28/13
to rubyonra...@googlegroups.com
On 28 October 2013 15:10, RVic <rvin...@hotmail.com> wrote:
> I've been tryng to duplicate an ancient Ruby 1.86 Rails 2.3.2 app on a brand
> new Linux box (over from a windows box) and have, under rpm, recreated all
> the gems with their corret versions.

Looking back I see you had exactly the same problem on 23rd Oct and I
replied exactly the same as I have done above. Did it not work the
first time? You then came back with a different problem about
executable-hooks. I assumed you had fixed the ruby-debug problem.

Colin

RVic

unread,
Oct 28, 2013, 11:48:42 AM10/28/13
to rubyonra...@googlegroups.com

Colin,

I was able to fix executable-hooks (which installing 1.8.6 under rvm was causing) per Michal Papas this morning. I;ve tried to instaull ruby-debug-base, etc. but:

gem install --remote ruby-debug
ERROR:  Error installing ruby-debug:
    linecache requires Ruby version >= 1.8.7.

(Incidentally, under rvm, if I were to install 1.8.7, would I need to reinstall all the gems I have installed under 1.8.6? Does rvm create another new, empty ruby "slot" in that regard that moves with the version selected?)

You are right, ruby-deub existed in my develoment.rb, which I commented out, restarted, and:

 ruby script/server
./script/../config/boot.rb:39:in `run': uninitialized constant Rails::Initializer (NameError)
    from ./script/../config/boot.rb:11:in `boot!'
    from ./script/../config/boot.rb:110
    from script/server:2:in `require'
    from script/server:2

Line 39 of boot.rb is:

Rails::Initializer.run(:set_load_path)

I'm really struggling with discerning what these error messages mean. It takes a while to get into the Ruby idiom, even longer using an old app, when you have been away from it for a few years (not by virtue of wanting to be away from it though) Rvic

Colin Law

unread,
Oct 28, 2013, 12:04:45 PM10/28/13
to rubyonra...@googlegroups.com
On 28 October 2013 15:48, RVic <rvin...@hotmail.com> wrote:
>
> Colin,
>
> I was able to fix executable-hooks (which installing 1.8.6 under rvm was
> causing) per Michal Papas this morning. I;ve tried to instaull
> ruby-debug-base, etc. but:
>
> gem install --remote ruby-debug
> ERROR: Error installing ruby-debug:
> linecache requires Ruby version >= 1.8.7.
>
> (Incidentally, under rvm, if I were to install 1.8.7, would I need to
> reinstall all the gems I have installed under 1.8.6? Does rvm create another
> new, empty ruby "slot" in that regard that moves with the version selected?)

Yes

>
> You are right, ruby-deub existed in my develoment.rb, which I commented out,
> restarted, and:
>
> ruby script/server
> ./script/../config/boot.rb:39:in `run': uninitialized constant
> Rails::Initializer (NameError)
> from ./script/../config/boot.rb:11:in `boot!'
> from ./script/../config/boot.rb:110
> from script/server:2:in `require'
> from script/server:2
>
> Line 39 of boot.rb is:
>
> Rails::Initializer.run(:set_load_path)

Which version of rubygems are you running?
gem -v

Colin

RVic

unread,
Oct 28, 2013, 12:32:07 PM10/28/13
to rubyonra...@googlegroups.com
gem -v
/home/user/.rvm/rubies/ruby-1.8.6-p420/bin/gem:21: uninitialized constant Gem::GemRunner (NameError)

I thought I had installed 2.3.2 ?

Colin Law

unread,
Oct 28, 2013, 12:44:50 PM10/28/13
to rubyonra...@googlegroups.com
That is Rails, we are talking here about rubygems. You probably want
version 1.3.7. Did you run gem -v from your application root?

I don't understand the error, but to install rubygems 1.3.7 try
rvm install rubygems 1.3.7

then see if gem -v works.

Colin

RVic

unread,
Oct 28, 2013, 1:07:07 PM10/28/13
to rubyonra...@googlegroups.com
Colin,

I installed
rvm install rubygems 1.3.7
right after installing rvm, right before I installed rails 2.3.2

I went and re-installed it, and now:

gem -v
1.3.7

Colin Law

unread,
Oct 28, 2013, 1:16:09 PM10/28/13
to rubyonra...@googlegroups.com
On 28 October 2013 17:07, RVic <rvin...@hotmail.com> wrote:

Please don't top post, and remember to quote the relevant bits of the
previous message. Thanks.
And....

Any difference to your problem? We are not telepathic.

Colin

RVic

unread,
Oct 28, 2013, 1:30:45 PM10/28/13
to rubyonra...@googlegroups.com
Colin,

You underestimate yourselves -- I think the guys in this group do exhibit telepathic qualities (I say that because i am very grteful to all the hlpe I have been offered here, and hoe to reciprocate in the not-too-distant future).

(Im sorry, I am on the google grups page, and seemingly unable to get anything of the thread in this message save for the first message in the thread, which I am not dupicating)

Yes, it made a big difference! Now, however (because I am using the authlogic gem I believe, and now on linux as opposed to a windows installation previously that I am porting this over from):
ruby script/server
/home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:163:in `ensure_session_key': A key is required to write a cookie containing the session data. Use config.action_controller.session = { :key => "_myapp_session", :secret => "some secret phrase" } in config/environment.rb (ArgumentError)
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:74:in `initialize'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:72:in `new'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:72:in `build'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in `build'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/activesupport-2.3.2/lib/active_support/inflector.rb:361:in `inject'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in `each'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in `inject'
    from /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in `build'
     ... 8 levels...

Colin Law

unread,
Oct 28, 2013, 1:33:55 PM10/28/13
to rubyonra...@googlegroups.com
On 28 October 2013 17:30, RVic <rvin...@hotmail.com> wrote:
> Colin,
>
> You underestimate yourselves -- I think the guys in this group do exhibit
> telepathic qualities (I say that because i am very grteful to all the hlpe I
> have been offered here, and hoe to reciprocate in the not-too-distant
> future).
>
> (Im sorry, I am on the google grups page, and seemingly unable to get
> anything of the thread in this message save for the first message in the
> thread, which I am not dupicating)

In that case please subscribe to the list and access it through email.

>
> Yes, it made a big difference! Now, however (because I am using the
> authlogic gem I believe, and now on linux as opposed to a windows
> installation previously that I am porting this over from):
> ruby script/server
> /home/user/.rvm/gems/ruby-1.8.6-p420/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:163:in
> `ensure_session_key': A key is required to write a cookie containing the
> session data. Use config.action_controller.session = { :key =>
> "_myapp_session", :secret => "some secret phrase" } in config/environment.rb

Well that is clear enough I think.

Colin
Reply all
Reply to author
Forward
0 new messages