My teams use development environments powered by Vagrant, which I highly recommend. This however requires we either maintain or manage a variety of recipes/cookbooks, or that we bootstrap our dev virtual machines identically. I generally prefer the latter to avoid issues with connecting to Chef that have burned me in the past, or just general third-party woes. Bootstrapping an app then requires some scripting to properly setup Ruby and thereby Compass and Sass gems which we use for compiling our assets.

That being said, we’ve chosen to use RVM instead of rbenv or any of the alternatives just because it suits us best. I’m not evangelical one way or the other.

We’ve essentially taken this superb guide from AJ ONeal and made a crisp little bash script. Finally, the meat of the script. We put this in every bootstrap script to setup the basics of ruby/compass/sass:


sudo chmod -R 0777 /home/vagrant
sudo chown vagrant:vagrant -R /home/vagrant

echo 'Installing Vennli Frontend Tools..'
sudo apt-get install -y npm -y
sudo npm config set registry
sudo npm install source-map -g
sudo npm update --save-dev
sudo npm install uglify-js@1.3 -g

echo 'Installing Ruby and Gems..'
sudo apt-get remove --purge ruby-rvm ruby
sudo rm -rf /usr/share/ruby-rvm /etc/rmvrc /etc/profile.d/
rm -rf ~/.rvm* ~/.gem/ ~/.bundle*
echo 'gem: --no-rdoc --no-ri' >> ~/.gemrc
echo "export rvm_max_time_flag=20" >> ~/.rvmrc
#tail ~/.gemrc
echo "[[ -s '${HOME}/.rvm/scripts/rvm' ]] && source '${HOME}/.rvm/scripts/rvm'" >> ~/.bashrc
curl -L | bash -s stable --ruby
sudo gpg --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3

#source /home/vagrant/.rvm/scripts/rvm
source /usr/local/rvm/scripts/rvm

# Fix permissions and add Vagrant to the RVM group
sudo rvm group add rvm vagrant
sudo rvm fix-permissions

# Now that permissions are fixed, install ruby 2.2.2
sudo rvm install 2.2.2

gem install cyaml
gem install compass
gem install sass
gem install bundler

# Reinstall ruby 1.9.3 for backwards compatability
sudo bash -c "rvm reinstall 1.9.3"

# Use Ruby 2.2.2 by default globally
sudo rvm --default use 2.2.2



Leave a Reply

Your email address will not be published. Required fields are marked *