Save 36% for Black Friday! Learn more

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Setup Windows 10 Discussion

Chris Oliver asked in General

Hi,

I got all the way through this so thanks for the walk through! I run "rails server -b 0.0.0.0" and the server boots fine but when I go to localhost:3000 in the browser, the browser icon spins but the server does not respond. Has anyone seen this before?

Reply

For any newcomers experiencing this issue:

Run ifconfig then select the appropriate ipv4 ---> inet addr address for your ethernet adapter (Typically eth0).

Example:

eth0 Link encap:Ethernet HWaddr 30:9c:00:a0:93:b5
inet addr:192.168.1.236 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::d400:af9d:a16e:0000/64 Scope:Global
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Then once you find your local IPV4 you can go to your browser and type your address plus the appropriate port, in my case 192.168.1.236:3000

Which will succesfully connect you to your Ubuntu bash rails server on your local machine!

As for anyone experiencing the issue of rails or gem commands not working after exiting and re-entering bash; you need to ensure you are running shell commands, you can acheive this by running exec $SHELL and possibly the few commands prior as laid out in the Installing Ruby portion of this tutorial.

IMPORTANT UPDATE (9/29/2018):
Per the instructions HERE, nate clarifies something extremely important regarding switching users via su. In order to succesfully execute .profile you must use su - user, where su simply switches users, while su - ... is an alias to su user --login || su user -l which then allows you to succesfully execute gem, rails, and bundler commands whereas they would normally be unavailable (command not found). This is a nicer way of doing things, rather than my solution of running exec $SHELL every time, one less command! Woohoo!

Cheers!

As of 9/28/2018

Reply

I've worked it out now. It seems that thin was the problem. I switched to webrick and the app now runs perfectly. I don't exactly no what the problem was with thin but this solution works for now!

Reply

So cool. I have been waiting for you to write this :)

Reply

This is great tut- based on it I installed rails 5 and ruby 2.3.1. created new test app and after rails -s I have something like this: => Booting Puma
=> Rails 5.0.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Exiting
/root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify/watcher.rb:74:in `initialize': Invalid argument - Failed to watch "/root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/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 /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify/notifier.rb:190:in `new'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify/notifier.rb:190:in `watch'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rb-inotify-0.9.7/lib/rb-inotify/notifier.rb:204:in `watch'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/linux.rb:32:in `_configure'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:45:in `block in configure'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:40:in `each'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:40:in `configure'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/adapter/base.rb:63:in `start'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/backend.rb:28:in `start'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/listener.rb:67:in `block in <class:listener>'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:120:in `instance_eval'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:120:in `call'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:91:in `transition_with_callbacks!'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/fsm.rb:57:in `transition'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/listen-3.0.8/lib/listen/listener.rb:90:in `start'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/evented_file_update_checker.rb:90:in `boot!'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/evented_file_update_checker.rb:61:in `initialize'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/i18n_railtie.rb:59:in `new'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/i18n_railtie.rb:59:in `initialize_i18n'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/i18n_railtie.rb:15:in `block in <class:railtie>'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:44:in `each'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activesupport-5.0.0/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/application/finisher.rb:65:in `block in <module:finisher>'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `instance_exec'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/initializable.rb:30:in `run'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /root/.rbenv/versions/2.3.1/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/initializable.rb:54:in `run_initializers'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/application.rb:352:in `initialize!'
from /root/myapp/config/environment.rb:5:in `<top (required)="">'
from /root/myapp/config.ru:3:in `require_relative'
from /root/myapp/config.ru:3:in `block in <main>'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
from /root/myapp/config.ru:in `new'
from /root/myapp/config.ru:in `<main>'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:49:in `eval'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:49:in `new_from_string'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/builder.rb:40:in `parse_file'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/server.rb:318:in `build_app_and_options_from_config'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/server.rb:218:in `app'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/server.rb:59:in `app'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rack-2.0.1/lib/rack/server.rb:353:in `wrapped_app'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/server.rb:124:in `log_to_stdout'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/server.rb:77:in `start'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:90:in `block in server'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `tap'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:85:in `server'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/railties-5.0.0/lib/rails/commands.rb:18:in `<top (required)="">'
from /root/myapp/bin/rails:9:in `require'
from /root/myapp/bin/rails:9:in `<top (required)="">'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `load'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/rails.rb:28:in `call'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/client/command.rb:7:in `call'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/client.rb:30:in `run'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/bin/spring:49:in `<top (required)="">'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `load'
from /root/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/spring-1.7.2/lib/spring/binstub.rb:11:in `<top (required)="">'
from /root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /root/.rbenv/versions/2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /root/myapp/bin/spring:13:in `<top (required)="">'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
Any ideas what should I do ?

