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

run() in thread failed: undefined method `callback!' for nil:NilClass on FreeBSD #475

Closed
trombik opened this issue Apr 26, 2020 · 13 comments

Comments

@trombik
Copy link

trombik commented Apr 26, 2020

hi,

while trying to use guard, the watcher throws an exception after modifying a watched file.

[1] guard(main)> E, [2020-04-27T06:56:46.488159 #30911] ERROR -- : run() in thread failed: undefined method `callback!' for nil:NilClass:\n /usr/home/trombik/github/trombik/motbot/vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/event.rb:80:in `callback!'
/usr/home/trombik/github/trombik/motbot/vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:337:in `block in process'
/usr/home/trombik/github/trombik/motbot/vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:337:in `each'
/usr/home/trombik/github/trombik/motbot/vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:337:in `process'
/usr/home/trombik/github/trombik/motbot/vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:316:in `run'
/usr/home/trombik/github/trombik/motbot/vendor/bundle/ruby/2.6/gems/listen-3.2.1/lib/listen/adapter/bsd.rb:50:in `_run'
...

and some specs fails with the same exception when I run the specs in listen.

Failures:

  1) Listen with one listen dir force_polling option to false with default ignore options listens to subdirectory removed listen to the files of a removed directory
     Got 0 failures and 2 other errors:

     1.1) Failure/Error: @worker.run
          
          NoMethodError:
            undefined method `callback!' for nil:NilClass
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/event.rb:80:in `callback!'
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:337:in `block in process'
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:337:in `each'
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:337:in `process'
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:316:in `run'
          # ./lib/listen/adapter/bsd.rb:50:in `_run'
          # ./lib/listen/adapter/base.rb:78:in `block in start'
          # ./lib/listen/internals/thread_pool.rb:6:in `block in add'

     1.2) Failure/Error: @worker.run
          
          NoMethodError:
            undefined method `callback!' for nil:NilClass
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/event.rb:80:in `callback!'
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:337:in `block in process'
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:337:in `each'
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:337:in `process'
          # ./vendor/bundle/ruby/2.6/gems/rb-kqueue-0.2.5/lib/rb-kqueue/queue.rb:316:in `run'
          # ./lib/listen/adapter/bsd.rb:50:in `_run'
          # ./lib/listen/adapter/base.rb:78:in `block in start'
          # ./lib/listen/internals/thread_pool.rb:6:in `block in add'

  2) Listen with one listen dir force_polling option to false with default ignore options existing file.rb in listen dir listens to file.rb moved out
     Got 0 failures and 2 other errors:

     2.1) Failure/Error: @worker.run
          
          NoMethodError:
            undefined method `callback!' for nil:NilClass
...

Finished in 2 minutes 15.6 seconds (files took 0.28346 seconds to load)
322 examples, 6 failures, 1 pending

Failed examples:

rspec './spec/acceptance/listen_spec.rb[1:1:2:2:7:1]' # Listen with one listen dir force_polling option to false with default ignore options listens to subdirectory removed listen to the files of a removed directory
rspec './spec/acceptance/listen_spec.rb[1:1:2:2:2:3]' # Listen with one listen dir force_polling option to false with default ignore options existing file.rb in listen dir listens to file.rb moved out
rspec './spec/acceptance/listen_spec.rb[1:1:2:2:2:2]' # Listen with one listen dir force_polling option to false with default ignore options existing file.rb in listen dir is expected to process removal of "file.rb"
rspec './spec/acceptance/listen_spec.rb[1:1:2:2:6:2]' # Listen with one listen dir force_polling option to false with default ignore options two dirs with files in listen dir listens to dir move
rspec './spec/acceptance/listen_spec.rb[1:1:2:2:6:1]' # Listen with one listen dir force_polling option to false with default ignore options two dirs with files in listen dir listens to multiple file moves
rspec './spec/acceptance/listen_spec.rb[1:1:2:2:5:1]' # Listen with one listen dir force_polling option to false with default ignore options dir with file in listen dir listens to file move
> ruby --version 
ruby 2.6.6p146 (2020-03-31 revision 67876) [amd64-freebsd13]
> uname -msr 
FreeBSD 13.0-CURRENT amd64

as I cannot see any significant change in the bsd adapter, the issue is somewhere else, which is where i am stuck.

@gridbugs
Copy link

gridbugs commented Aug 3, 2020

I'm also running into this.

> ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-freebsd12.1]
> uname -msr
FreeBSD 12.1-RELEASE amd64

@michelboaventura
Copy link

I'm having the same problem with this configuration:

> uname -msr 
FreeBSD 12.1-RELEASE-p8 amd64
> ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-freebsd12.1]

@gridbugs
Copy link

I have a PR open which should fix this: mat813/rb-kqueue#12
Try it out by replacing the rb-kqueue line in your Gemfile with:

gem 'rb-kqueue', :git => "https://github.com/stevebob/rb-kqueue.git", :ref => "144ee7bb7963c77fc219ba736df7ee952d50ab19"

@ColinDKelley
Copy link
Collaborator

@stevebob @trombik @michelboaventura
Does it look like the fix mentioned in the PR has fixed the problem? https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=250432
Anything we need to change here in listen?

@trombik
Copy link
Author

trombik commented Nov 1, 2020

@stevebob @trombik @michelboaventura
Does it look like the fix mentioned in the PR has fixed the problem? https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=250432

I haven't tried the mentioned patch because I'm not using listen, thus rb-kqueue, from ports. With bundler, mat813/rb-kqueue#12 fixes the issue. With the patch, all the specs in listen passed.

Anything we need to change here in listen?

No. Adding a "known issue" might help other users, though.

Anyone having the issue: add the following to Gemfile

gem "rb-kqueue", git: "https://github.com/stevebob/rb-kqueue.git", branch: "handle-unexpected-events"

@ColinDKelley
Copy link
Collaborator

@trombik I'm happy to add that as a "known issue". Do those go in the README or somewhere else?

@trombik
Copy link
Author

trombik commented Nov 2, 2020

Issues / limitations in README.md is the best place, I guess. something like:

FreeBSD users need patched version of rb-kqueue (as of 2020/11). see #475 for the issue, mat813/rb-kqueue#12 for the patch, and Bug 250432 in bugzilla.

ColinDKelley added a commit to Invoca/listen that referenced this issue Nov 3, 2020
@ColinDKelley
Copy link
Collaborator

Adding to README here: a4c6095

@gregschmit
Copy link

gregschmit commented Apr 14, 2021

FYI, I'm helping out as a maintainer on rb-kqueue; the latest version (0.2.6) includes @stevebob's patch. https://rubygems.org/gems/rb-kqueue

@ColinDKelley
Copy link
Collaborator

@gregschmit Do you need anything here in listen, or is your message just an FYI?

@gregschmit
Copy link

@ColinDKelley it's just an FYI; I noticed you mentioned this issue in your README so if you want, you can remove that at some point.

@ColinDKelley
Copy link
Collaborator

@gregschmit Thanks for the clarification. I'll try to get that reference out of the README soon.

@ColinDKelley
Copy link
Collaborator

^ done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@michelboaventura @ColinDKelley @trombik @gridbugs @gregschmit and others