# Problem loading files in Ruby CGI scripts

**URL:** <https://www.ruby-forum.com/t/problem-loading-files-in-ruby-cgi-scripts/104216>\
**Category:** Ruby\
**Created:** [May 15, 2007, 3:14pm UTC](https://www.ruby-forum.com/t/problem-loading-files-in-ruby-cgi-scripts/104216 "2007-05-15T15:14:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [May 15, 2007, 3:14pm UTC](https://www.ruby-forum.com/t/problem-loading-files-in-ruby-cgi-scripts/104216/1 "2007-05-15T15:14:52Z")

</div>

This is not a Ruby problem as such, but I’m hoping someone will have  
come across this problem before and can advise.

I have a basic CGI script, that loads a YAML file and prints out HTML  
and a few calculated results. The script works fine when I run it from  
the command line, but (no surprise!) I have problems when trying to  
access it from a browser. The error message in the APache log  
(abbreviated) is " No such file or directory -  
/usr/local/lib/ruby/1.8/sparc-solaris2.9/stringio.so (LoadError)  
from /usr/local/lib/ruby/1.8/yaml.rb:9"

I guess this must be something to do with permissions, or environment,  
because the file referred to _does_ exist. Broadly speaking, from a few  
basic tests, it seems that none of the ‘requires’ are working.

Any ideas?

thanks in advance

---

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [May 15, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/problem-loading-files-in-ruby-cgi-scripts/104216/2 "2007-05-15T16:23:14Z")

</div>

Only some obvious ones. Is your environment set up correctly? Does the  
Apache uid have access to those files? Are you running Apache in a  
chroot  
jail?

On 5/15/07, Toby R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> from /usr/local/lib/ruby/1.8/yaml.rb:9"  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

–  
“Hey brother christian with your high and mighty errand, Your actions  
speak  
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [May 15, 2007, 4:42pm UTC](https://www.ruby-forum.com/t/problem-loading-files-in-ruby-cgi-scripts/104216/3 "2007-05-15T16:42:19Z")

</div>

Glen H. wrote:

> Only some obvious ones. Is your environment set up correctly? Does the  
> Apache uid have access to those files? Are you running Apache in a  
> chroot  
> jail?

The file permissions seem OK (all can be read by anybody). I don’t know  
about a chroot jail (I’m not the sys admin). As far as environment is  
concerned I must admit I don’t know how to check or alter that - can you  
point me in the right direction? Thanks again.

---

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [May 15, 2007, 5:25pm UTC](https://www.ruby-forum.com/t/problem-loading-files-in-ruby-cgi-scripts/104216/4 "2007-05-15T17:25:23Z")

</div>

It sounds like your environment is probably okay, you said things work  
from  
the command line. However if Apache is running chroot then it is  
possible  
it can’t get to files on the regular filesystem. Then again the error  
message you are getting is coming from yaml.rb which it seems to find  
without any trouble.

I suppose it could be an ACL type issue although I haven’t used solaris  
in  
years and don’t know what equivalent they have.

I’m afraid without seeing the machine I can’t be of much more help. My  
suggestion would be to see if the sys admin can help you out.

Sorry.

On 5/15/07, Toby R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> point me in the right direction? Thanks again.
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

–  
“Hey brother christian with your high and mighty errand, Your actions  
speak  
so loud, I can’t hear a word you’re saying.”

-Greg Graffin (Bad Religion)

---

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [May 15, 2007, 9:01pm UTC](https://www.ruby-forum.com/t/problem-loading-files-in-ruby-cgi-scripts/104216/5 "2007-05-15T21:01:14Z")

</div>

Problem solved - my sys admin sorted me out with an .htaccess file,  
which for the record is:

SetEnv LD\_LIBRARY\_PATH  
/usr/local/lib:/usr/sfw/lib:/net/dante-sw/lib:/usr/ccs/lib:/usr/lib:/lib  
SetEnv LD\_RUN\_PATH  
/usr/local/lib:/usr/sfw/lib:/net/dante-sw/lib:/usr/ccs/lib:/usr/lib:/lib

and that did the trick!
