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

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

Closed
a0x opened this Issue Aug 4, 2016 · 18 comments

Comments

Projects
None yet
10 participants
@a0x

a0x commented Aug 4, 2016

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:
Microsoft/WSL#451 (comment)

@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix Aug 4, 2016

Member

I suspect that the os_supports_listen_out_of_the_box? method is returning true and the listen gem is being added by default to the Gemfile.

@a0x can you let me know what RbConfig::CONFIG['host_os'] returns, e.g:

$ irb
>> RbConfig::CONFIG['host_os']
=> "darwin14.3.0" 
Member

pixeltrix commented Aug 4, 2016

I suspect that the os_supports_listen_out_of_the_box? method is returning true and the listen gem is being added by default to the Gemfile.

@a0x can you let me know what RbConfig::CONFIG['host_os'] returns, e.g:

$ irb
>> RbConfig::CONFIG['host_os']
=> "darwin14.3.0" 

@pixeltrix pixeltrix added this to the 5.0.1 milestone Aug 4, 2016

@pixeltrix pixeltrix added the railties label Aug 4, 2016

@GoldenKeyRiver

This comment has been minimized.

Show comment
Hide comment
@GoldenKeyRiver

GoldenKeyRiver Aug 4, 2016

RAILS_ENV=production rails s -b [IP of your computer]
Remember add key to ./config/secrets.yml in production.

GoldenKeyRiver commented Aug 4, 2016

RAILS_ENV=production rails s -b [IP of your computer]
Remember add key to ./config/secrets.yml in production.

@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix Aug 5, 2016

Member

To answer my own question:

bash4win

Member

pixeltrix commented Aug 5, 2016

To answer my own question:

bash4win

@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix Aug 5, 2016

Member

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 (bundler/bundler#4599)
  2. Even though the rb-inotify gem installs it's broken (Microsoft/WSL#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.

Member

pixeltrix commented Aug 5, 2016

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 (bundler/bundler#4599)
  2. Even though the rb-inotify gem installs it's broken (Microsoft/WSL#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.

@a0x

This comment has been minimized.

Show comment
Hide comment
@a0x

a0x Aug 5, 2016

@pixeltrix
First answer to your question:

2.3.1 :001 > RbConfig::CONFIG['host_os']
 => "linux-gnu"

As for bundler, I can only make it work by command rails new xxx directly. I will dig into this problem later and reply in the mentioned issue.

And of course, using --skip-listen gives a working app.

a0x commented Aug 5, 2016

@pixeltrix
First answer to your question:

2.3.1 :001 > RbConfig::CONFIG['host_os']
 => "linux-gnu"

As for bundler, I can only make it work by command rails new xxx directly. I will dig into this problem later and reply in the mentioned issue.

And of course, using --skip-listen gives a working app.

pixeltrix added a commit that referenced this issue Aug 5, 2016

Add note about limitations of Windows Subsystem for Linux
Due to the limited support for inotify (Microsoft/WSL#216) in
WSL the best thing to do at moment is add a note about skipping spring
and listen when generating your application in the Getting Started guide.

[skip ci]

Fixes #26054.

(cherry picked from commit 70f2f98)

@pixeltrix pixeltrix closed this in 70f2f98 Aug 5, 2016

@bitcrazed

This comment has been minimized.

Show comment
Hide comment
@bitcrazed

bitcrazed Oct 7, 2016

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

bitcrazed commented Oct 7, 2016

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

@pixeltrix

This comment has been minimized.

Show comment
Hide comment
@pixeltrix

pixeltrix Oct 9, 2016

Member

@bitcrazed where can I get hold of that build? The ISO download page only has 14931 as the latest. I've tried installing that and switching onto the fast ring but it's not updated in 18 hours - will it only update if I've activated the install?

Member

pixeltrix commented Oct 9, 2016

@bitcrazed where can I get hold of that build? The ISO download page only has 14931 as the latest. I've tried installing that and switching onto the fast ring but it's not updated in 18 hours - will it only update if I've activated the install?

@bitcrazed

This comment has been minimized.

Show comment
Hide comment
@bitcrazed

bitcrazed Oct 9, 2016

We tend to only post slow-ring ISO updates at the moment. Be sure to sign-up for Insiders here too: https://insider.windows.com/ if you haven't already. Also make sure to sign-in using your Microsoft ID.

bitcrazed commented Oct 9, 2016

We tend to only post slow-ring ISO updates at the moment. Be sure to sign-up for Insiders here too: https://insider.windows.com/ if you haven't already. Also make sure to sign-in using your Microsoft ID.

@aac9095

This comment has been minimized.

Show comment
Hide comment
@aac9095

aac9095 Dec 26, 2016

@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?

aac9095 commented Dec 26, 2016

@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?

@howdoicomputer

This comment has been minimized.

Show comment
Hide comment
@howdoicomputer

howdoicomputer Feb 3, 2017

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

howdoicomputer commented Feb 3, 2017

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

@Amorim2014

This comment has been minimized.

Show comment
Hide comment
@Amorim2014

Amorim2014 Feb 22, 2017

Go to you config/environments/development.rb and comment/remove out the last line,..

Use an evented file watcher to asynchronously detect changes in source code,

routes, locales, etc. This feature depends on the listen gem.

config.file_watcher = ActiveSupport::EventedFileUpdateChecker

this is new a new method that rails uses to watch changed files, but it doesn't work on WSL
Then it seems the rails server does run through .

Amorim2014 commented Feb 22, 2017

Go to you config/environments/development.rb and comment/remove out the last line,..

Use an evented file watcher to asynchronously detect changes in source code,

routes, locales, etc. This feature depends on the listen gem.

config.file_watcher = ActiveSupport::EventedFileUpdateChecker

this is new a new method that rails uses to watch changed files, but it doesn't work on WSL
Then it seems the rails server does run through .

@byrgvt

This comment has been minimized.

Show comment
Hide comment
@byrgvt

byrgvt Mar 18, 2017

Hi, I'm on fast track insider build (I think slow ring gets it too) and I think this should be resolved now. Maybe this? https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13469097-support-for-filesystem-watchers-like-inotify

I am able to create new rails apps in WSL without skipping skip-spring, skip-listen and rails works out of box. When I edit files, rails picks up changes.

Another similar issue related to filewatchers not working, gohugoio/hugo#1772, was also fixed when I upgraded my windows to insider build.

I am on build https://betanews.com/2017/03/14/windows-10-creators-update-build-15058/, which gets u1604 out of box.

byrgvt commented Mar 18, 2017

Hi, I'm on fast track insider build (I think slow ring gets it too) and I think this should be resolved now. Maybe this? https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13469097-support-for-filesystem-watchers-like-inotify

I am able to create new rails apps in WSL without skipping skip-spring, skip-listen and rails works out of box. When I edit files, rails picks up changes.

Another similar issue related to filewatchers not working, gohugoio/hugo#1772, was also fixed when I upgraded my windows to insider build.

I am on build https://betanews.com/2017/03/14/windows-10-creators-update-build-15058/, which gets u1604 out of box.

@Amorim2014

This comment has been minimized.

Show comment
Hide comment
@Amorim2014

Amorim2014 Jun 1, 2017

For me to comment on the last line ( config.file_watcher = ActiveSupport::EventedFileUpdateChecker) the file(config/environments/development.rb )worked. tanks for the tip.

Amorim2014 commented Jun 1, 2017

For me to comment on the last line ( config.file_watcher = ActiveSupport::EventedFileUpdateChecker) the file(config/environments/development.rb )worked. tanks for the tip.

@bitcrazed

This comment has been minimized.

Show comment
Hide comment
@bitcrazed

bitcrazed Jun 1, 2017

Has anyone tried this on Creators Update yet?

bitcrazed commented Jun 1, 2017

Has anyone tried this on Creators Update yet?

@a0x

This comment has been minimized.

Show comment
Hide comment
@a0x

a0x Jun 19, 2017

@bitcrazed
I tried this a couple days ago, turned out OK.
It works perfectly well on the latest Win 10 creators update.

a0x commented Jun 19, 2017

@bitcrazed
I tried this a couple days ago, turned out OK.
It works perfectly well on the latest Win 10 creators update.

@aoozdemir

This comment has been minimized.

Show comment
Hide comment
@aoozdemir

aoozdemir Jun 20, 2017

@bitcrazed I'm on build 15063.413. Using these versions for a while. It works as it should. Also, I believe spring and listen fixed as well. (\cc @byrgvt, @aac9095, @howdoicomputer)

 [~] $ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
 [~] $ rails -v
Rails 5.1.1

aoozdemir commented Jun 20, 2017

@bitcrazed I'm on build 15063.413. Using these versions for a while. It works as it should. Also, I believe spring and listen fixed as well. (\cc @byrgvt, @aac9095, @howdoicomputer)

 [~] $ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
 [~] $ rails -v
Rails 5.1.1
@tsujp

This comment has been minimized.

Show comment
Hide comment
@tsujp

tsujp Jul 3, 2017

@aoozdemir how do we check our build and update to the fixed version?

tsujp commented Jul 3, 2017

@aoozdemir how do we check our build and update to the fixed version?

@aoozdemir

This comment has been minimized.

Show comment
Hide comment
@aoozdemir

aoozdemir Jul 3, 2017

Windows + R and type winver. This will show your current build. And for the update, I didn't even sign up for the insider build. It's what released. @tsujp

aoozdemir commented Jul 3, 2017

Windows + R and type winver. This will show your current build. And for the update, I didn't even sign up for the insider build. It's what released. @tsujp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment