Help with errors:

T

Ted Flethuseo

Hi everyone,

I was running some scripts but the following lines are giving
me errors. Now I"m not sure if this methods don't exist in ruby
or I don't have the libraries for them:


NoMethodError: undefined method `sync=' for IO:Class

at top level in writeFile.rb at line 26


NameError: undefined local variable or method ‘ruby_ode’ for main:Object

at top level in whitespace.rb at line 12

How do I update this libraries for ruby on a Mac, without ending up with
two different copies of ruby.

Ted.
 
G

Gennady Bystritsky

Hi everyone,
=20
I was running some scripts but the following lines are giving
me errors. Now I"m not sure if this methods don't exist in ruby
or I don't have the libraries for them:
=20
=20
NoMethodError: undefined method `sync=3D' for IO:Class
=20
at top level in writeFile.rb at line 26
=20
=20
NameError: undefined local variable or method =91ruby_ode=92 for main:Obj= ect
=20
at top level in whitespace.rb at line 12
=20
How do I update this libraries for ruby on a Mac, without ending up with
two different copies of ruby.

How about the following solution? Beautiful, isn't it? ;-)

Hope it helps,
Gennady.

P.S. And seriously, where's the code that does not work? As a not so wild g=
uess, you use a class method instead of the instance one.

--------------------------------------------------------------- IO#sync=3D
ios.sync =3D boolean =3D> boolean
------------------------------------------------------------------------
Sets the ``sync mode'' to true or false. When sync mode is true,=20
all output is immediately flushed to the underlying operating=20
system and is not buffered internally. Returns the new state. See=20
also IO#fsync.

f =3D File.new("testfile")
f.sync =3D true

(produces no output)
 
B

Brian Candler

Ted said:
I was running some scripts but the following lines are giving
me errors. Now I"m not sure if this methods don't exist in ruby
or I don't have the libraries for them:


NoMethodError: undefined method `sync=' for IO:Class

at top level in writeFile.rb at line 26

Show your code, i.e. contents of writeFile.rb around that line.

It looks to me like you've written

IO.sync = true

which won't work - exactly as the error says, there's no sync= method
for the IO class.

This method exists for *instances* of IO. For example:

fd = File.open("foo","w") # returns an instance of IO subclass
fd.sync = true
NameError: undefined local variable or method ‘ruby_ode’ for main:Object

at top level in whitespace.rb at line 12

Again, this looks like a bug in line 12 of whitespace.rb, which I
presume is your code since the error doesn't say
/path/to/some/lib/whitespace.rb.

You are trying to invoke a non-existent method called "ruby_ode". Why do
you think that such a method exists? Did you define it earlier? Is it in
some library, did you remember to require the library?
How do I update this libraries for ruby on a Mac, without ending up with
two different copies of ruby.

Unless you can provide evidence to the contrary, so far it looks like
the problem is nothing to do with ruby. But you need to provide more
details of both the code you are running and the exceptions you see.
Ideally, you should shrink the problem down to the smallest possible
program you can which replicates the problem, e.g.

require 'rubygems'
require 'some_strange_gem'
puts ruby_ode

Regards,

Brian.
 

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

Forum statistics

Threads
474,149
Messages
2,570,842
Members
47,388
Latest member
EarthaGilm

Latest Threads

Top