erniebrodeur / pushover

A gem to interface with pushover.net
http://erniebrodeur.github.io/pushover/
MIT License
64 stars 24 forks source link

Doesn't play well with Ubuntu Upstart #20

Closed unRob closed 6 years ago

unRob commented 9 years ago

When v1.0.4 requires bini within an Upstart script, the following error appears:

# /var/log/upstart/bini.log
/var/lib/gems/2.0.0/gems/bini-0.7.0/lib/bini/core.rb:29:in `home': couldn't find HOME environment -- expanding `~' (ArgumentError)
    from /var/lib/gems/2.0.0/gems/bini-0.7.0/lib/bini/core.rb:29:in `block in <module:Bini>'
    from /var/lib/gems/2.0.0/gems/bini-0.7.0/lib/bini/core.rb:53:in `call'
    from /var/lib/gems/2.0.0/gems/bini-0.7.0/lib/bini/core.rb:53:in `block (2 levels) in <module:Bini>'
    from /var/lib/gems/2.0.0/gems/bini-0.7.0/lib/bini/config.rb:7:in `<module:Bini>'
    from /var/lib/gems/2.0.0/gems/bini-0.7.0/lib/bini/config.rb:3:in `<top (required)>'
    from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in `require'
    from /var/lib/gems/2.0.0/gems/pushover-1.0.4/lib/pushover.rb:5:in `<top (required)>'
    from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:118:in `require'
    from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:118:in `rescue in require'
    from /usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:124:in `require'
    from /bini.rb:1:in `<main>'

Here's how to replicate the issue:

#!upstart
# /etc/init/bini.conf
description "Bini Test"

start on filesystem and started networking
stop on stopping network-services

console log
exec ruby /bini-test.rb
# /bini.rb
require 'pushover'

Just thought someone might find themselves in the same situation, the easy fix is to add env HOME=/to the script, but this seems more like a hack.

Also, great work, thanks!

erniebrodeur commented 9 years ago

Good catch, this needs a rewrite, it's been a few years since I've touched it and my skillset has gotten better.

I'll go ahead and work on this one here in the next few weeks.

cyclotron3k commented 7 years ago

I'm having the same issue. The problem is that upstart, systemd, etc, don't set the HOME environment variable, so calls to Dir.home raise an error.

env -i ruby -e Dir.home
-e:1:in `home': couldn't find HOME environment -- expanding `~' (ArgumentError)
from -e:1:in `<main>'

The error comes from require 'bini/config', which immediately calls Dir.home

erniebrodeur commented 6 years ago

Gonna close this, as I'm rewriting the code currently. Won't include bini so it won't be an issue.