Yaml load error (when using cgi)

i’ve a cgi wanted to make use of yaml and i get this error reported by
Apache2 :

[Tue May 06 12:25:50 2008] [error] mod_ruby: error in ruby
[Tue May 06 12:25:50 2008] [error] mod_ruby:
/opt/local/lib/ruby/1.8/yaml.rb:133:in load': syntax error on line 3, col -1: manpath: “” (ArgumentError)
[Tue May 06 12:25:50 2008] [error] mod_ruby: search: man
[Tue May 06 12:25:50 2008] [error] mod_ruby: section: “”
[Tue May 06 12:25:50 2008] [error] mod_ruby: : 1
[Tue May 06 12:25:50 2008] [error] mod_ruby:
[Tue May 06 12:25:50 2008] [error] mod_ruby: yaml:
/Users/yt/Sites/man/man_rep/history.yaml
[Tue May 06 12:25:50 2008] [error] mod_ruby: ’
[Tue May 06 12:25:50 2008] [error] mod_ruby: from
/opt/local/lib/ruby/1.8/yaml.rb:133:in load' [Tue May 06 12:25:50 2008] [error] mod_ruby: from /Users/yt/Sites/man/index.rbx:30 [Tue May 06 12:25:50 2008] [error] mod_ruby: from /opt/local/lib/ruby/1.8/apache/ruby-run.rb:53:inload’
[Tue May 06 12:25:50 2008] [error] mod_ruby: from
/opt/local/lib/ruby/1.8/apache/ruby-run.rb:53:in `handler’

the calling line being :
history=YAML::load( File.open( YAMLFILE ) )

and the yaml file being no more than :
— history.yaml ------------------------------
— !ruby/object:History
items:
!ruby/object:Item ?
manpath: “”
search: man
section: “”
: 1

yaml: /Users/yt/Sites/man/man_rep/history.yaml
— history.yaml ------------------------------

I should mention i don’t have prob when testing that apart from Apache2
and cgi.

When testing under Apache2/cgi my requirements are :
require ‘rubygems’
require ‘cgi’
require ‘fileutils’
require ‘yaml’
require ‘history’

When testing standalone:
require ‘rubygems’
require ‘yaml’
require ‘history’

the ‘history’ script being a class History of mine, nothing to do (i
believe) with the prob.

[email protected] (Une Bévue) writes:

/opt/local/lib/ruby/1.8/yaml.rb:133:in load': syntax error on line 3, col -1: manpath: “” (ArgumentError)

Can you load the yaml file from outside your CGI script? Are both the
History and Item class loaded into the runtime before you load the
yaml file?

Peter J. [email protected] wrote:

Can you load the yaml file from outside your CGI script?

Nope…

Are both the
History and Item class loaded into the runtime before you load the
yaml file?

YES, because of “rubygems”

i’ve tried :
require ‘man_rep/manpage’
require ‘rubygems’
require ‘cgi’
require ‘yaml’

=> that way probs with yaml

require ‘rubygems’
require ‘yaml’
require ‘cgi’
require ‘man_rep/manpage’

=> that way probs with rubygems (unable to find man_rep/manpage …)

but i could try something else, using “computed” absolute path for
‘man_rep/manpage’

thanks for your answer !

[email protected] (Une Bévue) writes:

Can you load the yaml file from outside your CGI script?

Nope…

I think the core issue is that your YAML file is malformed. How did
you create it?

Load it in IRB and track down the syntax error in the YAML file:

,----
| >> # load all your libs
| >> h = YAML.load_file(‘filename’)
`----

Peter J. [email protected] wrote:

I think the core issue is that your YAML file is malformed. How did
you create it?

to read it :
history_file=“man_rep/history.yaml”
history=YAML::load( File.open(history_file))

to write it:
File.open( history_file, “w” ) {|f| f.write( history.to_yaml ) }

history being an Array of Page(s), Page is a simple class of mine.

Load it in IRB and track down the syntax error in the YAML file:

I’ll look at however, i don’t think it’s corrupted because, i’ve trashed
it regularly…

thanks for the tip !

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs