How do you use the 'vendor' directory with 3rd party librari


#1

Hi,

I’m wondering how to use the ‘vendor’ directory in a Rails app. I
know that you can put plugins and engines into the ‘vendor/plugins’
directory and that svn:externals can be used for that, but I was
wondering how & where I put a 3rd party library? My specific case is
the pdf-writer code, which I’d rather have inside my app than as a
Ruby gem (for no particular reason).

What I’ve done is put the following into the svn:externals for the
‘vendor’ directory:

pdf-writer svn://rubyforge.org/var/svn/ruby-pdf/tags/v1-1-3/pdf-writer
color-tools
svn://rubyforge.org/var/svn/ruby-pdf/tags/version-1-3-0/color-tools

I’ve then done a ‘svn update’ and got the code (so now I have
‘vendor/pdf-writer’ and ‘vendor/color-tools’) but when I run the
‘script/server’ I simply see:

=> Booting WEBrick…

So I ran ‘script/console’ to see what was going on and I get:

Loading development environment.
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in
require__': no such file to load -- pdf/writer (MissingSourceFile) from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' from ./script/../config/../config/../lib/pdf_render.rb:1 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
from
/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' from ./script/../config/../config/environment.rb:18 from /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:inrequire’
from /usr/lib/ruby/1.8/irb/init.rb:252:in load_modules' from /usr/lib/ruby/1.8/irb/init.rb:250:inload_modules’
from /usr/lib/ruby/1.8/irb/init.rb:21:in setup' from /usr/lib/ruby/1.8/irb.rb:54:instart’
from /usr/bin/irb:13
m

This code was working with the pdf-writer installed as a Ruby gem so I
know it’s right, so it must be either (a) me putting those
svn:externals in the wrong place, (b) me missing something in the
configuration setup, © me completely missing the point of the vendor
directory and what code can go there. Do I have to explicitly add the
‘vendor/pdf-writer’ and ‘vendor/color-tools’ to the require path or
something?

Any help much appreciated, particular a pointer to a webpage that
explains this (which I’ve yet to find).

Matt


#2

I have a similar problem. I am trying to use the ferret gem on a
shared hosting account. I can’t install any gems, so I did a “gem
unpack ferret” in my “vendor” directory.

I get the same error message as Matthew, except with “ferret” not being
found.


#3

On 5/4/06, Nithin R. removed_email_address@domain.invalid wrote:

I have a similar problem. I am trying to use the ferret gem on a
shared hosting account. I can’t install any gems, so I did a “gem
unpack ferret” in my “vendor” directory.

I get the same error message as Matthew, except with “ferret” not being found.

I’ve got it working for the PDF writer stuff. I had to ensure that
the paths were on the config.load_paths:

Rails::Initializer.run do |config|

Settings in config/environments/* take precedence those specified

here

We have several components that are used in the ‘vendor’ directory.

So we need to add the appropriate load paths.

config.load_paths += [ ‘color-tools’, ‘pdf-writer’ ].collect {
|vendor| “#{ RAILS_ROOT }/vendor/#{ vendor }/lib” }
end

To my config/environment.rb. This gets it working for me, maybe it’ll
help you.

Matt