rack based and gem_path

146 views
Skip to first unread message

ericl

unread,
Jul 31, 2008, 8:41:23 AM7/31/08
to Phusion Passenger Discussions
Hi,
on shared hosting, if I have a custom gem. For a rails based
application it's possible define in config/environment.rb

ENV['GEM_PATH'] = '/path/to/my/gems'
(or Gem.path.unshift('/path/to/my/gems')

but for a rack based application, is it possible to set this
somewhere? I've tried to put that at the top of the config.ru with
limited success only. When it is first spawned, passenger is not
searching for gems in my custom path, but after a reload it's ok.

So for now the workaround for me is to set PassengerPoolIdleTime to a
ridiculous amount to avoid the first spawn, but this is not 'ressource
friendly'

any idea would be welcome
Eric

Dalban

unread,
Sep 15, 2008, 6:38:37 AM9/15/08
to Phusion Passenger Discussions
This is an old topic, but maybe someone else could use this info.
below to save a few minutes.

I was having the same problem. Apparently, you have to put:
Gem.clear_paths
after you do "require 'rubygems'". So the full solution is:
---------------------------------
ENV['GEM_HOME'] = '/path/to/my/gems'
ENV['GEM_PATH'] = '/path/to/my/gems:/another/path/if/you/want:/and/
another'
require 'rubygems'
Gem.clear_paths
---------------------------------
Apparently, 'Gem.clear_paths' was being called after a gem or file
load error. A better explanation is here:
http://github.com/FooBarWidget/passenger/commit/a60f262fe38beda161024ee14f4387b2c3c73bdf
That explains why the reload was needed to take care of it. I finally
found the answer based on sbeckeriv's comments on the web.
http://www.google.com/search?q=sbeckeriv+clear_paths

I'm still not sure why this hasn't come up before. Are most people
are just using Rails with Passenger? Or maybe there is a better way of
setting the 'gem_path' in a shared environment for Rack apps?

ericl

unread,
Sep 21, 2008, 9:05:06 PM9/21/08
to Phusion Passenger Discussions
Oh thanks, it's working great. Now I can use Ramaze on Dreamhost

On Sep 15, 6:38 am, Dalban <diego.al...@gmail.com> wrote:
> This is an old topic, but maybe someone else could use this info.
> below to save a few minutes.
>
> I was having the same problem.  Apparently, you have to put:
> Gem.clear_paths
> after you do "require 'rubygems'".  So the full solution is:
> ---------------------------------
> ENV['GEM_HOME'] = '/path/to/my/gems'
> ENV['GEM_PATH'] = '/path/to/my/gems:/another/path/if/you/want:/and/
> another'
> require 'rubygems'
> Gem.clear_paths
> ---------------------------------
> Apparently, 'Gem.clear_paths' was being called after a gem or file
> load error. A better explanation is here:http://github.com/FooBarWidget/passenger/commit/a60f262fe38beda161024...
> That explains why the reload was needed to take care of it. I finally
> found the answer based on sbeckeriv's comments on the web.http://www.google.com/search?q=sbeckeriv+clear_paths
Reply all
Reply to author
Forward
0 new messages