rails: Unable to execute `rails` in WSL(Windows Subsystem for Linux)

Steps to reproduce

  1. In WSL in Win 10, after everything basic was setup, I installed rvm and through that I installed ruby-2.3.1 successfully.
  2. I created a gemset, and installed rails-5.0 in that gemset. After that I created a demo by rails new rails5_demo , and bundle install successfully.
  3. In rails5_demo dir, I run rails s.

Expected behavior

In the above condition, Rack server should been up and running and listening to 127.0.0.1:3000.

Actual behavior

An Error occured:

=> Booting Puma
=> Rails 5.0.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Exiting
/home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rb-inotify-0.9.7/lib/rb-inotify/watcher.rb:74:in `initialize': Invalid argument - Failed to watch "/home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/locale": the given event mask contains no legal events; or fd is not an inotify file descriptor. (Errno::EINVAL)
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rb-inotify-0.9.7/lib/rb-inotify/notifier.rb:190:in `new'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rb-inotify-0.9.7/lib/rb-inotify/notifier.rb:190:in `watch'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rb-inotify-0.9.7/lib/rb-inotify/notifier.rb:204:in `watch'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/adapter/linux.rb:32:in `_configure'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/adapter/base.rb:45:in `block in configure'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/adapter/base.rb:40:in `each'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/adapter/base.rb:40:in `configure'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/adapter/base.rb:63:in `start'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/backend.rb:28:in `start'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/listener.rb:67:in `block in <class:Listener>'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/fsm.rb:120:in `instance_eval'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/fsm.rb:120:in `call'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/fsm.rb:91:in `transition_with_callbacks!'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/fsm.rb:57:in `transition'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/listen-3.0.8/lib/listen/listener.rb:90:in `start'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/evented_file_update_checker.rb:90:in `boot!'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/evented_file_update_checker.rb:61:in `initialize'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/i18n_railtie.rb:59:in `new'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/i18n_railtie.rb:59:in `initialize_i18n'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/i18n_railtie.rb:15:in `block in <class:Railtie>'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/application/finisher.rb:65:in `block in <module:Finisher>'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `run'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/a0x/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
        from /home/a0x/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        from /home/a0x/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
        from /home/a0x/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
        from /home/a0x/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
        from /home/a0x/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
        from /home/a0x/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
        from /home/a0x/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
        from /home/a0x/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/application.rb:352:in `initialize!'
        from /home/a0x/workspace/rails5_demo/config/environment.rb:5:in `<top (required)>'
        from /home/a0x/workspace/rails5_demo/config.ru:3:in `require_relative'
        from /home/a0x/workspace/rails5_demo/config.ru:3:in `block in <main>'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
        from /home/a0x/workspace/rails5_demo/config.ru:in `new'
        from /home/a0x/workspace/rails5_demo/config.ru:in `<main>'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rack-2.0.1/lib/rack/builder.rb:49:in `eval'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rack-2.0.1/lib/rack/builder.rb:49:in `new_from_string'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rack-2.0.1/lib/rack/builder.rb:40:in `parse_file'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rack-2.0.1/lib/rack/server.rb:318:in `build_app_and_options_from_config'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rack-2.0.1/lib/rack/server.rb:218:in `app'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/commands/server.rb:59:in `app'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/rack-2.0.1/lib/rack/server.rb:353:in `wrapped_app'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/commands/server.rb:124:in `log_to_stdout'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/commands/server.rb:77:in `start'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:90:in `block in server'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `tap'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `server'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from /home/a0x/.rvm/gems/ruby-2.3.1@rails5/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

System configuration

Rails version: 5.0.0

Ruby version: ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]

Related Issue

Later I solved it temporarily using the method mentioned in the following issue: https://github.com/Microsoft/BashOnWindows/issues/451#issuecomment-225107119

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18 (4 by maintainers)

Commits related to this issue

Most upvoted comments

So I had a go at installing Rails 5 on Bash for Windows and this is what I discovered:

  1. Bundler can get in a mess (https://github.com/bundler/bundler/issues/4599)
  2. Even though the rb-inotify gem installs it’s broken (https://github.com/Microsoft/BashOnWindows/issues/216)
  3. Using rails new --skip-spring --skip-listen gives you a working app

Since the first two problems are beyond our control I think the best we can do is add a note to the getting started guide.

I didn’t see anybody mention it but to disable file watching you can edit config/environments/development.rb and comment out this line (it should be close to the bottom):

config.file_watcher = ActiveSupport::EventedFileUpdateChecker

EDIT: @aac9095

This should now work in Windows 10 Insider builds >= 14942

@pixeltrix Using rails new --skip-spring --skip-listen gives you a working app but I want to know what are we skipping and do it have some shortcoming when compared with normal rails new command?