# Etc.dir, Etc.name

**URL:** <https://www.ruby-forum.com/t/etc-dir-etc-name/72970>\
**Category:** Ruby\
**Created:** [October 20, 2006, 9:41am UTC](https://www.ruby-forum.com/t/etc-dir-etc-name/72970 "2006-10-20T09:41:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [October 20, 2006, 9:41am UTC](https://www.ruby-forum.com/t/etc-dir-etc-name/72970/1 "2006-10-20T09:41:21Z")

</div>

I found some of the Etc functions missing which are mentioned in  
Matsumoto’s book “Ruby in a nutshell”, for example Etc.dir and  
Etc.shell. OTOH, Etc.name exists (for example):

irb(main):002:0\> Etc.dir  
NoMethodError: undefined method `dir' for Etc:Module from (irb):2 irb(main):003:0> Etc.name => "Etc" irb(main):004:0> Etc.shell NoMethodError: undefined method`shell’ for Etc:Module  
from (irb):4  
from :0

I’m running the following Ruby version:

$ irb --version  
irb 0.9.5(05/04/13)  
$ ruby --version  
ruby 1.8.4 (2005-12-24) [i686-linux]

As the book was published 2001, it can’t be that I just have an  
outdated Ruby version.

What am I doing wrong here?

Ronald

---

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [October 20, 2006, 10:09am UTC](https://www.ruby-forum.com/t/etc-dir-etc-name/72970/2 "2006-10-20T10:09:24Z")

</div>

Hi,

In message “Re: Etc.dir, Etc.name”  
on Fri, 20 Oct 2006 16:40:13 +0900, Ronald F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
writes:

|I found some of the Etc functions missing which are mentioned in  
|Matsumoto’s book “Ruby in a nutshell”, for example Etc.dir and  
|Etc.shell. OTOH, Etc.name exists (for example):  
|  
|irb(main):002:0\> Etc.dir  
|NoMethodError: undefined method `dir' for Etc:Module | from (irb):2 |irb(main):003:0> Etc.name |=> "Etc" |irb(main):004:0> Etc.shell |NoMethodError: undefined method `shell’ for Etc:Module  
| from (irb):4  
| from :0

I don’t have the book at hand right now (since I am staying at the  
hotel in Denver for RubyConf), but Etc module never had methods dir  
and shell. If it says so, it is a bug in the book. Sorry.

Actually, the value returned from Etc#getpwnam has dir and shell  
methods. Use them as in the following code:

pw = Etc.getpwnam(‘root’)  
p pw.dir # root’s home directory  
p pw.shell # root’s shell

```
						matz.

```

---

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [October 23, 2006, 9:06am UTC](https://www.ruby-forum.com/t/etc-dir-etc-name/72970/3 "2006-10-23T09:06:58Z")

</div>

Yukihiro M. schrieb:

> I don’t have the book at hand right now (since I am staying at the  
> hotel in Denver for RubyConf), but Etc module never had methods dir  
> and shell. If it says so, it is a bug in the book. Sorry.
> 
> Actually, the value returned from Etc#getpwnam has dir and shell  
> methods.

Sorry, you are right. I did not pay enough attention to this. So, no  
error in the book.

Ronald
