Introduction

Opening remarks

I’m not a Ruby developer, and I’m heavily discovering the ecosystem by now. This are my notes, and if anything seems wrong to you, do not hesitate to send me remarks.

The scenario

For testing purpose, I wanted to play with vagrant-aws and more generally with ruby on my Chromebook.

Vagrant does not support rubygems as installation method anymore (see Mitchell Hashimoto’s post) and of course, there is no binary distribution available for the Chromebook.

So I have to install it from the sources.

The documentation says:

  • Do NOT use the system Ruby - use a Ruby version manager like rvm, chruby, etc

Alright, anyway I don’t want to mess with my system and break Homebrew, so using RVM seems to be a good idea.

Installing RVM

The RVM installation is relatively easy; simply running curl -sSL https://get.rvm.io | bash does the trick. And then those commands make ruby 2.3.0 available via rvm:

$ source ~/.rvm/scripts/rvm  
$ rvm install 2.3.0

The stupid trick here is that everything is installed in my $HOME directory, and as my Chromebook is short on disk space: FS full !

Too bad.

Using a USB stick

So my idea is to install the RVM suite onto a USB stick (because with me I don’t have any SDHC card available).

Preparing the stick

At first, the USB stick must be formatted in extendX (ext4) in order to be able to use symlinks, correct ownership etc.

1sudo mkfs.ext4 -L Lexar /dev/sda1

Note: I’ve found that avoiding spaces in the volume name was good for rvm.

Once connected on the Chromebook, it’s automatically mounted on /media/removable/Lexar. The problem are the options:

1/dev/sda1 on /media/removable/Lexar type ext4 (rw,nosuid,nodev,noexec,relatime,dirsync,data=ordered)

the most problematic is noexec because I want to install executables in it.

So what I did was simply:

sudo mount -o remount /dev/sda1 /media/removable/Lexar

and that did the trick.

Installing RVM on the USB

I will install rvm into /media/removable/Lexar/rvm. In order to avoid any ownership and permission problem I did:

1mkdir /media/removable/Lexar/rvm
2chown chronos:chronos /media/removable/Lexar/rvm

And then I created a simple ~/.rvmrc file as indicated in the documentation with this:

1$ cat ~/.rvmrc                                          
2$ export rvm_path=/media/removable/Lexar/rvm

I also included this in my ~/.zshrc

1if [ -s "$HOME/.rvmrc"   ]; then
2    source "$HOME/.rvmrc"
3fi # to have $rvm_path defined if set
4if [ -s "${rvm_path-$HOME/.rvm}/scripts/rvm"   ]; then
5    source "${rvm_path-$HOME/.rvm}/scripts/rvm"
6fi

Installing rvm

the command I executed were then:

$ curl -sSL https://get.rvm.io | bash
$ source /media/removable/Lexar/rvm/scripts/rvm
$ rvm autolibs enable
$ rvm get stable
$ rvm install 2.3.0

And that did the trick

$ rvm list

rvm rubies

=* ruby-2.3.0 [ x84_64 ]

# => - current
# =* - current && default
#  * - default

Testing with vagrant

Cloning the vagrant sources

1$ sudo mkdir /media/removable/Lexar/tools
2$ sudo chown chronos:chronos /media/removable/Lexar/tools
3$ cd /media/removable/Lexar/tools
4$ git clone https://github.com/mitchellh/vagrant.git

Preparing the rvm file for vagrant

To use the ruby 2.3.0 (that I’ve installed before) with vagrant, I need to create a .rvmrc in the vagrant directory:

$ cd /media/removable/Lexar/tools/vagrant
$ rvm --rvmrc --create 2.3.0@vagrant

Installing bundler

The bundler version that is supported by vagrant must be <= 1.5.2 as written in the Gemfile. So I’m installing version 1.5.2

1$ cd /media/removable/Lexar/tools/vagrant
2$ source .rcmrv
3$ gem install bundler -v 1.5.2

Compiling vagrant

Back to the vagrant documentation, what I must do is now to “compile it”. To do so, the advice is to run:

$ bundle _1.5.2_ install  

(just in case several bundler are present )

I faced this error:

1NoMethodError: undefined method `spec' for nil:NilClass
2Did you mean?  inspect
3An error occurred while installing vagrant (1.8.2.dev), and Bundler cannot continue.
4Make sure that `gem install vagrant -v '1.8.2.dev'` succeeds before bundling.

According to google, this may be an issue with the version of bundler I’m using. As I cannot upgrade the bundler because of vagrant, I’ve decided to take a chance and use a lower version of Ruby

1$ rvm install 2.2.0
2$ rvm --rvmrc --create 2.2.0@vagrant
3$ source .rvmrc
4# and reinstalling bundler
5$ gem install bundler -v 1.5.2            
6$ bundle _1.5.2_ install
7...
8Your bundle is complete!
9Use `bundle show [gemname]` to see where a bundled gem is installed.

VoilĂ !

I can now use vagrant installed fully on the USB stick with

 1$ bundle _1.5.2_ exec vagrant
 2Vagrant appears to be running in a Bundler environment. Your 
 3existing Gemfile will be used. Vagrant will not auto-load any plugins
 4installed with `vagrant plugin`. Vagrant will autoload any plugins in
 5the 'plugins' group in your Gemfile. You can force Vagrant to take over
 6with VAGRANT_FORCE_BUNDLER.
 7
 8You appear to be running Vagrant outside of the official installers.
 9Note that the installers are what ensure that Vagrant has all required
10dependencies, and Vagrant assumes that these dependencies exist. By
11running outside of the installer environment, Vagrant may not function
12properly. To remove this warning, install Vagrant using one of the
13official packages from vagrantup.com.
14...

That’s it for this post; next I will try to install vagrant-aws and play a little bit with it.

stay tuned.