Skip to content
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
Closed

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

a0x opened this issue Aug 4, 2016 · 18 comments
Labels
Milestone

Comments

@a0x
Copy link

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
Copy link
Contributor

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
@GoldenKeyRiver
Copy link

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

@pixeltrix
Copy link
Contributor

To answer my own question:

bash4win

@pixeltrix
Copy link
Contributor

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 (Error Installing Bundler - Parent Directory is World Writable but not Sticky rubygems/bundler#4599)
  2. Even though the rb-inotify gem installs it's broken (Filesystem watchers like libinotify do not work 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
Copy link
Author

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
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)
@bitcrazed
Copy link

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

@pixeltrix
Copy link
Contributor

@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
Copy link

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.

@ayushchauhan0811
Copy link

@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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

Has anyone tried this on Creators Update yet?

@a0x
Copy link
Author

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.

@rwxdash
Copy link

rwxdash 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
Copy link

tsujp commented Jul 3, 2017

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

@rwxdash
Copy link

rwxdash 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
Labels
Projects
None yet
Development

No branches or pull requests

10 participants