Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard gem does not work on JRuby 9.1.8.0 #4527

Closed
yujideveloper opened this issue Mar 9, 2017 · 4 comments
Closed

Guard gem does not work on JRuby 9.1.8.0 #4527

yujideveloper opened this issue Mar 9, 2017 · 4 comments

Comments

@yujideveloper
Copy link

Environment

Provide at least:

  • JRuby version: jruby 9.1.8.0 (2.3.1) 2017-03-06 90fc7ab OpenJDK 64-Bit Server VM 25.111-b15 on 1.8.0_111-b15 +jit [linux-x86_64]
  • Operating system: CentOS Linux release 7.2.1511 (Core) / Linux 3.10.0-123.el7.x86_64
  • Guard version: 2.14.1 (with guard-rubocop 1.2.0)
  • Bundler version: 1.13.7

Expected Behavior

  • No error occurs

Actual Behavior

  • Following error has occurred:
$ bundle exec guard -i -d
21:45:53 - DEBUG - Notiffany: gntp not available (Please add "gem 'ruby_gntp'" to your Gemfile and run your app with "bundle exec".).
21:45:53 - DEBUG - Notiffany: growl not available (Unsupported platform "linux").
21:45:53 - DEBUG - Notiffany: terminal_notifier not available (Unsupported platform "linux").
21:45:53 - DEBUG - Notiffany: libnotify not available (Please add "gem 'libnotify'" to your Gemfile and run your app with "bundle exec".).
21:45:53 - DEBUG - Command execution: which notify-send
21:45:53 - DEBUG - Notiffany: notifysend not available (libnotify-bin package is not installed).
21:45:53 - DEBUG - Notiffany: notifu not available (Unsupported platform "linux").
21:45:53 - DEBUG - Command execution: {"ALTERNATE_EDITOR"=>"false"} emacsclient --eval '1'
org/jruby/RubyProcess.java:1566:in `spawn': Inappropriate ioctl for device - emacsclient (Errno::ENOTTY)
        from org/jruby/RubyKernel.java:1517:in `spawn'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/stdlib/open3.rb:206:in `popen_run'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/stdlib/open3.rb:102:in `popen3'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/guard-2.14.1/lib/guard/internals/tracing.rb:15:in `block in popen3'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/shellany-0.0.1/lib/shellany/sheller.rb:116:in `_system_with_capture'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/shellany-0.0.1/lib/shellany/sheller.rb:46:in `run'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/shellany-0.0.1/lib/shellany/sheller.rb:25:in `run'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier/emacs/client.rb:47:in `_emacs_eval'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier/emacs/client.rb:36:in `available?'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier/emacs.rb:33:in `_check_available'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier/base.rb:59:in `initialize'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier/detected.rb:100:in `_add'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier/detected.rb:62:in `block in detect'
        from org/jruby/RubyHash.java:1343:in `each'
        from org/jruby/RubyEnumerable.java:626:in `detect'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier/detected.rb:60:in `block in detect'
        from org/jruby/RubyArray.java:1734:in `each'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier/detected.rb:59:in `detect'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier.rb:180:in `_detect_or_add_notifiers'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier.rb:198:in `_activate'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier.rb:87:in `initialize'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/notiffany-0.1.1/lib/notiffany/notifier.rb:42:in `connect'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/guard-2.14.1/lib/guard/notifier.rb:11:in `connect'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/guard-2.14.1/lib/guard.rb:61:in `setup'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/guard-2.14.1/lib/guard/commander.rb:32:in `start'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/guard-2.14.1/lib/guard/cli/environments/valid.rb:16:in `start_guard'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/guard-2.14.1/lib/guard/cli.rb:122:in `start'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/guard-2.14.1/lib/guard/aruba_adapter.rb:32:in `execute'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/guard-2.14.1/lib/guard/aruba_adapter.rb:19:in `execute!'
        from /home/vagrant/.rbenv/versions/jruby-9.1.8.0/lib/ruby/gems/shared/gems/guard-2.14.1/bin/_guard-core:11:in `<main>'
@headius
Copy link
Member

headius commented Mar 9, 2017

Icky.

@headius
Copy link
Member

headius commented Mar 9, 2017

I can reproduce on 9.1.8.0 locally with a default Guardfile.

It does not fail with 9.1.7.0. This appears to be a regression, probably from bfb5eeb.

@enebo Looks like we might want a 9.1.9 sooner rather than later.

@headius
Copy link
Member

headius commented Mar 9, 2017

Ok, this is kinda funny.

So my TTY change above caused this to regress, but only because it exposed a bug in our spawn logic. When you spawn a command that doesn't exist (emacsclient in this case) it should raise ENOENT. This is handled by various pieces of logic along the spawn/open3 pipeline. The logic for the error lives in PopenExecutor.procSpawnCmdInternal when it uses dlnFindExeR to see if the spawn executable exists. It sets a pseduo-errno we maintain insdie the PopenExecutor to ENOENT and returns -1. However, when that -1 (pid) gets back to PopenExecutor.spawnProcess it erroneously tries to get the real errno. Because we started checking IO objects for TTYness in 9.1.8.0, the errno just happens to be ENOTTY at that point.

I have two fixes I will make:

  1. Check the pseudo-errno rather than the real errno at this point.
  2. Clear the real errno after our TTY check to avoid other cases.

You can work around this in 9.1.8.0 by making a no-op emacsclient command.

~/projects/jruby/tmp $ touch emacsclient

~/projects/jruby/tmp $ chmod +x emacsclient 

~/projects/jruby/tmp $ PATH=$PATH:. guard -d -i
14:15:45 - ERROR - No plugins found in Guardfile, please add at least one.
14:15:45 - DEBUG - Notiffany: gntp not available (Please add "gem 'ruby_gntp'" to your Gemfile and run your app with "bundle exec".).
14:15:45 - DEBUG - Notiffany: growl not available (Unsupported platform "linux").
14:15:45 - DEBUG - Notiffany: terminal_notifier not available (Unsupported platform "linux").
14:15:45 - DEBUG - Notiffany: libnotify not available (Please add "gem 'libnotify'" to your Gemfile and run your app with "bundle exec".).
14:15:45 - DEBUG - Command execution: which notify-send
14:15:45 - DEBUG - Command execution: {"ALTERNATE_EDITOR"=>"false"} emacsclient --eval '1'
14:15:45 - DEBUG - Notiffany: tmux not available (:tmux notifier is only available inside a TMux session.).
14:15:45 - DEBUG - Notiffany: file not available (No :path option given).
14:15:45 - DEBUG - Command execution: which notify-send
14:15:45 - DEBUG - Command execution: {"ALTERNATE_EDITOR"=>"false"} emacsclient --eval '1'
14:15:45 - DEBUG - Notiffany is using NotifySend to send notifications.
14:15:45 - DEBUG - Notiffany is using Emacs to send notifications.
14:15:45 - DEBUG - Notiffany is using TerminalTitle to send notifications.
The signal USR1 is in use by the JVM and will not work correctly on this platform
14:15:46 - DEBUG - Guard starts all plugins
14:15:46 - INFO - Guard is now watching at '/home/headius/projects/jruby/tmp'
14:15:46 - DEBUG - Guards jobs done. Sleeping...

👍

@headius
Copy link
Member

headius commented Mar 9, 2017

On second thought I won't make the change to the TTY logic. MRI does not do it, and if other places are using real errno when they should not be, it would be better to find them.

@headius headius closed this as completed in bafb4f5 Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants