# Vendor/rails seems to be being ignored in preference to gem?

**URL:** <https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395>\
**Category:** Rails\
**Created:** [May 3, 2006, 6:59pm UTC](https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395 "2006-05-03T18:59:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [May 3, 2006, 6:59pm UTC](https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395/1 "2006-05-03T18:59:48Z")

</div>

I have edge rails in /vendor/rails on DreamHost, but when running  
dispatch.fcgi I get the following error in my logs:

[02/May/2006:08:52:32 :: 29365] terminated gracefully  
[02/May/2006:08:53:53 :: 19526] starting  
[02/May/2006:08:53:54 :: 19526] Dispatcher failed to catch: undefined  
method `clear\_connection\_cache!’ for ActiveRecord::Base:Class  
(NoMethodError)

…/config/…/vendor/rails/activerecord/lib/active\_record/base.rb:1138:in  
`method_missing' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:76:in`reset\_after\_dispatch’  
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:46:in  
`dispatch' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:141:in`process\_request’  
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi\_handler.rb:53:in  
`process!' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:52:in`each\_cgi’  
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi\_handler.rb:52:in  
`process!' /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:22:in`process!’  
./dispatch.fcgi:35

I get the same printed to the shell when running dispatch.rb too.

It appears to me that it’s trying to use the gem version of rails on DH  
and not the copy I have in /vendor/rails.

Any ideas on why this is happening, or things to check, would be  
appreciated.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [May 3, 2006, 7:00pm UTC](https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395/2 "2006-05-03T19:00:23Z")

</div>

Quick update on this…

Running script/server or the console etc… also result in the GEM being  
used instead of the version in /vendor/

Certainly odd and I’m at a bit of a loss!

–  
R.Livsey

> **[Livsey.org](http://livsey.org)**
>
> I’ve been using Firebase with Ember.js quite a lot recently and have just
> released Fireplace, a library to integrate the two more easily. It

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [May 4, 2006, 2:07pm UTC](https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395/3 "2006-05-04T14:07:05Z")

</div>

On Tue, 2006-05-02 at 19:31 +0100, Richard L. wrote:

> Quick update on this…
> 
> Running script/server or the console etc… also result in the GEM being  
> used instead of the version in /vendor/
> 
> Certainly odd and I’m at a bit of a loss!

Hi Richard,  
Have you found a solution for this yet?

I am seeing the same problem, and hope to work on it tonight, so fingers  
crossed and maybe I’ll post a solution soon.

cheers,  
mick

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [May 4, 2006, 2:44pm UTC](https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395/4 "2006-05-04T14:44:23Z")

</div>

Look at your environment.rb and the development.rb and production.rb  
files in config/environments. Make sure there are no declarations  
specifying a version of Rails or to use gems. If you still don’t see  
anything, I suggest posting the files so we can have a look.

Mick H. wrote:

> On Tue, 2006-05-02 at 19:31 +0100, Richard L. wrote:
> 
> > Quick update on this…
> > 
> > Running script/server or the console etc… also result in the GEM being  
> > used instead of the version in /vendor/
> > 
> > Certainly odd and I’m at a bit of a loss!
> 
> Hi Richard,  
> Have you found a solution for this yet?
> 
> I am seeing the same problem, and hope to work on it tonight, so fingers  
> crossed and maybe I’ll post a solution soon.
> 
> cheers,  
> mick

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [May 4, 2006, 3:33pm UTC](https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395/5 "2006-05-04T15:33:31Z")

</div>

Hi Richard and Mick.

I had the same problem with Dreamhost as well. There were two  
solutions for me. My app uses Engines and the problem was somehow  
related.

The first solution was easy, but a bit of a hack since you have to  
modify files in /vendor/rails. If you follow this thread:

[http://forum.textdrive.com/viewtopic.php?pid=87987](http://forum.textdrive.com/viewtopic.php?pid=87987)

near the end, there’s a suggestion to replace the lines require  
‘fcgi\_handler’ and require ‘dispatcher’. These two modifications  
fixed the problem, however I hate the idea of having to modify any  
rails code.

I realized that for me, the new Engines from svn was causing the  
problem. Since the two versions (the previous one that had to issues)  
and the new version that broke my app (on Dreahost, works fine on my  
powerbook) had the same version (1.1.1) I didn’t realize there were  
any differences until I decided to run diff. Anyway, I reverted to  
the last working engines code from svn, and things started working  
again, phew!

I don’t know if the cause is the same, but I had the same problems as  
you guys and that’s how I fixed it. Hope this helps.

-Tak.

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [May 5, 2006, 6:36pm UTC](https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395/6 "2006-05-05T18:36:42Z")

</div>

This particular fix is already present in the current release branch  
for the engines plugin, and should be out very soon.

- james

On 5/5/06, Mick H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> vendor/plugins/engines/lib/engines.rb:  
> rescue kicks in and the second “require” loads the “rails/version.rb”
> 
> Now, I think (a) is achieved by following instructions from pages such  
> cheers.

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [May 8, 2006, 9:04am UTC](https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395/7 "2006-05-08T09:04:26Z")

</div>

On Fri, 2006-05-05 at 17:33 +0100, James A. wrote:

> This particular fix is already present in the current release branch  
> for the engines plugin, and should be out very soon.

Thanks James.  
Out of interest, what does the fix actually do?

My conclusion was that I should really be changing my ways so that, as I  
said, I should

> a) freeze every gem that I use, and  
> b) configure my rails app in such a way that it never looks for gems  
> outside of my application’s directory

Does the fix make the above unnecessary?

thanks,  
mick

---

<div class="post-metadata">

**Author:** ![rjlyders](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/58f4c7/32.png) [@rjlyders](https://www.ruby-forum.com/u/rjlyders)\
**Post date:** [May 5, 2006, 5:41pm UTC](https://www.ruby-forum.com/t/vendor-rails-seems-to-be-being-ignored-in-preference-to-gem/59395/8 "2006-05-05T17:41:08Z")

</div>

On Thu, 2006-05-04 at 09:32 -0400, Takashi Okamoto wrote:

> Hi Richard and Mick.
> 
> I had the same problem with Dreamhost as well. There were two  
> solutions for me. My app uses Engines and the problem was somehow  
> related.

Problem diagnosed:

I’m using Engines as well. I tracked it down to the following code in  
vendor/plugins/engines/lib/engines.rb:

```
#load this before doing ANYTHING freaky with the reloading.
begin
  require 'rails_version' # Rails 1.0, 1.1.0
rescue LoadError, Gem::Exception
  require 'rails/version' # renamed as of Rails 1.1.1
end

```

As I am running Rails 1.1.2, in order to get the correct rails version  
file being loaded I need the first “require” above to fail, so that the  
rescue kicks in and the second “require” loads the “rails/version.rb”  
from vendor/rails/…

Unfortunately, in my case (on Dreamhost) the first require does not fail  
as the Rails 1.0 gem is available.

If I change the above code to simply say:

require ‘rails/version’

then my app works just fine.

It strikes me that this is a more general problem than the offending  
“require” above as there could be any number of such “requires” that  
cause the wrong gem to be brought in.

I suspect the correct solution is for me to set things up so that I:

a) freeze every gem that I use, and  
b) configure my rails app in such a way that it never looks for gems  
outside of my application’s directory

Now, I think (a) is achieved by following instructions from pages such  
as:  
[http://nubyonrails.com/articles/2005/12/22/freeze-other-gems-to-rails-lib-directory](http://nubyonrails.com/articles/2005/12/22/freeze-other-gems-to-rails-lib-directory)

For (b) I seem to recall reading how to do that somewhere, but will have  
to do some more googling.

Anyway, I hope the above helps others who hit this problem, and if  
anyone has advice on how to do (a) and (b), or whether that’s actually  
what I should be doing, it would be much appreciated.

cheers.  
mick
