Moving Rails development from Windows to Linux

February 23, 2015

Recently we embarked on a new feature requiring a gem that is not compatible with Windows.

To re-quote a quote from : “The reality is that Ruby, as used by most Rails apps is full of unixism, performance of Ruby MRI (the default Ruby) on Windows is abysmal, Rails load times are hellish, sooner or later (more likely sooner) you are going to hit gems that simply do not work properly on Windows. So … if you are on Windows (Disclaimer: my primary Dev machine is Windows 8) and would like to play with Rails you are must install a Linux VM.”

Up till now we had been running Rails 4.2.0 on Ruby 2.1.4.

So here are the steps we took:-

Install VMware Player Pro - free for non-commercial use. Download Ubuntu 14.04 LTS (64-bit) and create a Ubuntu VM

On creating the Ubuntu VM we got a blue screen Windows failure. It now works after a hardware upgrade: increased RAM from 4 to 8 GB; replace HDD with new SSD. Running’s System Scanner was excellent for getting upgrade specs and options specific to a pc or laptop.

VMware player says VMware tools needed upgrading -> upgrade using a terminal Configure timezone in Ubuntu

Follow guides on installing Rails 4.2.0 on Ruby 2.1.4 with PostgreSQL 9.3:-

[ ]

[ ]

$ sudo apt-get update
$ sudo apt-get install git-core zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties
$ sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
$ curl -L | bash -s stable
$ source ~/.rvm/scripts/rvm
$ echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
$ rvm install 2.1.4
$ rvm use 2.1.4 --default
$ ruby -v
$ echo "gem: --no-ri --no-rdoc" > ~/.gemrc


$ git config --global color.ui true
$ git config --global "YOUR NAME"
$ git config --global ""
$ ssh-keygen -t rsa -C ""
$ ssh-add ~/.ssh/id_rsa
$ xclip -sel clip < ~/.ssh/

aws:- set up the command line tool

$ sudo apt-get install nodejs

rvm gemset list

$ rvm gemset use global
$ gem list
$ gem outdated
$ gem update
$ gem install nokogiri
$ rvm use ruby-2.1.4@rails4.2.0 --create
$ gem install rails --version=4.2.0
$ rails -v

Setting Up PostgreSQL:-

$ sudo sh -c "echo 'deb precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
$ wget --quiet -O - | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install postgresql-common
$ sudo apt-get install postgresql-9.3 libpq-dev
$ sudo apt-get install postgresql-contrib-9.3 # for hstore

Create DB’s, user & password:-

$ sudo -u postgres createuser chris -s
$ sudo -u postgres psql
$ postgres=# \password chris # then set password when prompted
$ sudo apt-get install pgadmin3
$ sudo -u postgres createdb mydb
$ sudo -u postgres createdb mydb_test
$ rake db:structure:load RAILS_ENV=test
$ sudo -u postgres psql
$ \l # list db's

Fetch existing GitHub project:-

$ mkdir git
$ cd git
$ git clone[gituser]/myapp.git
# should be using ssh for git origin:-
$ git remote set-url origin
$ git remote -v
$ rvm use ruby-2.1.4@myapp --ruby-version --create
$ gem install rails --version=4.2.0
$ bundle install
$ echo "ruby-2.1.4" > .ruby-version
$ echo "myapp" > .ruby-gemset
$ rake -T

Install a text editor or lightweight IDE:-

Was using notepad++, and is the fall-back plan.

[ costs USD 70 ]

[ is free! ]

$ sudo apt-get install geany

( set tabs as 2 spaces in edit / preferences editor / indentation )

Get geany setup to run rails server ( not sure if this is a good idea ):-

“RVM is not a function, selecting rubies with ‘rvm use …’ will not work.”

=> 1: check the ‘Run command as login shell’

=> 2: Nothing worked, until I found this - make this the LAST line in /home/your-name/.bashrc

[[ -s “$HOME/.rvm/scripts/rvm” ]] && source “$HOME/.rvm/scripts/rvm”

but now it works - how to get it to shut down! ?

=> $ kill -INT $(cat tmp/pids/

Get a tortoise alternative for linux - something good for reverts:-

[ ]

[ ]

( shame no plugin for geany )

$ sudo apt-get install git-cola

All done and tests passing!

© 2018 Keith P | Follow on Twitter | Git