# Help with errors:

**URL:** <https://www.ruby-forum.com/t/help-with-errors/190146>\
**Category:** Ruby\
**Created:** [June 17, 2010, 3:48am UTC](https://www.ruby-forum.com/t/help-with-errors/190146 "2010-06-17T03:48:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tedforte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecb155/32.png) [@tedforte](https://www.ruby-forum.com/u/tedforte)\
**Post date:** [June 17, 2010, 3:48am UTC](https://www.ruby-forum.com/t/help-with-errors/190146/1 "2010-06-17T03:48:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tedforte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecb155/32.png) [@tedforte](https://www.ruby-forum.com/u/tedforte)\
**Post date:** [June 17, 2010, 9:57am UTC](https://www.ruby-forum.com/t/help-with-errors/190146/2 "2010-06-17T09:57:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tedforte](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecb155/32.png) [@tedforte](https://www.ruby-forum.com/u/tedforte)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/help-with-errors/190146/3 "2010-06-17T16:22:21Z")

</div>

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? 😉

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