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
lot of 'is already being watched through' messages when using rails console if using node_modules #32700
Comments
Is the node_modules directory listed as an autoload directory? Rails and listen only watches directories that are autloaded. |
I tried to reproduce this issue and I could not. I don't see those warnings. Here are the steps that I made
|
No, I have not added it to the autoloaded paths, and it does not appear when I list them with |
Those exact steps get me the error. Maybe you don't have it because you did not use the same versions of Ruby and Rails? |
I'm not sure what could be causing that because I could not reproduce and Rails only listen to Try |
|
Does it happens with a Rails 5.2 application? That will help us to check if that is a problem that was already fixed. |
Same problem with Rails 5.2. Note that I forgot to mention that I'm using Mac OS (Sierra 10.12.6 for now), and this is maybe relevant, I think I read somewhere the creator of the gem Listen saying that Mac OS is causing trouble. Unfortunately I don't have a linux machine to test if this is OS related. Also, I just had a trouble with my npm install, I used |
I'm on Mac OS 10.13.4 with Ruby 2.5, Rails 5.2 and 5.1 and I could not reproduce this issue. And given |
I have no idea :( Maybe that would help if someone with a version of Mac OS closer to mine could test this. 10.13.4 is maybe too different from 10.12.6. Also for the record, I'm using yarn 1.6.0, and the version of puppeteer is 1.3.0. |
Is it possible there's a symlink to node_modules inside one of the autoload paths? |
@pixeltrix I haven't created any symlink. |
I believe this (watching everything inside the app root) is a known symptom of one of the watched-by-default directories being missing. I feel like the previous report involved an app that was using rspec, and therefore didn't have a @vmarquet do you have a |
@matthewd No I don't have any .railsrc, I did not even knew that existed. |
Thanks!(First of all, a heartfelt thank you @rafaelfranca and @matthewd for all of your work in Rails!, and for taking a look at this issue in particular, and @vmarquet for reporting it.) Thanks in advance for your patience with this lengthy comment, as well! I am also affectedThis issue is affecting me and I am able to reproduce it by following the steps that you demonstrated @rafaelfranca (although, mysteriously, those reproduction steps did not work for you). View my full reproduction log~/workspace 12:51:25 PM
❯ sw_vers
ProductName: Mac OS X
ProductVersion: 10.13.4
BuildVersion: 17E202
~/workspace 12:51:28 PM
❯ ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
~/workspace 12:51:35 PM
❯ rails --version
Rails 5.2.0
~/workspace 12:51:40 PM
❯ rails new foo
create
create README.md
create Rakefile
create .ruby-version
create config.ru
create .gitignore
create Gemfile
run git init from "."
Initialized empty Git repository in /Users/david/workspace/foo/.git/
create package.json
create app
create app/assets/config/manifest.js
create app/assets/javascripts/application.js
create app/assets/javascripts/cable.js
create app/assets/stylesheets/application.css
create app/channels/application_cable/channel.rb
create app/channels/application_cable/connection.rb
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/jobs/application_job.rb
create app/mailers/application_mailer.rb
create app/models/application_record.rb
create app/views/layouts/application.html.erb
create app/views/layouts/mailer.html.erb
create app/views/layouts/mailer.text.erb
create app/assets/images/.keep
create app/assets/javascripts/channels
create app/assets/javascripts/channels/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/bundle
create bin/rails
create bin/rake
create bin/setup
create bin/update
create bin/yarn
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/cable.yml
create config/puma.rb
create config/spring.rb
create config/storage.yml
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/application_controller_renderer.rb
create config/initializers/assets.rb
create config/initializers/backtrace_silencers.rb
create config/initializers/content_security_policy.rb
create config/initializers/cookies_serializer.rb
create config/initializers/cors.rb
create config/initializers/filter_parameter_logging.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/new_framework_defaults_5_2.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/master.key
append .gitignore
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create lib
create lib/tasks
create lib/tasks/.keep
create lib/assets
create lib/assets/.keep
create log
create log/.keep
create public
create public/404.html
create public/422.html
create public/500.html
create public/apple-touch-icon-precomposed.png
create public/apple-touch-icon.png
create public/favicon.ico
create public/robots.txt
create tmp
create tmp/.keep
create tmp/cache
create tmp/cache/assets
create vendor
create vendor/.keep
create test/fixtures
create test/fixtures/.keep
create test/fixtures/files
create test/fixtures/files/.keep
create test/controllers
create test/controllers/.keep
create test/mailers
create test/mailers/.keep
create test/models
create test/models/.keep
create test/helpers
create test/helpers/.keep
create test/integration
create test/integration/.keep
create test/test_helper.rb
create test/system
create test/system/.keep
create test/application_system_test_case.rb
create storage
create storage/.keep
create tmp/storage
create tmp/storage/.keep
remove config/initializers/cors.rb
remove config/initializers/new_framework_defaults_5_2.rb
run bundle install
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
Fetching gem metadata from https://rubygems.org/..............
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies....
Fetching rake 12.3.1
Installing rake 12.3.1
Using concurrent-ruby 1.0.5
Using i18n 1.0.1
Fetching minitest 5.11.3
Installing minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.2.0
Using builder 3.2.3
Using erubi 1.7.1
Using mini_portile2 2.3.0
Using nokogiri 1.8.2
Using rails-dom-testing 2.0.3
Using crass 1.0.4
Using loofah 2.2.2
Using rails-html-sanitizer 1.0.4
Using actionview 5.2.0
Using rack 2.0.5
Using rack-test 1.0.0
Using actionpack 5.2.0
Using nio4r 2.3.1
Using websocket-extensions 0.1.3
Using websocket-driver 0.7.0
Using actioncable 5.2.0
Using globalid 0.4.1
Using activejob 5.2.0
Using mini_mime 1.0.0
Using mail 2.7.0
Using actionmailer 5.2.0
Using activemodel 5.2.0
Using arel 9.0.0
Using activerecord 5.2.0
Using mimemagic 0.3.2
Using marcel 0.3.2
Using activestorage 5.2.0
Fetching public_suffix 3.0.2
Installing public_suffix 3.0.2
Fetching addressable 2.5.2
Installing addressable 2.5.2
Fetching io-like 0.3.0
Installing io-like 0.3.0
Fetching archive-zip 0.11.0
Installing archive-zip 0.11.0
Fetching bindex 0.5.0
Installing bindex 0.5.0 with native extensions
Fetching msgpack 1.2.4
Installing msgpack 1.2.4 with native extensions
Fetching bootsnap 1.3.0
Installing bootsnap 1.3.0 with native extensions
Using bundler 1.16.1
Fetching byebug 10.0.2
Installing byebug 10.0.2 with native extensions
Fetching xpath 3.0.0
Installing xpath 3.0.0
Fetching capybara 3.0.3
Installing capybara 3.0.3
Fetching ffi 1.9.23
Installing ffi 1.9.23 with native extensions
Fetching childprocess 0.9.0
Installing childprocess 0.9.0
Fetching chromedriver-helper 1.2.0
Installing chromedriver-helper 1.2.0
Fetching coffee-script-source 1.12.2
Installing coffee-script-source 1.12.2
Fetching execjs 2.7.0
Installing execjs 2.7.0
Fetching coffee-script 2.4.1
Installing coffee-script 2.4.1
Using method_source 0.9.0
Using thor 0.20.0
Using railties 5.2.0
Fetching coffee-rails 4.2.2
Installing coffee-rails 4.2.2
Fetching multi_json 1.13.1
Installing multi_json 1.13.1
Fetching jbuilder 2.7.0
Installing jbuilder 2.7.0
Fetching rb-fsevent 0.10.3
Installing rb-fsevent 0.10.3
Fetching rb-inotify 0.9.10
Installing rb-inotify 0.9.10
Fetching ruby_dep 1.5.0
Installing ruby_dep 1.5.0
Fetching listen 3.1.5
Installing listen 3.1.5
Fetching puma 3.11.4
Installing puma 3.11.4 with native extensions
Using sprockets 3.7.1
Using sprockets-rails 3.2.1
Using rails 5.2.0
Fetching rubyzip 1.2.1
Installing rubyzip 1.2.1
Fetching sass-listen 4.0.0
Installing sass-listen 4.0.0
Fetching sass 3.5.6
Installing sass 3.5.6
Fetching tilt 2.0.8
Installing tilt 2.0.8
Fetching sass-rails 5.0.7
Installing sass-rails 5.0.7
Fetching selenium-webdriver 3.11.0
Installing selenium-webdriver 3.11.0
Fetching spring 2.0.2
Installing spring 2.0.2
Fetching spring-watcher-listen 2.0.1
Installing spring-watcher-listen 2.0.1
Fetching sqlite3 1.3.13
Installing sqlite3 1.3.13 with native extensions
Fetching turbolinks-source 5.1.0
Installing turbolinks-source 5.1.0
Fetching turbolinks 5.1.1
Installing turbolinks 5.1.1
Fetching uglifier 4.1.10
Installing uglifier 4.1.10
Fetching web-console 3.6.2
Installing web-console 3.6.2
Bundle complete! 18 Gemfile dependencies, 78 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
run bundle exec spring binstub --all
* bin/rake: spring inserted
* bin/rails: spring inserted
~/workspace 12:52:47 PM
❯ cd foo/
~/workspace/foo master ✗ 12:52:51 PM
❯ npm install puppeteer
> puppeteer@1.3.0 install /Users/david/workspace/foo/node_modules/puppeteer
> node install.js
Downloading Chromium r549031 - 76 Mb [====================] 100% 0.0s
Chromium downloaded to /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031
npm notice created a lockfile as package-lock.json. You should commit this file.
+ puppeteer@1.3.0
added 41 packages in 17.496s
~/workspace/foo master ✗ 12:53:48 PM
❯ ls
Gemfile README.md app config db log package-lock.json public test vendor
Gemfile.lock Rakefile bin config.ru lib node_modules package.json storage tmp
~/workspace/foo master ✗ 12:53:58 PM
❯ spring stop
Spring is not running
~/workspace/foo master ✗ 12:54:05 PM
❯ rails c
** ERROR: directory is already being watched! **
Directory: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/Current
is already being watched through: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
** ERROR: directory is already being watched! **
Directory: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/Resources
is already being watched through: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/Resources
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
** ERROR: directory is already being watched! **
Directory: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/Libraries
is already being watched through: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/Libraries
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
** ERROR: directory is already being watched! **
Directory: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/Internet Plug-Ins
is already being watched through: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/Internet Plug-Ins
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
** ERROR: directory is already being watched! **
Directory: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/XPCServices
is already being watched through: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/XPCServices
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
** ERROR: directory is already being watched! **
Directory: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/Helpers
is already being watched through: /Users/david/workspace/foo/node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium Framework.framework/Versions/A/Helpers
MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
Running via Spring preloader in process 11287
Loading development environment (Rails 5.2.0)
irb(main):001:0>
~/workspace/foo master ✗ 12:54:24 PM
❯ ls -lh node_modules/puppeteer/.local-chromium/mac-549031/chrome-mac/Chromium.app/Contents/Versions/67.0.3391.0/Chromium\ Framework.framework/Versions/
total 0
drwxr-xr-x 8 david staff 256B May 6 12:53 A
lrwxr-xr-x 1 david staff 1B May 6 12:53 Current -> A
~/workspace/foo master ✗ 01:01:31 PM
❯ My systemI have:
Problem: symlinks within
|
@rafaelfranca I wonder if you have |
Another hacky workaround would be to prevent outputting the message to the user console, maybe something like:
|
This issue has been automatically marked as stale because it has not been commented on for at least three months. |
In my case the reason is that "app/javascript" & "app/styles" includes symlinks to a folders in "node_modules". Removing "app/javascript" & "app/styles" from |
Is there any new news on this? |
@mobilutz Unfortunately not solved it yet. |
In my case, the method directories_to_watch of # config/initializers/fixes.rb
module ActiveSupport
class EventedFileUpdateChecker
private
def directories_to_watch
dtw = (@files + @dirs.keys).map { |f| @ph.existing_parent(f) }
dtw.compact!
dtw.uniq!
normalized_gem_paths = Gem.path.map { |path| File.join path, "" }
dtw = dtw.reject do |path|
normalized_gem_paths.any? { |gem_path| path.to_s.start_with?(gem_path) }
end
dtw.delete Rails.root # added for me
@ph.filter_out_descendants(dtw)
end
end
end |
@rjurado01 Can you please provide a sample application that reproduces? |
@y-yagi Yes, I have uploaded a sample rails api project with this bug: https://github.com/rjurado01/bug_sample. It contains a |
@rjurado01 Thanks! I will investigate. |
`EventedFileUpdateChecker` will search the parent directory if the specified directory does not exist. Since `test/mailers/previews` is included in the watch target by default, if there is no test directory (e.g. using `rspec`), the Rails root directory will be included in the watch target. ``` $ rails new app $ cd app $ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)" false $ rm -rf test $ ./bin/rails r "p Rails.application.reloaders.last.send(:directories_to_watch).include?(Rails.root)" true ``` This causes `node_modules` to be included in watch target. Adding parent directories to watch target may include unexpected directories. In order to avoid this, fixed that parents of nonexistent directories are not added to the watch targets, instead checking that the directory exists when checking changes. Related to rails#32700. [Matthew Draper & Yuji Yaginuma]
Fixed by #33822. |
Currently, `factories`, `test/factories` and `spec/factories` are specified by default as reload watching paths. In many applications, there are directories which do not exist (perhaps do not have` spec` if using minitest and do not have` spec` if using minitest). In Rails 5 series, if specify a path that does not exist in `EventedFileUpdateChecker`, its parent is added to the watching path. As a result, `node_modules` is also included in the watching path, and unexpectedly many directories and files are included in listen's watching targets. Also, if symlink is included in `node_modules`, it also causes warning of listen. This issue is solved in Rails 6. However, since many applications use this gem in Rails 5 and below, it is good not to add directories that do not exist on the gem side. Ref: rails/rails#32700
Currently, `factories`, `test/factories` and `spec/factories` are specified by default as reload watching paths. In many applications, there are directories which do not exist (perhaps do not have` spec` if using minitest and do not have` spec` if using minitest). In Rails 5 series, if specify a path that does not exist in `EventedFileUpdateChecker`, its parent is added to the watching path. As a result, `node_modules` is also included in the watching path, and unexpectedly many directories and files are included in listen's watching targets. Also, if symlink is included in `node_modules`, it also causes warning of listen. This issue is solved in Rails 6. However, since many applications use this gem in Rails 5 and below, it is good not to add directories that do not exist on the gem side. Ref: rails/rails#32700
Currently, `factories`, `test/factories` and `spec/factories` are specified by default as reload watching paths. In many applications, there are directories which do not exist (perhaps do not have` spec` if using minitest and do not have` spec` if using minitest). In Rails 5 series, if specify a path that does not exist in `EventedFileUpdateChecker`, its parent is added to the watching path. As a result, `node_modules` is also included in the watching path, and unexpectedly many directories and files are included in listen's watching targets. Also, if symlink is included in `node_modules`, it also causes warning of listen. This issue is solved in Rails 6. However, since many applications use this gem in Rails 5 and below, it is good not to add directories that do not exist on the gem side. Ref: rails/rails#32700
Currently, `factories`, `test/factories` and `spec/factories` are specified by default as reload watching paths. In many applications, there are directories which do not exist (perhaps do not have` spec` if using minitest and do not have` spec` if using minitest). In Rails 5 series, if specify a path that does not exist in `EventedFileUpdateChecker`, its parent is added to the watching path. As a result, `node_modules` is also included in the watching path, and unexpectedly many directories and files are included in listen's watching targets. Also, if symlink is included in `node_modules`, it also causes warning of listen. This issue is solved in Rails 6. However, since many applications use this gem in Rails 5 and below, it is good not to add directories that do not exist on the gem side. Ref: rails/rails#32700
Currently, `factories`, `test/factories` and `spec/factories` are specified by default as reload watching paths. In many applications, there are directories which do not exist (perhaps do not have` spec` if using minitest and do not have` spec` if using minitest). In Rails 5 series, if specify a path that does not exist in `EventedFileUpdateChecker`, its parent is added to the watching path. As a result, `node_modules` is also included in the watching path, and unexpectedly many directories and files are included in listen's watching targets. Also, if symlink is included in `node_modules`, it also causes warning of listen. This issue is solved in Rails 6. However, since many applications use this gem in Rails 5 and below, it is good not to add directories that do not exist on the gem side. Ref: rails/rails#32700
Currently, `factories`, `test/factories` and `spec/factories` are specified by default as reload watching paths. In many applications, there are directories which do not exist (perhaps do not have` spec` if using minitest and do not have` spec` if using minitest). In Rails 5 series, if specify a path that does not exist in `EventedFileUpdateChecker`, its parent is added to the watching path. As a result, `node_modules` is also included in the watching path, and unexpectedly many directories and files are included in listen's watching targets. Also, if symlink is included in `node_modules`, it also causes warning of listen. This issue is solved in Rails 6. However, since many applications use this gem in Rails 5 and below, it is good not to add directories that do not exist on the gem side. Ref: rails/rails#32700
on Feb 5 master been merged? I am still running into this issue March 21;
Created rails app with Sorry new to Ruby and Rails |
I also just encountered this while setting up a new rails 6 app.
I didn't start getting the error until I included a few test gems and isolated the break to the addition of the
|
Also having this issue running rails 5.2.2.1 and after manually adding the |
I have this issue with:
|
I have this issue on 6.0.0.rc1. Can provide more info if needed. |
Can you please provide a sample application that reproduces the issue with Rails 6.0? |
@y-yagi here's a repro for Rails 6.0.0.rc1: https://github.com/jordan-brough/example-already-watched ^ See the README for repro Summary: I get the warnings just by doing this:
|
@jordan-brough Thanks for your application. This is a spring-watcher-listen's issue(Ref : #32700 (comment)). For now, please remove spring-watcher-listen from Gemfile. Thanks. |
👍 Will do, thanks! @y-yagi will this be fixed in some way for Rails 6? Is there an open issue anywhere (in I don't see this problem when using Rails 5.2.3. I assume it would be undesirable to ship Rails 6 with this? i.e. this works fine for me with no warnings:
but this generates a bunch of warnings: (and again whenever spring restarts)
|
`spring-watcher-listen` watch application root by default. https://github.com/jonleighton/spring-watcher-listen/blob/c4bfe15805867e229588e4b776a7b87438137094/lib/spring/watcher/listen.rb#L58 This is necessary to watch the file (e.g. `.ruby-version`) in the application root. By this `node_modules` also be watched, and it is a possibility to be shown a warning by `listen`. Related to rails#32700, rails#34912, rails/webpacker#1990. `listen` watches directory recursive by default, and it cannot avoid it. guard/listen#111 So If this warning happens, the only workaround the user can do is remove the gem. The issue is likely to occur more frequently in Rails 6 because `rails new` runs `webpacker:install` by default. Because of such a state, I think that we should not recommend to use `spring-watcher-listen`. Spring has polling watcher, restart process works without this `spring-watcher-listen`. Because of polling base, CPU load may be higher than listen base. Still I think that it is better than the warning comes out.
(This is not strictly a bug but more of a medium annoyance.)
Steps to reproduce
npm install puppeteer
spring stop
rails c
Expected behavior
I expect to be elegantly logged into the Rails console:
Actual behavior
Sometimes, I get a lot of error messages:
System configuration
Additional information
I looked at the Guard wiki, but that didn't really help me to solve the problem. I couldn't find how to configure Guard/Listen to ignore the
node_modules
directory.Is there a way to not watch that directory and thus prevent error messages from cluttering the Rails console? Or maybe those message could simply be filtered and not sent to the user terminal.
The text was updated successfully, but these errors were encountered: