[How to] Install libv8 and therubyracer on C1 server


#1

Important: An issue is open to get a binary version of the gem, you can track it here

Run these commands as your normal login (e.g. “michael”)

sudo apt-get -y install build-essential git software-properties-common

Install RVM

We recommend installing RVM isolated to a single user’s environment.

Create user:

# Run these commands as your normal login (e.g. "michael")
sudo adduser --shell /bin/bash --gecos 'Bob user' bob
sudo install -d -m 755 -o bob -g bob /<yourpath>/bob

Change to the ‘bob’ user:

# Run this command as your normal login (e.g. "michael"), further commands should be run as 'bob'
sudo su - bob

Install RVM

# As 'bob'
# Install RVM
\curl -s -S -L https://get.rvm.io | bash -s stable

# Refresh your profile
. ~/.rvm/scripts/rvm

rvm_make_flags=( -j 4 )

Install missing packages

# Install necessary packages for building ruby (this will only work if
# you've given bob sudo permissions, which is *not* the default)
# rvm requirements

# NOTE: rvm will tell you which packages you (or your sysadmin) need
# to install during this step. As bob does not have sudo
# permissions (likely the case), run:

rvm --autolibs=read-fail requirements

# For instance, if prompted with `libreadline6-dev libsqlite3-dev sqlite3 autoconf' etc
# Install the missing packages with this command, run as your user:
# sudo apt-get install libreadline6-dev libsqlite3-dev sqlite3 autoconf libgdbm-dev libncurses5-dev bison libffi-dev
# Repeat the autolibs test until you see "Requirements installation successful"

Build and install ruby

rvm install 2.0.0

# Use installed ruby as default
rvm use 2.0.0 --default

# Install bundler
gem install bundler

bundle config --global jobs 4

Install libv8 and therubyracer on a C1 server

git clone https://github.com/cowboyd/libv8 /<yourpath>/gems/libv8
cd /<yourpath>/gems/libv8

Edit builder.rb file

Change this line

flags << "vfp2=off vfp3=off" if @compiler.target.include? "arm"

to

flags << "vfp2=off vfp3=on" if @compiler.target.include? "arm"

Add the following line just above flags << "-j4" save and quit

Applying patches

bundle install
bundle exec rake checkout
patch -N -p1 -d vendor/v8 < patches/arm/do-not-use-vfp2.patch
patch -N -p1 -d vendor/v8 < patches/fPIC-for-static.patch

Compile libv8

# Compile
bundle exec rake compile
# Generate binary
bundle exec rake binary
# Install GEM
cd pkg && bundle exec gem install libv8-3.16.14.3-armv7l-linux.gem

Installing the rubyracer

git clone https://github.com/cowboyd/therubyracer /<yourpath>/gems/therubyracer
cd /<yourpath>/gems/therubyracer

In the gemfile comment the following line

gem “rubysl”, :platforms => :rbx

add this line at the end of the file

gem "libv8", :path => '/<yourpath>/gems/libv8'

# Install necessary gems
bundle install
# Compile
bundle exec rake compile
# Generate binary
bundle exec rake build
# Install GEM
cd pkg && bundle exec gem install therubyracer-0.12.1.gem