Reply

According to this site[1] you can omment out "config.file_watcher = ActiveSupport::EventedFileUpdateChecker" in this file, config/environments/development.rb

[1]:https://github.com/rails/ra...

Reply

The main issue here is that inotify has been completely broken in WSL. So even if you disable listeners, tools like Guard won't work. Insiders are soon getting a partial fix, whereby files changed within WSL itself can be watched without errors.

Here's the test. First install inotify-tools, which give you some command line programs to monitor files:

$ sudo apt-get install inotify-tools

Then attempt to watch any file from the command line:

$ touch testfile.txt && inotifywatch testfile.txt
Establishing watches...
Failed to watch ./testfile.txt: Invalid argument

Note that's the same error that rb-inotify reports above.

Github issues:
https://github.com/Microsof...
https://github.com/Microsof...

Reply

I get the error like : `sudo: setresuid() [1000, 106, 1000] -> [-1, 0, -1]: Operation not permitted` when I try to create new postgres user. Is it going to be fix in the nearest feature?

Reply
Abhinav Tripathi Abhinav Tripathi

why does this blog have no support?
people are facing multiple issues!

Reply
Kevin Méndez Kevin Méndez

Hi, friend! You can install postgres in windows. To connect the app you only need a port of the database (I had the same issue at the beginin).

Reply
Stefan Cardenas Stefan Cardenas

I'm getting the same error and can't figure out how to get around it. I've tried uninstalling and reinstalling Postgresql to no avail. Any thoughts?

Reply
Reply

How were you able to get the terminal to let you copy the SSH key so that you could paste it into GitHub? Copy and paste is not working for me using shortcuts or the mouse, and there is no menu that I can see.

Reply

RIght click on the Ubuntu icon, go to properties and check the boxes under Edit Options and text selection

Reply

I would just suggest taking a look at cmder -- This tool is a terminal lifesaver for me on Windows. It is highly configurable. By default, it adds git and some linux tools to cmd, the default shell it uses, but also allows you to use any shell (MING64, Git Bash, PowerShell, the new Bash/Ubuntu for Windows).

Today I tried getting on with the default Bash for Windows which uses the older cmd terminal, but I went bananas. Cmder gives you the text tools you need!

Reply

that link is malware now

Reply

Thanks, removed the link. 👍

Reply
Łukasz Fuszara Łukasz Fuszara

I run Rubinius on Windows 10 Bash.

Reply
Brian Arpaio Brian Arpaio

When I run "rails new testApp -d mysql" I get back
"Errno::ENOMEM: Cannot allocate memory - sudo -p "

Your user account isn't allowed to install to the system Rubygems."

Anyone have any ideas where I went wrong?

Reply
Brian Arpaio Brian Arpaio

Fixed it - had to do a fresh install of everything from outside of the firewall at my office.

Tried re-installing and now the error I get is
"Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory: /home/barp/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/debug_inspector-0.0.2/ext/debug_inspector
/home/barp/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20160805-549-tt92si.rb extconf.rb
Cannot allocate memory - /home/barp/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20160805-549-tt92si.rb extconf.rb 2>&1"

Reply

I received an error "There was an error while trying to load the gem "uglifier". Gem Load Error is: Could not find a JavaScript runtime." Any ideas?

Reply
Kai Dorschner Kai Dorschner

Install node.js in the Linux subsystem maybe?

Reply
Paulo de Tarso Paulo de Tarso

After I close the terminal I lost all the settings that I had installed following this tutorial. I will try install it again but I fear that the same happen again. What should I do to prevent it?

Reply
Paulo de Tarso Paulo de Tarso

In fact, some commands stoped working since I closed the bash: rails new, rake test, bundle etc.

Reply
strangebiscuit strangebiscuit

I'm able to go through this whole tutorial for Windows 10 bash and get everything listed here working (using rvm currently). I get through all the final steps without error, got a working server, etc...

But I'm trying to follow a basic "hello world" tutorial ( found here: http://iridakos.com/2013/11... ) and when I try "rails generate controller pages" I get: "Error: Command 'rails' not recognized" as well as an info section on "Usage: spring COMMAND [ARGS]" and "Usage: rails COMMAND [ARGS]"

