# The error occurred while evaluating nil.chop

**URL:** <https://www.ruby-forum.com/t/the-error-occurred-while-evaluating-nil-chop/169395>\
**Category:** Rails\
**Created:** [June 3, 2009, 9:03am UTC](https://www.ruby-forum.com/t/the-error-occurred-while-evaluating-nil-chop/169395 "2009-06-03T09:03:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yasir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9f8e36/32.png) [@yasir](https://www.ruby-forum.com/u/yasir)\
**Post date:** [June 3, 2009, 9:03am UTC](https://www.ruby-forum.com/t/the-error-occurred-while-evaluating-nil-chop/169395/1 "2009-06-03T09:03:04Z")

</div>

Hi,

I am new to Ruby, while running a project I get the following errors:

C:\cairns\cairns\cairns\script\>ruby server  
=\> Booting WEBrick…  
server: No such file or directory - uname  
C:/cairns/cairns/cairns/app/models/node.rb:74:in `get_hostname': You have a nil object when you didn't expect it! (NoMethodError) The error occurred while evaluating nil.chop from C:/cairns/cairns/cairns/app/models/node.rb:60:in`initialize’  
from ./…/config/…/config/environment.rb:65:in `new' from ./../config/../config/environment.rb:65 from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 31:in`ge  
m\_original\_require’  
from C:/Ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:  
31:in `re quire' from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_suppo rt/dependencies.rb:495:in`require’  
from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/  
active\_suppo  
rt/dependencies.rb:342:in `new_constants_in' from C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/ active_suppo rt/dependencies.rb:495:in`require’  
… 6 levels…  
from C:/Ruby/lib/ruby/gems/1.8/gems/rails-1.2.5/lib/commands/  
server.rb:3  
9  
from C:/Ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:  
31:in `ge m_original_require' from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb: 31:in`re  
quire’  
from server:3

Need Help!

Kind Regards,

---

<div class="post-metadata">

**Author:** ![yasir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9f8e36/32.png) [@yasir](https://www.ruby-forum.com/u/yasir)\
**Post date:** [June 3, 2009, 4:57pm UTC](https://www.ruby-forum.com/t/the-error-occurred-while-evaluating-nil-chop/169395/2 "2009-06-03T16:57:38Z")

</div>

Don’t cd into the script dir, instead call it from the project root:

ruby script/server

---

<div class="post-metadata">

**Author:** ![yasir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9f8e36/32.png) [@yasir](https://www.ruby-forum.com/u/yasir)\
**Post date:** [June 3, 2009, 4:59pm UTC](https://www.ruby-forum.com/t/the-error-occurred-while-evaluating-nil-chop/169395/3 "2009-06-03T16:59:25Z")

</div>

On Jun 3, 10:56 am, jemminger [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Don’t cd into the script dir, instead call it from the project root:
> 
> ruby script/server

Actually that doesn’t seem to matter - the problem is that you’re  
trying to call chop() on nil here:

C:/cairns/cairns/cairns/app/models/node.rb:60:in `initialize’

---

<div class="post-metadata">

**Author:** ![yasir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/9f8e36/32.png) [@yasir](https://www.ruby-forum.com/u/yasir)\
**Post date:** [June 3, 2009, 5:45pm UTC](https://www.ruby-forum.com/t/the-error-occurred-while-evaluating-nil-chop/169395/4 "2009-06-03T17:45:54Z")

</div>

Also, if you’re trying to get the machine’s hostname, instead of  
invoking the shell to call uname or hostname or whatever, just use  
Socket.gethostname.
