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
- my.cnf
[client]
protocol = TCP
- /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