-
-
Notifications
You must be signed in to change notification settings - Fork 372
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
Reloading Issue Triggering Resolved Rails Bug #328
Comments
Hm, this should have been fixed by f718048, which went out in factory_bot_rails 5.0.1 Thanks for the report! |
Having the same |
@TeTiRoss what version of factory_bot_rails are you using? |
@composerinteralia |
@BintLopez I wasn't able to reproduce this with the steps you provided. Is there something I am missing? rails new testing
cd testing
echo "gem 'factory_bot_rails', '~> 5.0', '>=5.0.1', group: [:test, :development]" >> Gemfile
bundle install
bin/rails s I didn't see any error messages. Also, I went into the console and checked that the factory_bot_rails reloader was not actually watching any files (as expected with f718048) : Rails.application.reloaders.first.send(:directories_to_watch)
#=> [] I am using: I tried these steps on 6.0.0.beta3 as well and had the same results. I am especially surprised you are seeing this on 6.0.0.beta3, since rails/rails#33822 was included in that release. |
I also encountered this error on |
I ran through the repro steps with a fresh rails project (using 6.0.0.beta3) and was able to reproduce with both ruby 2.5.3 and ruby 2.6.2. This is using |
@yazumoto that makes sense, since the fix in f718048 went out in factory_bot_rails 5.0.1. Thanks for letting me know! @BintLopez would you be to share a link to the fresh rails project you used to reproduce this? Thanks for your help! |
@composerinteralia -- here's the repo that triggers the error for me: https://github.com/BintLopez/testing_bug_repro. What I did to reproduce was Based on the write up at the link from the error https://github.com/guard/listen/wiki/Duplicate-directory-errors ... this appears to be a bug in how |
@BintLopez unfortunately I still am not seeing the error in your test repo. It seems like we are following exactly the same steps, so I am not sure what is different. I would be curious to know what you get if you start a rails console and type: |
Thanks for that command! Running that returns an empty array. But looking at it for all the reloaders returned the following... Rails.application.reloaders.map{|r| r.send(:directories_to_watch) if r.respond_to?(:directories_to_watch, true)}
=> [
[],
[#<Pathname:/Users/path/to/my/project/config/locales>],
nil,
[#<Pathname:/Users/path/to/my/project/db>,
#<Pathname:Users/path/to/my/project/app/channels>,
#<Pathname:/Users/path/to/my/project/app/controllers>,
#<Pathname:/Users/path/to/my/project/app/helpers>,
#<Pathname:/Users/path/to/my/project/app/jobs>,
#<Pathname:/Users/path/to/my/project/app/mailers>,
#<Pathname:/Users/path/to/my/project/app/models>,
#<Pathname:/Users/path/to/my/project/test/mailers/previews>]
] ^^ I don't see anything in there that would be loading the js (at first glance) Also, another data point -- a friend of mine ran the same code and was not able to reproduce the same issue. This makes me think it's something about dev env that's in the works here. I use rbenv for ruby version, nvm for node versioning, homebrew (maybe brew has something to do since it's symlinks?). Running in a mac os. At any rate, this isn't a blocker for me, and shouldn't affect production since |
That reloader output looks right to me:
I am stumped. Let me know if that patch helps and maybe we can work backwards from there. |
@y-yagi do you have any ideas about what might be going on here? |
Thank you for the mention. I think this is an issue of Rails.
I will fix this on Rails side first. But considering the old Rails version, I think it would be better to fix the @composerinteralia I think it's better not to call |
Aha! That makes sense. Thanks so much for your help. Yeah, I agree we should fix it on the |
👍 I will create a PR later. |
If all the paths specified in `FactoryBot.definition_file_paths` do not exist, an empty array is passed to the reloader. If an empty array is specified, reloader passes it to `Listen.to` as it is. This causes the application root to be watched and `node_modules` to become a target of listening. The behavior when an empty array is passed to reloader depends on the Rails side. Fixes to not register a reloader when file paths do not exist consistent behavior regardless of Rails side. Fixes thoughtbot#328.
If all the paths specified in `FactoryBot.definition_file_paths` do not exist, an empty array is passed to the reloader. If an empty array is specified, reloader passes it to `Listen.to` as it is. This causes the application root to be watched and `node_modules` to become a target of listening. The behavior when an empty array is passed to reloader depends on the Rails side. Fixes to not register a reloader when file paths do not exist consistent behavior regardless of Rails side. Fixes thoughtbot#328.
If all the paths specified in `FactoryBot.definition_file_paths` do not exist, an empty array is passed to the reloader. If an empty array is specified, reloader passes it to `Listen.to` as it is. This causes the application root to be watched and `node_modules` to become a target of listening. The behavior when an empty array is passed to reloader depends on the Rails side. Fixes to not register a reloader when file paths do not exist consistent behavior regardless of Rails side. Fixes thoughtbot#328.
If all the paths specified in `FactoryBot.definition_file_paths` do not exist, an empty array is passed to the reloader. If an empty array is specified, reloader passes it to `Listen.to` as it is. This causes the application root to be watched and `node_modules` to become a target of listening. The behavior when an empty array is passed to reloader depends on the Rails side. Fixes to not register a reloader when file paths do not exist consistent behavior regardless of Rails side. Fixes #328.
Related Rails issue: rails/rails#32700
Steps to reproduce
gem 'factory_bot_rails', '~> 5.0', '>= 5.0.1'
to the gemfilebundle install
bundle exec rails s
Expected behavior
Adding
factory_bot_rails
gem to a rails project should not trigger** ERROR: directory is already being watched! **
when booting up a rails server or consoleActual behavior
After including the gem in my project, I'm getting the following errors in my server when running the rails server...
System configuration
Rails version: 6.0.0.beta3
Ruby version: 2.5.3
The text was updated successfully, but these errors were encountered: