# Rails PDF gem woe -- "MissingSourceFile"

**URL:** <https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092>\
**Category:** Rails\
**Created:** [September 26, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092 "2006-09-26T19:09:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gwendy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gwendy](https://www.ruby-forum.com/u/gwendy)\
**Post date:** [September 26, 2006, 7:09pm UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092/1 "2006-09-26T19:09:38Z")

</div>

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://rubyforge.org/projects/railspdfplugin/)  
[http://wiki.rubyonrails.org/rails/pages/Rails+PDF+Plugin/versions/18](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

---

<div class="post-metadata">

**Author:** ![gwendy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gwendy](https://www.ruby-forum.com/u/gwendy)\
**Post date:** [September 26, 2006, 7:25pm UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092/2 "2006-09-26T19:25:40Z")

</div>

What do you get if you type?

> gem environment

on your server?

\_Kevin

---

<div class="post-metadata">

**Author:** ![gwendy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gwendy](https://www.ruby-forum.com/u/gwendy)\
**Post date:** [September 26, 2006, 7:53pm UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092/3 "2006-09-26T19:53:46Z")

</div>

\_Kevin wrote:

> What do you get if you type?
> 
> > gem environment
> 
> on your server?

Thank you for the suggestion!

On the plus side, that shows me what I wanted to see:

# gem environment

Rubygems Environment:

- VERSION: 0.8.10 (0.8.10)
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.8
- GEM PATH:
  - /usr/local/lib/ruby/gems/1.8

- REMOTE SOURCES:
  - [http://gems.rubyforge.org](http://gems.rubyforge.org)

On the not plus side, the gem path appears to be where I expected it to  
be, and it doesn’t reveal an easy answer as to why the Rails PDF gem is  
not being found.

I’m not sure if this is pertinent or not, but it looks like ruby is  
looking for a gem called “RailsPDF” (“no such file to load – RailsPDF  
(MissingSourceFile)”), but I can’t find anything within  
/usr/local/lib/ruby/gems/1.8/gems/pdf-writer-1.1.3/ which contains or  
references that name.

~gwendy

---

<div class="post-metadata">

**Author:** ![gwendy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gwendy](https://www.ruby-forum.com/u/gwendy)\
**Post date:** [September 26, 2006, 9:51pm UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092/4 "2006-09-26T21:51:58Z")

</div>

On 9/26/06, gwendy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m not sure if this is pertinent or not, but it looks like ruby is  
> looking for a gem called “RailsPDF” (“no such file to load – RailsPDF  
> (MissingSourceFile)”), but I can’t find anything within  
> /usr/local/lib/ruby/gems/1.8/gems/pdf-writer-1.1.3/ which contains or  
> references that name.

That’s because the RailsPDF gem is separate from PDF::Writer and it is  
not maintained by the PDF::Writer maintainer. (That would be me, even  
though I’m too busy to do much maintaining right now.)

There is no file to require ‘RailsPDF’. You need to see how you’re  
supposed to use the Rails PDF plugin according to that documentation.

## -austin

Austin Z. \* removed\_email\_address@domain.invalid \* [http://www.halostatue.ca/](http://www.halostatue.ca/)  
\* removed\_email\_address@domain.invalid \* [You are in a maze of twisty little passages, all alike. // halo • statue](http://www.halostatue.ca/feed/)  
\* removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![gwendy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gwendy](https://www.ruby-forum.com/u/gwendy)\
**Post date:** [September 26, 2006, 11:10pm UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092/5 "2006-09-26T23:10:05Z")

</div>

Austin Z. wrote:

> not maintained by the PDF::Writer maintainer. (That would be me, even  
> though I’m too busy to do much maintaining right now.)

And confusion abounds! (On my end, that is!) This is what happens when  
you come back to  
something after a break. Details get muddled and you forget what’s what  
☹

I’d forgotten that I had at one point looked at two different PDF tools!  
Let’s forget that reference to  
PDF::Writer all together. Its not relevant 😉

> There is no file to require ‘RailsPDF’. You need to see how you’re  
> supposed to use the Rails PDF plugin according to that documentation.

Alas, its not so simple as consulting the documentation (which amounts  
to “install and use” anyway).  
The plugin IS installed and working on my development box. The source is  
checked in to svn, and  
has been deployed to my production server. Same source, same  
configuration. I’m even still running  
in “Development” mode on both machines. Here it works. There it doesn’t.  
What’s the difference?  
The only thing that I can see is the physical environment that the  
source is being run in. But we’re  
still talking about the same _versions_ of ruby on down.

I’m also intrigued, now, as to why ruby appears to be looking for a  
RailsPDF gem when it is not a gem  
at all. I’m certainly not referencing it as a gem anywhere.

But so it goes. The learning experience continues…

~gwendy

---

<div class="post-metadata">

**Author:** ![gwendy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gwendy](https://www.ruby-forum.com/u/gwendy)\
**Post date:** [September 27, 2006, 5:23am UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092/6 "2006-09-27T05:23:59Z")

</div>

Austin Z. wrote:

> creator. The plugin only enables .rpdf capabilities.
> 
> > can see is the physical environment that the source is being run in.  
> > –  
> > Austin Z. \* removed\_email\_address@domain.invalid \* [http://www.halostatue.ca/](http://www.halostatue.ca/)  
> > \* removed\_email\_address@domain.invalid \* [You are in a maze of twisty little passages, all alike. // halo • statue](http://www.halostatue.ca/feed/)  
> > \* removed\_email\_address@domain.invalid

I’d try this…

Get the ‘Gems’ plugin (see  
[http://www.agilewebdevelopment.com/plugins/gems](http://www.agilewebdevelopment.com/plugins/gems)).  
Use it to freeze all your gems into your rails vendor directory  
Make sure it works.  
Deploy the new version with all the gems packed into it.

then you won’t need to worry about different gem versions on your local  
machine and the server.

\_Kevin

---

<div class="post-metadata">

**Author:** ![gwendy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gwendy](https://www.ruby-forum.com/u/gwendy)\
**Post date:** [September 27, 2006, 3:59pm UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092/7 "2006-09-27T15:59:01Z")

</div>

Austin Z. wrote:

> > I can’t answer to the plugins; but the error you reported is simply that  
> > “require ‘RailsPDF’” isn’t working because there’s no file ‘RailsPDF’.

Yes; I know that. That is precisely the point of my confusion, and the  
reason I posted in the first place:  
I’m getting an error because ruby is unable to find “RailsPDF”.

It appears to be looking for a gem of that name (_if_ I’ve interpreted  
the full error message correctly).  
There _is_ _no_ gem called “RailsPDF”. It is a plugin, and the plugin  
_is_ by all accounts properly  
installed. On my development box, the _exact_ same source does not cause  
ruby to go on a wild  
goosechase for this mythical “RailsPDF” file (gem or otherwise). Hence  
the “wtf” look on my face.

If I’ve misunderstood the error, and ruby is not looking for gem, then  
that is useful information for me to  
work with.

I understand that you don’t know anything about this plugin. That’s  
fair; I’m not specifically looking to  
you for answers. And I thank you for your time and interest. As I’m  
about to say below, though, I’m  
going to shelve this problem for the time being.

\_Kevin wrote:

> 

Thanks for this suggestion. I tried it, but it had no impact on the  
problem at hand. I can  
verify that all of my gems are now included locally in the source (both  
machines were  
currently in sync in terms of gem versions anyway, but ensuring things  
_stay that way_ in the future  
sounds like good insurance to me ;))

I’m about ready to chalk this one up to gremlins. Being able to deploy  
is more urgent at this  
point than having PDF support. I’ll look in to it again for version 2 😉

~gwendy

---

<div class="post-metadata">

**Author:** ![gwendy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gwendy](https://www.ruby-forum.com/u/gwendy)\
**Post date:** [September 27, 2006, 2:08am UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092/8 "2006-09-27T02:08:19Z")

</div>

On 9/26/06, gwendy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> And confusion abounds! (On my end, that is!) This is what happens when  
> you come back to something after a break. Details get muddled and you  
> forget what’s what ☹

> I’d forgotten that I had at one point looked at two different PDF  
> tools! Let’s forget that reference to PDF::Writer all together. Its  
> not relevant 😉

It is, in a way. The Rails PDF plugin uses PDF::Writer as its PDF  
creator. The plugin only enables .rpdf capabilities.

> > There is no file to require ‘RailsPDF’. You need to see how you’re  
> > supposed to use the Rails PDF plugin according to that documentation.

> Alas, its not so simple as consulting the documentation (which amounts  
> to “install and use” anyway). The plugin IS installed and working on  
> my development box. The source is checked in to svn, and has been  
> deployed to my production server. Same source, same configuration. I’m  
> even still running in “Development” mode on both machines. Here it  
> works. There it doesn’t. What’s the difference? The only thing that I  
> can see is the physical environment that the source is being run in.  
> But we’re still talking about the same _versions_ of ruby on down.

> I’m also intrigued, now, as to why ruby appears to be looking for a  
> RailsPDF gem when it is not a gem at all. I’m certainly not  
> referencing it as a gem anywhere.

I can’t answer to the plugins; but the error you reported is simply that  
“require ‘RailsPDF’” isn’t working because there’s no file ‘RailsPDF’.

## -austin

Austin Z. \* removed\_email\_address@domain.invalid \* [http://www.halostatue.ca/](http://www.halostatue.ca/)  
\* removed\_email\_address@domain.invalid \* [You are in a maze of twisty little passages, all alike. // halo • statue](http://www.halostatue.ca/feed/)  
\* removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![gwendy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/dbc845/32.png) [@gwendy](https://www.ruby-forum.com/u/gwendy)\
**Post date:** [September 27, 2006, 9:19pm UTC](https://www.ruby-forum.com/t/rails-pdf-gem-woe-missingsourcefile/70092/9 "2006-09-27T21:19:53Z")

</div>

On 9/27/06, gwendy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Yes; I know that. That is precisely the point of my confusion, and the  
> reason I posted in the first place:  
> I’m getting an error because ruby is unable to find “RailsPDF”.

Is there a file RailsPDF.rb in any of your files on your server?  
What’s your development platform as opposed to your deployment  
platform? Could it be that the file is actually railspdf.rb and not  
RailsPDF.rb? If you’re developing on Windows, Ruby doesn’t care about  
case sensitivity (because Windows doesn’t).

You are misunderstanding the error: when you are using RubyGems, it  
currently implements a custom Kernel#require method that implements  
the gem require capabilities (the ability to search within Gem  
directories for files to require).

## -austin

Austin Z. \* removed\_email\_address@domain.invalid \* [http://www.halostatue.ca/](http://www.halostatue.ca/)  
\* removed\_email\_address@domain.invalid \* [You are in a maze of twisty little passages, all alike. // halo • statue](http://www.halostatue.ca/feed/)  
\* removed\_email\_address@domain.invalid
