The error occurred while evaluating nil.chop

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:ininitialize’
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:inge
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:inrequire’
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:inrequire’
… 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:inre
quire’
from server:3

Need Help!

Kind Regards,

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

ruby script/server

On Jun 3, 10:56 am, jemminger [email protected] 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’

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.