guard无法找到libnotify也无法禁用通知但是抛出错误

时间:2014-12-05 11:22:49

标签: ruby-on-rails ruby ubuntu guard libnotify

guard运行正常,直到突然出现,它抛出了这些错误:

$bin/guard
Could not open library 'libgtkmm-2.4': libgtkmm-2.4: cannot open shared object file: No such file or directory.
Could not open library 'libgtkmm-2.4.so': libgtkmm-2.4.so: cannot open shared object file: No such file or directory.
Could not open library 'libgtkmm-2.4.so.1': libgtkmm-2.4.so.1: cannot open shared object file: No such file or directory.
Could not open library 'libgtkmm-3.0': libgtkmm-3.0: cannot open shared object file: No such file or directory.
Could not open library 'libgtkmm-3.0.so': libgtkmm-3.0.so: cannot open shared object file: No such file or directory.
Could not open library 'libgtkmm-3.0.so.1': libgtkmm-3.0.so.1: cannot open shared object file: No such file or directory
13:15:58 - INFO - Guard is using Libnotify to send notifications.
13:15:58 - INFO - Guard is using TerminalTitle to send notifications.
13:15:59 - INFO - Bundle already up-to-date
13:15:59 - INFO - Guard::Rack will now restart your app on port 9292 using development environment.
13:15:59 - INFO - Restarting Rack...
libnotify.so not found!
13:15:59 - ERROR - Guard::Rack failed to achieve its <start>, exception was:
> [#4FE305F3B849] NoMethodError: undefined method `notify_init' for #<Libnotify::API:0x97a2d18>

这是guard notifiers命令(缩写):

  +-------------------+-----------+------+-----------+-------------------+
  | libnotify         | ✔         | ✘    | transient | false             |
  |                   |           |      | append    | true              |
  |                   |           |      | timeout   | 3                 |
  +-------------------+-----------+------+-----------+-------------------+
  | notifysend        | ✘         | ✘    | t         | 3000              |
  |                   |           |      | h         | "int:transient:1" |
  +-------------------+-----------+------+-----------+-------------------+
  | terminal_title    | ✔         | ✘    |           |                   |
  +-------------------+-----------+------+-----------+-------------------+
  | file              | ✘         | ✘    | format    | "%s\n%s\n%s\n"    |
  +-------------------+-----------+------+-----------+-------------------+

我已尝试在Guardfile中设置notifiers :off选项,卸载libnotify gem,但它没有效果。

我正在运行ubuntu服务器,所以我觉得我不应该有libnotify,为什么警卫突然对我这么粗鲁?

1 个答案:

答案 0 :(得分:1)

[EDIT2]

你提到你设置了notifiers :off,而不是notification :off(我自己总是混淆了这些选项)。

此外,警卫&#39;检测&#39; libnotify by requiring it here - 这意味着您的系统中有文件。

(如果没有文件,要求失败并出现LoadError并且Guard决定libnotify不可用)。

蛮力&#34;通过运行strace找出它的位置(应该在服务器上可用):

strace -f -e open bundle exec guard notifiers 2>&1 | /bin/grep -v 'ENOENT' |/bin/grep lib/libnotify.rb

对我来说,显示:

[pid 16703] open("/home/me/.rvm/gems/ruby-2.1.4@guard/gems/libnotify-0.9.0/lib/libnotify.rb", O_RDONLY|O_CLOEXEC) = 7
[pid 16703] open("/home/me/.rvm/gems/ruby-2.1.4@guard/gems/libnotify-0.9.0/lib/libnotify.rb", O_RDONLY|O_CLOEXEC) = 7

注意:您可能安装了系统红宝石,可以查看:

rvm use system
gem list libnotify

Guard只是抱怨因为宝石安装在某个地方(或者某个地方有宝石)。