-1

i have the next code:

#! /usr/bin/env ruby
require 'dbus'
bus = DBus::SessionBus.instance

If i execute this code from desktop, it's fine. But if i execute the code in a TTY1-6 terminal i get this output:

home/migue/.rvm/gems/ruby-2.1.2/gems/ruby-dbus-0.11.0/lib/dbus/bus.rb:611:in 'address_from_file': undefined method '[]' for nil:NilClass (NoMethodError)

from /home/migue/.rvm/gems/ruby-2.1.2/gems/ruby-dbus-0.11.0/lib/dbus/bus.rb:600:in 'initialize'

from /home/migue/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/singleton.rb:141:in 'new'

from /home/migue/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/singleton.rb:141:in 'block in instance'

from /home/migue/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/singleton.rb:139:in 'synchronize'

from /home/migue/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/singleton.rb:139:in 'instance'

from bus.rb:3:in '< main >'

Any idea?

Madh
  • 131
  • 1
  • 12

1 Answers1

0

The source code reveals this line:

display = ENV["DISPLAY"][/:(\d+)\.?/, 1]

The NoMethodError occurs, because ENV["DISPLAY"] returns nil.

Setting the DISPLAY environment variable in your terminal should fix the problem.

Community
  • 1
  • 1
Stefan
  • 109,145
  • 14
  • 143
  • 218