title: How to fix Rails 6.0.0.beta1 directory already being watched error?
body: <p>I have a new rails app running Rails 6.0.0.beta1 and I'm getting this error when I run any <code>rails</code> command such as <code>rails s</code>, <code>rails test</code>, <code>rails db:migrate</code> etc.:</p>
  
  <pre><code>** ERROR: directory is already being watched! *
  </code></pre>
  
  <p>I also get it when running <code>bundle exec guard</code></p>
  
  <p>I've been googling this error quite a bit and can't figure out what's causing it. Does anyone know what might be causing this?</p>
  
  <p>Here's a full trace of the error:</p>
  
  <p>rails s
  => Booting Puma
  => Rails 6.0.0.beta1 application starting in development 
  => Run <code>rails server --help</code> for more startup options
          ** ERROR: directory is already being watched! **</p>
  
  <pre><code>    Directory: /Users/lee/Documents/Code/dashboard/node_modules/.bin/compression-webpack-plugin
  
      is already being watched through: /Users/lee/Documents/Code/dashboard/node_modules/compression-webpack-plugin
  
      MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
      ** ERROR: directory is already being watched! **
  
      Directory: /Users/lee/Documents/Code/dashboard/node_modules/.bin/mini-css-extract-plugin
  
      is already being watched through: /Users/lee/Documents/Code/dashboard/node_modules/mini-css-extract-plugin
  
      MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
      ** ERROR: directory is already being watched! **
  
      Directory: /Users/lee/Documents/Code/dashboard/node_modules/@rails/webpacker/node_modules/.bin/compression-webpack-plugin
  
      is already being watched through: /Users/lee/Documents/Code/dashboard/node_modules/compression-webpack-plugin
  
      MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
      ** ERROR: directory is already being watched! **
  
      Directory: /Users/lee/Documents/Code/dashboard/node_modules/@rails/webpacker/node_modules/.bin/mini-css-extract-plugin
  
      is already being watched through: /Users/lee/Documents/Code/dashboard/node_modules/mini-css-extract-plugin
  
      MORE INFO: https://github.com/guard/listen/wiki/Duplicate-directory-errors
  </code></pre>
  
  <p>And, here's my Gemfile:</p>
  
  <pre><code>    source 'https://rubygems.org'
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
  
  ruby '2.6.0'
  
  # Rails 6
  gem 'rails', '~&gt; 6.0.0.beta1'
  gem 'puma', '~&gt; 3.11'
  gem 'sass-rails', '~&gt; 5.0'
  gem 'webpacker', '&gt;= 4.0.0.rc.3'
  gem 'turbolinks', '~&gt; 5'
  gem 'jbuilder', '~&gt; 2.5'
  gem 'bootsnap', '&gt;= 1.1.0', require: false
  
  # App Specific gems
  gem 'clearance'
  gem 'pundit'
  
  # Development and test
  group :development, :test do
    gem 'sqlite3'
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    gem 'factory_bot_rails'
    gem 'launchy'
  end
  
  group :development do
    gem 'web-console', '&gt;= 3.3.0'
    gem 'listen', '&gt;= 3.0.5', '&lt; 3.2'
    gem 'spring'
    gem 'spring-watcher-listen', '~&gt; 2.0.0'
  end
  
  group :test do
    gem 'capybara', '&gt;= 2.15'
    gem 'capybara-webkit'
    gem 'capybara-email'
    gem 'faker'
    gem 'database_cleaner'
    gem 'rails-controller-testing'
    gem 'minitest'
    gem 'minitest-reporters'
    gem 'guard'
    gem 'guard-minitest'
  end
  
  group :production do
    gem 'pg'
  end
  </code></pre>
  
  <p>And my Guardfile:</p>
  
  <pre><code># Defines the matching rules for Guard.
  guard :minitest, spring: "bin/rails test", all_on_start: false do
    watch(%r{^test/(.*)/?(.*)_test\.rb$})
    watch('test/test_helper.rb') { 'test' }
    watch('config/routes.rb')    { integration_tests }
    watch(%r{^app/models/(.*?)\.rb$}) do |matches|
      "test/models/#{matches[1]}_test.rb"
    end
    watch(%r{^app/controllers/(.*?)_controller\.rb$}) do |matches|
      resource_tests(matches[1])
    end
    watch(%r{^app/views/([^/]*?)/.*\.html\.erb$}) do |matches|
      ["test/controllers/#{matches[1]}_controller_test.rb"] +
      integration_tests(matches[1])
    end
    watch(%r{^app/helpers/(.*?)_helper\.rb$}) do |matches|
      integration_tests(matches[1])
    end
    watch('app/views/layouts/application.html.erb') do
      'test/integration/site_layout_test.rb'
    end
    watch('app/helpers/sessions_helper.rb') do
      integration_tests &lt;&lt; 'test/helpers/sessions_helper_test.rb'
    end
    watch('app/controllers/sessions_controller.rb') do
      ['test/controllers/sessions_controller_test.rb',
       'test/integration/users_login_test.rb']
    end
    watch('app/controllers/account_activations_controller.rb') do
      'test/integration/users_signup_test.rb'
    end
  end
  
  # Returns the integration tests corresponding to the given resource.
  def integration_tests(resource = :all)
    if resource == :all
      Dir["test/integration/*"]
    else
      Dir["test/integration/#{resource}_*.rb"]
    end
  end
  
  # Returns the controller tests corresponding to the given resource.
  def controller_test(resource)
    "test/controllers/#{resource}_controller_test.rb"
  end
  
  # Returns all tests for the given resource.
  def resource_tests(resource)
    integration_tests(resource) &lt;&lt; controller_test(resource)
  end
  </code></pre>
  
  <p>This only seems to be happening with Rails 6. I have a similar app setup on Rails 5 and I'm not getting this error.</p>