yaml load error (when using cgi)

U

Une Bévue

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:in `load'
[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.
 
P

Peter Jones

/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?
 
U

Une Bévue

Peter Jones said:
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 !
 
P

Peter Jones


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')
`----
 
U

Une Bévue

Peter Jones said:
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 !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top