Forum: Ruby on Rails How do you use the 'vendor' directory with 3rd party librari

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4436333655e947f1a0da99a251abe0c6?d=identicon&s=25 Matthew Denner (Guest)
on 2006-05-03 19:07
(Received via mailing list)
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:in
`require'
        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:in
`require'
        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:in
`require'
        from /usr/lib/ruby/1.8/irb/init.rb:252:in `load_modules'
        from /usr/lib/ruby/1.8/irb/init.rb:250:in `load_modules'
        from /usr/lib/ruby/1.8/irb/init.rb:21:in `setup'
        from /usr/lib/ruby/1.8/irb.rb:54:in `start'
        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, (c) 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
720fde074c77f4c9692dd6f05802d581?d=identicon&s=25 Nithin Reddy (jashugan)
on 2006-05-04 02:00
(Received via mailing list)
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.
4436333655e947f1a0da99a251abe0c6?d=identicon&s=25 Matthew Denner (Guest)
on 2006-05-04 15:27
(Received via mailing list)
On 5/4/06, Nithin Reddy <jashugan@gmail.com> 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
This topic is locked and can not be replied to.