Skip to main content

Setup Windows 10 Discussion

General • Asked by Chris Oliver
Dd6c573a395cd4cac916951d4c9196fd

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?

7826d2de504f22fbf82aa57ac76be487

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


Dd6c573a395cd4cac916951d4c9196fd

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!


F486a599c9572196a9bc6cab380c1a82

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


F25fdebfe8650b8a3baba74c4532fb0c

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 ?

09fc57db9a26756f676234907addc88e

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...

356b6c1e0bf2d04c92c015f6679c2395

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...


Bf9bcfdc210b0f9161a5ef2d9c1ca444

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?

7fc5ca5e9c56eec80fae438b2218aeea

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

Cf908a4c2ea765af97a6f9bab01bbbaf

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).

0a8279d14a057bd78ab249b873385cec

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?


Ec7d5475bc43ab6b81dc1f68fecd042f

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.

45c541f7e93f3cb55c229495a9fbabba

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

Ad1f97dfcd855c06d40ea3204f11fb47

I would just suggest taking a look at http://cmder.net/ -- 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!


4afba4a9c83b2d7fe64fa69f7072ff59

I run Rubinius on Windows 10 Bash.


26f06ddcd61e508c7cc85c64171035c0

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?


26f06ddcd61e508c7cc85c64171035c0

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"


F07e9245dd95cab0984b7ad438b6dae0

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?

0e5a8621c193b0e8b5722a83f78a883a

Install node.js in the Linux subsystem maybe?


141ce5022abbad395a1d8959366ed061

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?

141ce5022abbad395a1d8959366ed061

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

931970b8dc51b72e05e3a12b88612d61
J. Pablo Fernández

You probably need to reselect the ruby with rbenv or rvm.


3ca8f9a994c6418c2b08c32e5e45f3e4

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!

Ad1f97dfcd855c06d40ea3204f11fb47

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

Ce795239ba5dd2384fc2f88ffaff5451

Not entirely sure on that one. Have you guys tried using rbenv instead?

Ad1f97dfcd855c06d40ea3204f11fb47

For me, that was with several attempts on different machines using my preferred rbenv -- I'm going to try RVM and report back.

Ce795239ba5dd2384fc2f88ffaff5451

Curious to hear what you find out. I didn't have any issues personally, but only tested rbenv. Now my Windows 10 install is borked and I haven't had time to fix it so it boots again.

Ad1f97dfcd855c06d40ea3204f11fb47

Well, I've tossed and reinstalled WSL from scratch, and tried the RVM install instead. I found that I needed to do `bash --login` to reference my profile (and load rvm) if I left the terminal -- so it might be a good idea to reference that -- apparently the default session is not interactive.

Anyway -- I did not encounter the sticky directory issues while using RVM, but I am still having the same issue as above running generators. I've tried both `rails g scaffold hotdogs good tasty` and `bundle exec rails g scaffold hotdogs good tasty` to no avail.

```
[email protected]:~/hotdogs$ uname -a && rvm -v && ruby -v && rails -v
Linux TIMDESKTOP 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux
rvm 1.27.0 (latest) by Wayne E. Seguin <[email protected]>, Michal Papis <[email protected]> [https://rvm.io/]
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-linux]
Rails 4.2.6
[email protected]:~/hotdogs$ rails generate scaffold dogs good tasty
Version: 1.7.2

Usage: spring COMMAND [ARGS]

Commands for spring itself:

binstub Generate spring based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert.
help Print available commands.
server Explicitly start a Spring server in the foreground
status Show current status.
stop Stop all spring processes for this project.

Commands for your application:

rails Run a rails command. The following sub commands will use spring: console, runner, generate, destroy, test.
rake Runs the rake command
Error: Command 'rails' not recognized
Usage: rails COMMAND [ARGS]

The most common rails commands are:
generate Generate new code (short-cut alias: "g")
console Start the Rails console (short-cut alias: "c")
server Start the Rails server (short-cut alias: "s")
dbconsole Start a console for the database specified in config/database.yml
(short-cut alias: "db")
new Create a new Rails application. "rails new my_app" creates a
new application called MyApp in "./my_app"

In addition to those, there are:
destroy Undo code generated with "generate" (short-cut alias: "d")
plugin new Generates skeleton for developing a Rails plugin
runner Run a piece of code in the application environment (short-cut alias: "r")

All commands can be run with -h (or --help) for more information.
```

Ad1f97dfcd855c06d40ea3204f11fb47

I just wanted to add that using the RVM install, knowing to use `bash --login` when I hop in, and ignoring the usage of any commands that utilize spring (generators, console, rake test :( ), seems to be working relatively fluidly (including the majority of rake tasks).

Obviously those are some big issues, but at least I can clone my working project down and run it currently. My last few attempts with RailsInstaller have been horribly unproductive.

Ce795239ba5dd2384fc2f88ffaff5451

Makes sense with the login shell. I wonder why they changed that, because I don't think that was how it used to be. Going to frustrate a lot of people if they keep that as the default.

Ad1f97dfcd855c06d40ea3204f11fb47

Got it!

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.

3ca8f9a994c6418c2b08c32e5e45f3e4

I've tried numerous times using both the rvm and rbenv route and end up with the exact same issue as described above every time. I've reset the entire linux subsystem between each attempt.

Ce795239ba5dd2384fc2f88ffaff5451

Seems they've been making some changes to it, one of those being it's not a login shell, so you'll have to do "bash --login" for now. Still other outstanding issues. Maybe they'll get some of them fixed soon.

Ad1f97dfcd855c06d40ea3204f11fb47

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!

Ce795239ba5dd2384fc2f88ffaff5451

Good to hear! This has to be frustrating.

9365af6ff55df10ca64a85c15c8040b4

I had the same problem and followed the fix above. The "rails generate controller welcome homepage" finally worked only to create the "app/controllers/welcome_controller.rb" and the route "get 'welcome/homepage'. Then produces the following error "/home/Username/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/thor-0.19.1/lib/thor/actions/inject_into_file.rb:98:in `binread': Input/output error @ rb_sysopen - /home/Username/MyProject/config/routes.rb (Errno::EIO)" and following several .rbenv file names with error lines. Any ideas?

Ad1f97dfcd855c06d40ea3204f11fb47

I saw your post on SO http://stackoverflow.com/qu... but don't have enough rep to comment there, so I'll comment here.

You mention not seeing routes.rb in bash, but seeing the file in Windows, and then proceeding to copy stuff around.

The file path you mention your project to be in is a straight up linux folder (/home/User1/stuff) as opposed to a shared, mounted directory in the Windows system. With this said, I've read that interacting with files on that side (burried in appdata or wherever) of the system from Windows causes problems because of the differences in how files are handled between the systems. So, as you mention in SO, trying to copy those files from Windows will likely lead to difficulties.

I've had success with my projects living in the Windows mount area -- for example:

```
cd /mnt/C/Users/Tim/Desktop
rails new hello_world
etc
```

With the files living there, it is easy to manipulate with Windows or Linux then without causing corruption (the worst of it seems to be line ending issues, which any proper text editor can deal with).

In addition, I was using rvm, instead of rbenv.

Without knowing too much more, I'd give generic recommendations akin to "reboot it and see what happens":

- run rbenv rehash
- run bundle install
- run chmod +t -R ~/.bundle
- consider running chown -R user:user /home/user
- cd /mnt/c/Users/User/Desktop && rails new hotdogs && cd hotdogs --- and try creating a controller from there -- pay attention to what happens to the actual output

Hope you find something -- I went through a bit of hell when I tried updating ruby recently, before WSL. I had a perfectly running Ruby 2.2.0 on my system with Rails -- tried upgrading, and went through 3 weeks of frustration in trying to get a working ruby again. The method I posted above has been working really great for me finally, but I don't dare mess with it again -- it's so damned fragile!

9365af6ff55df10ca64a85c15c8040b4

Thank very much you for the recommendations. I created a new bash user to install rvm there and follow your recommendations (do you think is OK or I should reinstall the whole subsystem and use rvm this time?). I'll let you know whether it is worked for me too.

9365af6ff55df10ca64a85c15c8040b4

Well, finally, the RVM installation with the fix above works fine, like you said! (I found no way to make rbenv installation operational). Thanks a lot!

Ad1f97dfcd855c06d40ea3204f11fb47

Hey @excid3:disqus -- You might want to consider noting some of this stuff in the Windows specific guide, unless you are in fact seeing people successfully using rbenv. Right now the guide says rbenv is the recommended way, but I haven't been able to get it to work on WSL without issues. If you know how, that information would also be appreciated :)

Ce795239ba5dd2384fc2f88ffaff5451

I used rbenv just fine when I initially set things up. My Windows 10 install got corrupted so I need to reinstall it and try this again sometime to see how things have changed.


6fc1d33366365c07e9b1b7793d80eb5a

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

I love you <3

02e664580551383f61243a1f7de67ccb

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.


Edcda9a80f7a359dfe55212fb19eafea

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


89d356dc318a6cf03c2b5bb68e332621

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!

Ce795239ba5dd2384fc2f88ffaff5451

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!

Ef44eaf67417828a27f69096f70d948b

why hours and not minutes?, does not seem like the download was much.

Ce795239ba5dd2384fc2f88ffaff5451

Because compiling Ruby takes a lot of CPU power.


Ca6d2a724bfa2ed8baf26f8ef5b2016b

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?

Ce795239ba5dd2384fc2f88ffaff5451

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...

Ca6d2a724bfa2ed8baf26f8ef5b2016b

I setup a new app and now I get the following message. I know something isn't configured correctly, but I don't know how to determine what it is.

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

Ca6d2a724bfa2ed8baf26f8ef5b2016b

After many times removing everything and starting over I finally resolved the issue. Or should I say this article fixed the problem. http://superuser.com/questi.... I was missing the /var/run/mysqld/mysqld.sock file. It is fixed and I am finally up and running with Rails on Bash on Ubuntu on Windows 10!


383268f80905a94cbd59f9b0c24816c3

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

4b6c7e40b1d6f27354ee1b4571b87fb0

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

9b122daa87e823a174438d2f7f0baf08

BTW.. I did a standard postgresql install on windows and didn't do anything special in the linux side.. my rails app in rails can talk to the postgresql server running in windows.. localhost points to the same place linux and windows..

4b6c7e40b1d6f27354ee1b4571b87fb0

Thanks for letting me know! I'll go and try this again in the future. Maybe I just messed something up

B1a908e4a4e921f5f9f1c8dbd198126f

Hi, I have mysql installed on windows. Do I need to install it separately on Linux Subsystem? Thanks


0e5a8621c193b0e8b5722a83f78a883a

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!


5b4e6ea2f5f61e445bf9e42d9a9ef022

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?


4b6c7e40b1d6f27354ee1b4571b87fb0

@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


562f47012f1a67425e0ddcbd3c0d2a3b

Hi!. I have a problem running a rails server. It's seems that a Thin Server is up and running, but not listening on port 3000

This picture will show you my situation. Please help me!.


Ad14e3e12ac4c8b01834002a96a9c3bd

hey .. did all the things till the final step /
i had some problem so closed the bash screen and turned on again
now when i type ruby -v .. its says it to install same goes for rails everything

so .. far i dnwld everythng is gone ah ???

i dont understand help me

it took nearly 4 hrs fr me to reach final step

Ce795239ba5dd2384fc2f88ffaff5451

It's likely that everything is installed but your terminal didn't automatically load rbenv again. Double check and make sure that you followed all the rbenv lines correctly to echo the lines into your .bashrc file.

Ad14e3e12ac4c8b01834002a96a9c3bd

i used RVM to install

is that a problem ????

7b0dcadab0c3f98965ec0f98b161182b

I had the same problem.... this worked for me:
/bin/bash --login

after that I could use ruby -v, rails -v, even rails server
hope it helps :)
BTW I also used rvm

7b0dcadab0c3f98965ec0f98b161182b

So, today I found something better.... Open up the launcher of the bash and go to the properties.... change the target to "C:\Windows\System32\bash.exe ~ -c "/bin/bash --login"... after this you do not have to use the solution from previous comment every time you launch it.... This works automatically... It's based on the fact that normally you launch a non-login session, however, with these settings you, on the other hand, run a login session..... If you want to know more, read these threads http://askubuntu.com/questi... and https://github.com/Microsof...

Ce795239ba5dd2384fc2f88ffaff5451

Hopefully that default changes in Windows as that's unexpected behavior from anyone who is used to opening bash with a login shell automatically on any Linux install.


35a336a29152b8e6c9946fc2ae1b57c5

great article , someone know how to install solidus ecommerce on w10 ussing bash ubuntu? thks


F8009bda1aafc7265ee24ef3166c10ef

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/home/rakis/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/byebug-9.0.6/ext/byebug
/home/rakis/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20161113-24750-68ud34.rb
extconf.rb
Cannot allocate memory - /home/rakis/.rbenv/versions/2.3.1/bin/ruby -r
./siteconf20161113-24750-68ud34.rb extconf.rb 2>&1

Gem files will remain installed in
/home/rakis/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/byebug-9.0.6 for
inspection.
Results logged to
/home/rakis/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/byebug-9.0.6/gem_make.out

An error occurred while installing byebug (9.0.6), and Bundler cannot
continue.
Make sure that `gem install byebug -v '9.0.6'` succeeds before bundling.
run bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`


1cbacb9d60447ab0127dc589955c2091

Brilliant - all worked v smoothly, like someone else said installing ruby 2.3.1 took ages. You may also need to install rmagick - to do this type sudo apt-get install libmagickwand-dev imagemagick


D9dace28d0ca7b87624b260dbf21853d
Beluan Fil Joseph Qu

I got the problem, i'm following your tutorial, but this result after running rails new myapp -d mysql

There was an error while trying to write to
`/home/user/.bundle/cache/compact_index/rubygems.org.443.29b0360b937aa4d161703e6160654e47`.
It is likely that you need to grant write permissions for that path.
run bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`


A59f2bb5ce994414297b76b4a968952f

so how do we find the root directory where all the created apps are located?

D2eb1fddabf34b99503a2e8535a15455

It will be here: "C:\Users\Your Name\AppData\Local\lxss" to access your projects you will navigate to: "C:\Users\Your Name\AppData\Local\lxss\home\then your new Ubuntu username"


931970b8dc51b72e05e3a12b88612d61
J. Pablo Fernández

Any ideas how to access that Ruby binary from Windows? For example, how do I use it as the RubyMine Ruby.


931970b8dc51b72e05e3a12b88612d61
J. Pablo Fernández

Serving static files with webrick inside WSL seems to be as slow as it was on Windows. Have anybody experience this? any solutions?


Be1a247df381daccce75436fdd5052e1
dan setengahmanusia

please explain to me, i still don't understand, why we don't install rails just using railsinstaller, or some simple easy installer else,,

D3371728bd6515ed3f261fd670dacdbc

Rails dev environment is not native on Windows, which is why you have to go through all the hassle.


D3371728bd6515ed3f261fd670dacdbc

I believe this guy actually reuses some other people's article and copy pasted.After installing ruby-build, when you do an rbenv install a specific version, Bash on Windows cannot create directories for installing the ruby version.

Ce795239ba5dd2384fc2f88ffaff5451

Nope, wrote it myself, but things are constantly changing with Bash on Windows so these instructions break often.

D3371728bd6515ed3f261fd670dacdbc

The horror. I might as well Virtualbox the Rails environment and just work from there instead then. Thanks anyways.

Ce795239ba5dd2384fc2f88ffaff5451

Go for it. Like it says at the top of the post, this is for documenting it for Bash on Windows, not other approaches like VirtualBox.


711fa3562785c6340a1829ae123015fd

After installing everything correctly, I received a "This site can't be reached" error for localhost:3000

Any suggestions?


6b2f625250dff0f09010fe0bb0a3f68b

ALERT !
© If you're using Windows Subsystem for Linux then there are currently some limitations on file system notifications that mean you should disable the spring and listen gems which you can do by running rails new blog --skip-spring --skip-listen.
http://guides.rubyonrails.o...


2cfe04cb23f9ad7f9c022d1946453ce8

I know this is a bit of an older post, but it is one of the few places where someone is doing, more or less, what I'm trying to do. My question is, has anyone successfully done this with jruby? I have tried installing jruby 9000 in my home directory, in the multi-user setup (usr/bin/jruby which are symlinks pointing to /usr/lib/jruby/bin), and using RVM in the home directory. In all cases I get to the point where jruby is installed and seems to run properly, but the gem command simply doesn't work. When I try to run "gem install rails" or "gem install bundler" or "jruby -S gem install..." I get "Unable to download data from https://rubygems.org/ - timed out"


F486a599c9572196a9bc6cab380c1a82

is it possible to use sublime text somehow? Just wondering


04e85d312e19758164ad21aaecc4d726

Thanks for this.. It was quite helpful.


B899af9f5dc7235671ea22e9f08f030a
Dmitrii Evdokimov

As for now this Bash is open for every PC with 64-bit Windows 10 Anniversary Update build 14393 (1607) or later - https://msdn.microsoft.com/...
So I install Ruby 2.4.1 from sources (and run Jekyll 3.4.3).


Bd8d349d629997654da6f7214bfe6a31

Incase you're not able to do rake db:migrate with pgsql try this .

I installed pgsql on local windows and not on ubuntu bash
Then did the following:
Go to you config/environments/development.rb and comment out The Line config.file_watcher = ActiveSupport::EventedFileUpdateChecker,
After this run - rails s or rake db:migrate.

This worked for me and is pretty fast too.
Earlier I was using Vagrant (VM) and this (Ubuntu on bash) is faster than vagrant method,
Just my opinion, Hope it helps :)

D2eb1fddabf34b99503a2e8535a15455

What version of postgres did you install on windows?

Bd8d349d629997654da6f7214bfe6a31

pgsql - 9.6 and rvm 2.4.
Initially I installed pgsql on ubuntu bash, but it didn't work, some error(don't remember it), then i read somewhere that we need to install on windows, so installed on windows and in db.yml added host as localhost.

D2eb1fddabf34b99503a2e8535a15455

Doesn't work with rbenv unfortunately. The pg gem won't install: fatal error: libpq-fe.h: No such file. If I run sudo apt-get install libpq-dev it can no longer find the gem file for some reason.

D2eb1fddabf34b99503a2e8535a15455

Actually got it working! Woohoo...


9f0e6a9646db6c333d8ad2b29d7a03c2

It looks like this does not work currently if you've been upgraded to xenial. Specifically, ruby does not appear to install correctly if you close the bash session, and you have to rerun the rvm script every time, in addition to not being able to install the rails gem at all.

E10f86067a19272f3d86723d86ec6bb0

so go for rbenv?


8133ee52ca72188132b5c7d97dfb967f

When going to locahost:3000 in the browser I get, json response as it it a api:

{"status":500,"error":"Internal Server Error","exception":"#\u003cRuntimeError: Cannot load `Rails.application.database_configuration`:\nCould not load database configuration. No such file - [\"config/database.yml\"]\u003e


93496c6cb9289f63206c508c8f7291cc

I have one problem on install postgresql on create user.
here is command:
[email protected]:~$ sudo -u postgres createuser malin -s
output: sudo: unable to resolve host XMAN
output: sudo: setresuid() [1000, 106, 1000] -> [-1, 0, -1]: Operation not permitted
how can I fixed it? Thank you.


60c1db74bc9539e1dfdd96b119c09ac8

Hi,
can you do a tutorial to explain how it's possible to configure rubymine to edit a project? (project in ubuntu /home/User). I would like to use Rubymine i have install on windows to edit code in ubuntu subsysteme.

Thanks a lot!

474288f408c5950862a4b346b60201a1

did you get the answer for this?


0fa8b2ff66894cf6c9eb4e8f98f30c8b

Chris it would be interesting to update the tutorial for Windows 10 Creators Update considering the many new updates and improvements the Windows Subsystem for Linux has received! ;) https://blogs.msdn.microsof...

Ce795239ba5dd2384fc2f88ffaff5451

I will try doing that! I've gotta get my Windows 10 install back working again. :S

0fa8b2ff66894cf6c9eb4e8f98f30c8b

Chris you should add explicitly which version of Windows 10 (1511, 1607, 1703, ecc) this guide curretly refers to.
Anyway, news: Ubuntu finally on the Windows Store: https://www.microsoft.com/e...


2b9a41d763da1653d03ead21cd07404b

My install works fine until 'gem install bundler' when I get this error:'/home/james/.rbenv/versions/2.4.0/bin/ruby: symbol lookup error: /home/james/.rbenv/versions/2.4.0/lib/ruby/2.4.0/x86_64-linux/socket.so: undefined symbol: parse_numeric_port'.
I'd appreciate any help as I really want to get WSL to work.

Aca906552a2fb93c7e3fb3db6732b1b4

rvm works


3cc5a60a8640a0fbd36f9b8b5701e20b

Hello,

Thanks for the tutorial. It really helped me to get my basic setup up and running.
Thou I did have to fiddle around to get a few things working.
I should note that 5/14/17 I was not able to do

sudo -u postgres createuser YOURUSER -s

instead I had to use

sudo sudo -iu postgres createuser YOURUSER -s

due to -u not working at the time on WSL. Also I had to start the postgresql service before creating the user with

sudo service postgresql start

Hope this comments help people trying to install it later.

Thanks again for all your help and to all the RoR community, I just spent the last few days until I had my successful attempt at installing everything I wanted on WSL (yeah there were 4, I am now familiar with lxrun.exe /uninstall /full and lxrun.exe /install to reset the entire linux subsystem :P).

PS:
I would like to see added to the tutorial some information on installing MongoDB. For the moment I will just leave the link to the official tutorial https://docs.mongodb.com/ma... small comment though there are problems starting mongodb as a service so for now the only way I have found is to use sudo mongod. Also, remember to run mkdir /data/db before starting the database (that last bit is required but it is not included in the official tutorial from mongo).


Adfde5ecce839f08c5d713f972eb746f

The source on my machine does not have the same path ~/.rvm/scripts/rvm

Mine is @: /usr/local/rvm/scripts/rvm

Also, The source is not persisting after exiting the terminal. And finally, it's failing when I try to start the rails server.


50899c7565455d5a35e94f989ba1e978

edit: got it working in the end, lots of patience required :)

Hello, thanks for the tutorial, however, I'm just trying to install rbenv and it has already taken 1 hour of waiting, it seems it is stuck on 'installing ruby-2.4.0...'. Should I just cancel and start afresh with rvm?

Ef44eaf67417828a27f69096f70d948b

what did you do? I have same issue. Another comment mentioned he left it over night and was ready in the morning. It is crazy it takes this long. Cant imagine ruby being a huge program.

Ef44eaf67417828a27f69096f70d948b

I am on a haswell cpu i5, 2 cores 4 threads. CPU and HD have been sitting at 1-2% now for about 24 hours. Not feeling like this will improve anytime.


B03cefed889733e23b2e6e16765e3733
Francisco Javier Vallés Johnso

I just want to share how I was able to install postgresql 9.5.
First, after running "sudo apt-get install postgresql-common postgresql libpq-dev" I got the error:

"http://archive.ubuntu.com/u... xenial-updates/main amd64 postgresql-client-9.5 amd64 9.5.7-0ubuntu0.16.04 Hash Sum mismatch"

So, as the console sugested, I executed it again adding "--fix-missing" and it worked.

Next, running "sudo sudo -u postgres createuser username -s" throwed the error:

"psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?"

which I solved by running "sudo pg_ctlcluster 9.5 main start".

Finally, trying to run "rails db:create" I got the error:

"new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)"

The solution for this was running:
- sudo sudo -u postgres psql
- UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
- DROP DATABASE template1;
- CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
- UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
- \c template1
- VACUUM FREEZE;

I found all the above solutions searching in Google, but I don't remember the links.

Hope it helps someone and saves them some time.


B1a908e4a4e921f5f9f1c8dbd198126f

I have mysql installed on windows. Do I need to install it separately on Linux Subsystem?


Ef44eaf67417828a27f69096f70d948b

How old is this guide? I ask because, as of 6/22/2017 msdn quotes:
"Languages: Javascript/node.js, Ruby, Python, C/C++, C# & F#, Rust, Go, etc.
Services: sshd, MySQL, Apache, lighttpd,"

Suggesting that ruby should have full support now?


8bc30b07318b20a85c5b64b2af6782ec

Thanks for the tutorial!

Just a note, it's "without further ado", not "without further adieu" 😉


1e515ff49c146cc1a16f9383554e20b2
francesco Esposito

ruby-build: definition not found: 2.4.0 ??? help me plz


9a6cb1bfc69beccab1c5a38360ea9eb0

I get this error anytime i start the rails server or type rails -v

rails-v
/home/word/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.3/lib/rails/app_loader.rb:40: warning: Insecure world writable dir /mnt/c in PATH, mode 040777
Rails 5.1.3


Abe37d5048fafc90950077ff515a63e7

Great post. The install went fine, including the MySQL server installation, but when I try to connect to the MySQL server, I get the message: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I uninstalled it (sudo apt-get remove mysql-server) and re-installed. Same error message

If I try to re-install, I get the message that the MySQL server is already installed and is the latest version. Any ideas?

Abe37d5048fafc90950077ff515a63e7

The install process, despite having asked me for the root password, etc., did not automatically start the MySQL server, so the solution is simple: sudo service mysql start


Ece6a0546f009b473d1d83eec10a20ee

i got a q. now i am o [email protected] does this mean i am on a vertual & so i can not get actual folders and files?


22c95c1b6a3a847d215d52d6441404fd
Yuri de Sales Almeida

Is it possible to share folders like vagrant?


Fae7d17f2a5337a3977ebc4a54127ca8

I get following error. I followed everything as mentioned in the article.
Looks like mysql db is not created.
Missed any step?

[email protected]:~/myapp$ rake db:create
#<mysql2::error: can't="" connect="" to="" local="" mysql="" server="" through="" socket="" '="" var="" run="" mysqld="" mysqld.sock'="" (2)="">
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>"******", "host"=>"localhost", "database"=>"myapp_development"}, {:charset=>"utf8"}
(If you set the charset manually, make sure you have a matching collation)
Created database 'myapp_development'
#<mysql2::error: can't="" connect="" to="" local="" mysql="" server="" through="" socket="" '="" var="" run="" mysqld="" mysqld.sock'="" (2)="">
Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "pool"=>5, "username"=>"root", "password"=>"*****", "host"=>"localhost", "database"=>"myapp_test"}, {:charset=>"utf8"}
(If you set the charset manually, make sure you have a matching collation)
Created database 'myapp_test'
[email protected]:~/myapp$ mysql
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
[email protected]:~/myapp$

1ef6532ca751421edfabcea02da0fc07

Not sure if you ever got it working, and I don't have a solution really, but here are some thing's I would check.

Make sure the MySQL server is actually running. If so:

Get a visual MySQL Editor, there's alot of them, make sure your database encoding is UTF8, if it's not change it. The Visual Editor just makes it easier to check thing's out. It's a bit more simple than throwing commands into a console.

Check your Firewall, and make sure it's allowing connections on the MySQL servers port/s.

Make sure you have the correct permissions/privileges, both file system permissions, and privileges to access the MySQL service. For example MySQL may have been installed with only root, or admin access allowed. try opening the bash terminal as administrator, if that doesn't work try using sudo prefixed before commands (with, and then without admin privileges on the bash process.)

Sorry I couldn't give you a concrete solution, hope you get it working.


Cdd3b60a99dc4bf41823216afb390f89

how to open Sublime, and point them to your folders in C:\code


5d903b9042dfe5477a3375432c3f1ad3

It's very sloooow. Did anybody get this issue with all Rails/Rake commands?


55445c280a82a1a23e037544b1bc721a

Good post.

I also needed to run the following, prior to installing ruby:
sudo apt-get install -y gcc libssl-dev libreadline-dev zlib1g-dev make


2b9a41d763da1653d03ead21cd07404b

I installed ruby and rails correctly, but when I run my new rails app, my browser cannot connect. I must have missed something obvious somewhere. Has anyone else had this problem?


70a87eab6f2f8621f33fdc350cde78f4

Nothing wrong! Just had to start the MySQL service: "sudo service mysql start"


0ea747d651c21d4028eafd3e12e302f5

Is there anything wrong with just running `sudo apt install rbenv` instead of the shell script? I was having issues with the script. Only the plugins folder was cloned...


D16a84f95ca53ab452cd210f8d65708e

Doesn't work with me.
rails aborted!
Don't know how to build task 'v' (see --tasks)
/home/Emad/myapp/bin/rails:9:in `require'
/home/Emad/myapp/bin/rails:9:in `<top (required)="">'
/home/Emad/myapp/bin/spring:15:in `<top (required)="">'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
(See full trace by running task with --trace)


E81c4ae54a0fd1349440d63a2a9ec270

Just wanted to let you know that I just got this up and running! Thankfully I didn't have any issues. Thank you to whoever for putting this together! Great job!!!!


09f492f370acb39777eca27a14b16bba
Thanks for tutorial, although I think you should take a moment to say if you have Windows Git you don't really need git install and likewise if you have mySQL already running as a service you don't need that either, just point database.yaml to windows instance.

D91dcc5fc942b6981d9a6edf9ffd312e
Hey There,
Thank you so much for this Article . Just wanted to add the following.
If you get stuck while bundle install for pg gem, then here is the solution:
$ sudo apt-get install postgresql-client libpq5 libpq-dev 
$ sudo gem install pg

Source: https://stackoverflow.com/a/49225282/3438461

Happy Day! :)

40633629dc6f047291e59d8d4c96a388
Yay, I'm now riding on Ruby on Rails. Thanks a lot! However, I encountered the following error:
An error occurred while installing pg (0.21.0) and bundler cannot continue.
Make sure that gem install pg -v '0.21.0' succeeds before bundling

I solved it using the following
sudo apt-get install libpq-dev
then:
gem install pg
followed by:
bundle install

Disclaimer: Not my own solution. Found it on Stake overflow.

9e41c220577ac8fd1694a7c416692b9c

Dd48f866dc2231e780b4e77e29cab4fb

 This package is not available in Ubuntu 18.04 Windows 10

python-software-properties 

Ce795239ba5dd2384fc2f88ffaff5451
Bagus, it should be called "software-properties-common" now or "python3-software-properties". Making an update for that.

9a2c8a698f7c88095bc13a9a1043ed7b
This should work with "Bash on Ubuntu on Windows" as well

B0310ed2c24d968ce3ddd90a7b3e70ea
As usual, GoRails is my go to site for any rails installations.  Thanks for all you do!

0fa8b2ff66894cf6c9eb4e8f98f30c8b

I don't know if it's expected or normal, but to get PostgreSQL installed on Windows to communicate within WSL I had to sudo apt-get install postgresql-client-common postgresql-client libpq-dev
Chris what do you think?


Ce795239ba5dd2384fc2f88ffaff5451

Alberto, yep. You'll always need libpq-dev to compile the C extension for Ruby to talk to Postgres. 👍

0fa8b2ff66894cf6c9eb4e8f98f30c8b

Wouldn't it be savvy to add it to the tutorial then? :P


8ef6c8aa45e589bbe3c835799c833956

I was getting an error using postgres where it would say "could not connect to server"

The fix was to uncomment the line host: localhost in database.yml

0fa8b2ff66894cf6c9eb4e8f98f30c8b

Taylor, for Rails an even better solution probably is to do that inside database.yml.
I had even to specify user and password for all the environments to do successfully the rake db:create.


0bc4a3c7304388e1bb3277666182f897

The generated Gemfile make bundle install error when create new project.
rails new myapp -d postgresql

It fixed

since need to install the postgreSQL dev package with header of PostgreSQL
sudo apt-get install libpq-dev

suggest to add tutorial for new kickstarter

Gemfile

# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'

installed also failed by using this command:
gem install pg -v '1.0.0' --source 'https://rubygems.org/'

, still prompt the error:
Could not find gem 'pg (< 2.0, >= 0.18)' in any of the gem sources listed in your Gemfile.

This is the error log:

find_executable: checking for pg_config... -------------------- no

/home/kachun/.rbenv/versions/2.5.1/lib/ruby/2.5.0/mkmf.rb:1553: warning: Insecure world writable dir /home/kachun/.rbenv/versions in PATH, mode 040777
--------------------

find_header: checking for libpq-fe.h... -------------------- no

"gcc -o conftest -I/home/kachun/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86_64-linux -I/home/kachun/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward -I/home/kachun/.rbenv/versions/2.5.1/include/ruby-2.5.0 -I. -I/home/kachun/.rbenv/versions/2.5.1/include    -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wno-maybe-uninitialized conftest.c  -L. -L/home/kachun/.rbenv/versions/2.5.1/lib -Wl,-rpath,/home/kachun/.rbenv/versions/2.5.1/lib -L. -L/home/kachun/.rbenv/versions/2.5.1/lib  -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-rpath,/home/kachun/.rbenv/versions/2.5.1/lib -L/home/kachun/.rbenv/versions/2.5.1/lib -lruby-static  -lpthread -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

"gcc -E -I/home/kachun/.rbenv/versions/2.5.1/include/ruby-2.5.0/x86_64-linux -I/home/kachun/.rbenv/versions/2.5.1/include/ruby-2.5.0/ruby/backward -I/home/kachun/.rbenv/versions/2.5.1/include/ruby-2.5.0 -I. -I/home/kachun/.rbenv/versions/2.5.1/include    -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wno-maybe-uninitialized  conftest.c -o conftest.i"
conftest.c:3:22: fatal error: libpq-fe.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
/* end */

--------------------

23de8cbb8c958a4817e817d95a6df1de

I can't ever seem to use your instructions verbatim when I get to the part of the gpg keys. I enter...

gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

...and I never get a message convincing me that the keys are in place. I get something to the effect...

gpg: directory '/root/.gnupg' created
gpg: new configuration file '/root/.gnupg/gpg.conf' created
gpg: WARNING: options in '/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring '/root/.gnupg/secring.gpg' created
gpg: keyring '/root/.gnupg/pubring.gpg' created
gpg: requesting key D39DC0E3 from hkp server keys.gnupg.net
gpg: requesting key 39499BDB from hkp server keys.gnupg.net
gpgkeys: key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB can't be retrieved
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key D39DC0E3: public key "Michal Papis (RVM signing) <[email protected]>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
gpg: keyserver communications error: keyserver helper general error
gpg: keyserver communications error: unknown pubkey algorithm
gpg: keyserver receive failed: unknown pubkey algorithm

Those last 3 lines always worry me. I get this same type of message whether I'm running the command in Windows 10 Bash on Ubuntu on Windows or when I run it in an Oracle virtualbox running the latest Ubuntu version. I've been having this issue for years now. I found another post that suggested I run this instead...

command curl -ssl https://rvm.io/mpapis.asc | gpg --import

