I’m experiencing some require-weirdness when deploying a railsapp which
uses the Rails PDF Plugin gem[1]. I’m not sure if anyone on this list
has any experience with this gem, or has a moment to try to help me
troubleshoot this, but I figured it was worth a shot. The plugin page
on rubyforge has not been active in almost a year, so… ![]()
I’m developing on my local machine (mac), using the Locomotive rails
environment[2]. I’m deploying to a linux server[2]. Both machines are
running the same version of ruby and applicable gems. While everything
works fine locally, when I deploy to the server and try to access the
the railsapp, I receive Application Error 500s from the webserver
(“premature end of script headers”). Running dispatch.cgi locally (on
the server) reveals an issue with RailsPDF:
/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__': no such file to load – RailsPDF (MissingSourceFile)
Line 18 in custom_require.rb is part of the Kernel module, which loads
gems on demand[4]. So its apparently not finding the RailsPDF gem when
it attempts to load it. But “gem list --local” does find the gem (see
[2]), and I can visually confirm its presence by looking in
“/usr/local/lib/ruby/gems/1.8/gems/pdf-writer-1.1.3/”. This leaves me
stumped.
Is there any way I can determine exactly where custom_require.rb is
looking for the RailsPDF gem? I assume loadpath is
“/usr/local/lib/ruby/gems/1.8/gems/”, but I don’t know this for certain.
This is certainly where all my other gems are located and none of them
have failed to load.
What other questions should I be asking at this point?
Any pointers that someone could offer would be greatly appreciated!
Thanks in advance,
~gwendy
[1] http://rubyforge.org/projects/railspdfplugin/
http://wiki.rubyonrails.org/rails/pages/Rails+PDF+Plugin/versions/18
[2] Development environment:
webserver: lightty (as built into Locomotive)
database: sqlite3
$ ruby -v
ruby 1.8.4 (2005-12-24) [i686-darwin8.6.1]
$ gem list --local [edit: list is truncated to the potentially
relevant]
*** LOCAL GEMS ***
activerecord (1.14.4, 1.14.3, 1.14.2)
Implements the ActiveRecord pattern for ORM.
activesupport (1.3.1)
Support and utility classes used by the Rails framework.
capistrano (1.2.0, 1.1.0)
Capistrano is a framework and utility for executing commands in
parallel on multiple remote machines, via SSH. The primary goal
is
to simplify and automate the deployment of web applications.
capistrano-ext (1.0.1)
Capistrano Extensions is a set of useful task libraries and
methods
that other developers may reference in their own recipe
files.
color-tools (1.3.0)
color-tools provides colour space definition and manpiulation as
well as commonly named RGB colours.
pdf-writer (1.1.3)
A pure Ruby PDF document creation library.
rails (1.1.6, 1.1.4, 1.1.2)
Web-application framework with template engine, control-flow
layer,
and ORM.
rake (0.7.1)
Ruby based make-like utility.
transaction-simple (1.3.0)
Simple object transaction support for Ruby.
[3] Production environment:
webserver: apache 1.3.36
database: MySQL 4.1.21
ruby -v
ruby 1.8.4 (2005-12-24) [i686-linux]
gem list --local
*** LOCAL GEMS ***
activerecord (1.14.4, 1.14.3, 1.14.0, 1.13.2, 1.11.1)
Implements the ActiveRecord pattern for ORM.
activesupport (1.3.1, 1.3.0, 1.2.5, 1.1.1)
Support and utility classes used by the Rails framework.
capistrano (1.2.0)
Capistrano is a framework and utility for executing commands in
parallel on multiple remote machines, via SSH. The primary goal
is
to simplify and automate the deployment of web applications.
color-tools (1.3.0)
color-tools provides colour space definition and manpiulation as
well as commonly named RGB colours.
pdf-writer (1.1.3)
A pure Ruby PDF document creation library.
rails (1.1.6, 1.1.4, 1.1.0, 1.0.0, 0.13.1)
Web-application framework with template engine, control-flow
layer,
and ORM.
rake (0.7.1, 0.7.0, 0.6.2)
Ruby based make-like utility.
transaction-simple (1.3.0)
Simple object transaction support for Ruby.
[4] /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb
3 module Kernel
4 alias require__ require
5
6 #
7 # We replace Ruby’s require with our own, which is capable of
loading gems on demand.
8 #
9 # When you call require ‘x’, this is what happens:
10 # * If the file can be loaded from the existing Ruby
loadpath, it is.
11 # * Otherwise, installed gems are searched for a file that
matches. If it’s found in gem
12 # ‘y’, that gem is activated (added to the loadpath).
13 #
14 # The normal require functionality of returning
false if that file has already been
15 # loaded is preserved.
16 #
17 def require(path)
18 require__ path
19 rescue LoadError => load_error
20 begin
21 @gempath_searcher ||= Gem::GemPathSearcher.new
22 if spec = @gempath_searcher.find(path)
23 Gem.activate(spec.name, true, “= #{spec.version}”)
24 require__ path
25 else
26 raise load_error
27 end
28 end
29 end
30 end # module Kernel

