Skip to content

Instantly share code, notes, and snippets.

@mh-github
Last active November 5, 2018 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mh-github/a5f61ffad90bd879e95558acf0f15049 to your computer and use it in GitHub Desktop.
Save mh-github/a5f61ffad90bd879e95558acf0f15049 to your computer and use it in GitHub Desktop.
Installing Ruby on Rails on Windows 10

After installing Ubuntu, I had to run the following two commands repeatedly. I haven't noted the exact error messages I got.

$ sudo apt update
$ sudo apt install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev

Install rbenv

$ cd
$ git clone https://github.com/rbenv/rbenv.git .rbenv
$ echo 'export PATH="$HOME:/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ exec $SHELL
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
$ exec $SHELL

$ rbenv install 2.3.1
$ rbenv global 2.3.2
$ ruby -v

$ gem install bundler
$ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
$ sudo apt install -y nodejs
$ gem install rails -v 4.2.10
$ rbenv rehash
$ rails -v

My code folder is D:\Code\Ruby\Rails

$ cd /mnt/d/Code/Ruby/Rails
$ rails new myapp
$ cd myapp
$ rake db:create
$ rails server

Now I could access localhost:3000 in the browser running on Windows. A helpful note --

When you create a new Rails app, you might run into the following error:

parent directory is world writable but not sticky.

If you run into this issue, you can run chmod +t -R ~/.bundle and that should fix the permissions errors and let you finish the bundle install for your Rails app.

Configuring MySQL database

First step is to install mysql client libraries

$ sudo apt install mysql-client libmysqlclient-dev

I had to make entries in two files for protocol and host

  1. my.cnf
[client]
protocol = TCP
  1. /config/database.yml in application folder
development:
    database: <<my_development_database>>
    host : 127.0.0.1

Start MySQL on Windows.

Create my_development_database

Now, when I started rails, I got a message:

Could not find proper version of railties (4.2.6) in any of the sources

$ bundle install

Last step was to populate the development database

$ bin/rake db:migrate RAILS_ENV=development

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