I'm confused as to how it could possibly say 'rails' is not recognized. I can do "rails -v", I can do "rails new", I can do "rails server", etc...

Anyone have any advice? I've tried this like 6 times now (resetting my entire linux subsystem after each failed try) using both rvm and rbenv and I end up stuck at this point every time. Any pointers as to where I'm going wrong would be greatly appreciated...thanks!

Reply

I was having this same issue and abandoned my attempt. If someone understands what's at hand here, that would be great.

Reply

I posted this in the long chain of comments that follows this thread, I thought I'd add it back up here for you and future folks too.

This guy has a solution https://github.com/Microsof...

```
bundle config --delete bin
rake rails:update:bin
git add bin
```

I've successfully tested it using WSL/Bash on Win10, with the instructions posted above using the RVM install, after running `bash --login` to ensure interactive shell.

I hope this helps you out!

Reply
Anthony Coffey Anthony Coffey

THIS IS AMAZING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

I love you <3

Reply

I agree with Anthony on this. I have the best of both worlds (solid windows gaming on a ridiculously fast machine and still have an ubuntu bash shell).

This is really perfect Chris. You're awesome.

Reply
radical_primate radical_primate

Excellent!! Thanks so much for this. Up and running without a hitch after first updating to Windows 10 Anniversary. You don't need to be an Insider to update now.

I hope WSL is the real deal...I've had several fits and starts trying to get going with rails on a windows machine.

Suggestion for newbies: rather than create myapp in your linux directory, switch to your windows directory, then create myapp there.

At that point you'll have ready access to work on the myapp files via your IDE

Thus, for final step, type this at the prompt $: cd /mnt/c/Users/you

Then in this director type $: rails new myapp

Reply

Got things rolling smoothly with this article. Not sure if anyone else had this issue but ruby took a really long time to install. I thought it was hanging but figured I'd give it a chance and left it running when I went to bed. In the morning it was done so slightly longer than 45 minutes for me!

Reply

It definitely can take a while sometimes. Depends on how powerful your computer is and stuff.The good news is you rarely need to do it so once it's done, you will be set for quite a while!

Reply
Dale D. Smith Dale D. Smith

I installed everything. Started the server. Went to the webpage and I got the error:
Cannot load `Rails.application.database_configuration`: No such file or directory @ rb_sysopen - /home/dale/myapp/config/database.yml

Also I tried a cat config/database.yml and received a no file or directory error.

I look in the directory and the file is there.

Frustrating. Can't find a solution. Anyone?

Reply

Hey Dale, you'll probably need to create that file if your Rails app doesn't have one. Some details on that file: http://edgeguides.rubyonrai...

Reply
Peter Truchan Peter Truchan

Thank you! I would suggest to add to postgresql installation quide, that it is possible to make it running by installing postgres directly on windows (https://www.postgresql.org/... - prefferably version 9.3.

Another issue I had is with Thin rails server. You have to use webrick by setting enviroment variable: `export RACK_HANDLER=webrick` and then run `rails s`

PS: I am going to try to develop our application on windows with this setup, I will post my experience then. Our application is for chess players and tournament organisers - https://www.swips.eu

Reply

Did you configure anything after the postgresql installation? I tried to follow the instruction here: https://github.com/Microsof... but it didn't work for me. Do you have any tips/comments that could help? Thanks

Reply

Which PGsql version did you guys download for corrresponding ruby version like i have downloaded ruby version 7 as the above guide said but i have installed pgsql version 14 is it compatible ? for ruby v7 to pair with pgsql 14??

Reply

Unfortunately as of now, when running "sudo -u" there is a bug in the Windows Bash which states: `sudo: setresuid() [1000, 1000, 1000] -> [-1, 0, -1]: Operation not permitted`

Official bug here: https://github.com/Microsof...
Of course you can work around that by using `sudo su USER`.

Otherwise a really nice tutorial with good hints (especially the `chmod +t -R ~/.bundle` one)! Million thanks!

Reply

I seem to have trouble sending http requests from my rails server on my windows 10 ubuntu subsystem, whereas people working on their OSX or normal linux have no such problem even with the same code. I keep getting a Net::OpenTimeout (expiration expired) exception no matter what type of http request I do. Has anyone experienced this as well and does anyone know why this might be happening?

Reply

@petertruchan:disqus How exactly did you get the postgresql installation to work? I followed the instruction i found here: https://github.com/Microsof... but it didn't work. Any tips/comments would be appreciated. Thanks

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.