...and that seems to get me what I need for the install and Rails to work. I just can't believe that I haven't seen anyone post about this error yet and that it's only happening to me....no matter what machine I'm on. Why doesn't this command work for me? gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB I've run this command on a few dozen virtualbox machines now and it's never worked without error messages at the end. When I ran this on my windows box and I still got the message, I figured I should finally post something. I've been getting a similar message since I started following these instructions since late 2015.


Ce795239ba5dd2384fc2f88ffaff5451

Hey John, not sure why that command doesn't work from you. I just pasted in the RVM installation instructions from their website. I don't use RVM though but as long as you get the gpg keys imported, that's all you need.


561c43f27a6a457fc2e48d591a130123

Do I have to be in the Windows Insider Program to download Linux on my Windows 10 PC?


3ddc0df24b1e92d0574ee0d2cb11eb9c

I had a problem when tried to run rake db:create after Postgress installed in Windows. It couldn't connect.
Here's the solution I've found here:

when you do not specify a hostname, postgresql clients (psql, pg_dump) will try to connect via a Unix socket, not TCP. Connection from Bash on Windows to Postgresql running on Windows must be via TCP (the error message mentioned that it could not connect on a Unix domain socket, but it hadn't clicked in my head). To force your connection to use TCP you must specify a hostname. The host can be specified with a command line flag -h localhost, via PGHOST environment variable, or via .psqlrc file. I added export PGHOST=localhost to the bottom of my ~/.bashrc file.
The second issue I had was that I expected psql to be able to connect to the local host without specifying a password, just as I do when running on Mac OSX. This was fixed by changing the Windows Postgres server's pg_hba.conf file. The default line in my installation for 127.0.0.1 was configured for md5 connection method. I changed it to trust, to match the configuration on my OSX installation. That makes the pg server trust any connection that can be made.

I also had to add a user in Postgres with the same name as it was in my Ubuntu Bash.

7826d2de504f22fbf82aa57ac76be487

Excellent! Thank you! I wish it were possible to get someone to add this newer information and workarounds to the tutorial.


60289ef6f381703a6bf5991a00bcedca

Hi,

I just impressed, awesome tutorial.

I love this tutorial.

Thanks


7826d2de504f22fbf82aa57ac76be487

Hello,

An addition that could be made to this article, and all articles on GoRails are timestamps. This way we know if the article is outdated / needs improvement, etc. so we can adjust our environment accordingly and easier diagnose what issues / inconcistencies we are experiencing.

Thanks!


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 18,000+ developers who get early access to new screencasts, articles, guides, updates, and more.

By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

More of a social being? We're also on Twitter and YouTube.