Help with errors:

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.

Ted F. wrote:

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.

On Jun 16, 2010, at 6:48 PM, Ted F. wrote:

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.

How about the following solution? Beautiful, isn’t it? :wink:

Hope it helps,
Gennady.

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

--------------------------------------------------------------- IO#sync=
ios.sync = boolean => boolean

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

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

 (produces no output)