Skip to content
Jason Charney edited this page Nov 9, 2015 · 15 revisions

TODO: I want to ad a section about Jekyll later.

Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It was designed and developed by Yukihiro "Matz" Matsumoto.

Removing the other stuff with the good stuff

One of my pet peeves with Linux distributions is that a lot of the binaries, even when you run sudo apt-get update && sudo apt-get upgrade the software you need to be upgraded is never upgraded to the latest stable binary like it should be. I mean, what the heck is the version of Ruby on Raspberry Pi STILL doing using Ruby 1.9.1 or 1.9.3 or even 2.1? As of this wrting, we are at 2.2.3, and that was upgraded a few months ago. That's how long it's been since Matz and his team had to fix something.

So what's install that really shouldn't be?

$ dpkg-query -l | grep -i "ruby"
ii  libruby1.9.1             1.9.3.484-2        armhf     Libraries necessary to run Ruby 1.9.1
ii  libruby1.9.1-dbg         1.9.3.484-2        armhf     Debugging symbols for Ruby 1.9.1
ii  libruby2.1:armhf         2.1.5-2+deb8u2     armhf     Libraries necessary to run Ruby 2.1
ii  libtcltk-ruby1.9.1       1.9.3.484-2        armhf     Tcl/Tk interface for Ruby 1.9.1
ii  ri1.9.1                  1.9.3.484-2        all       Ruby Interactive reference (for Ruby 1.9.1)
ii  ruby                     1:2.1.5+deb8u1     all       Interpreter of object-oriented scripting language Ruby (default version)
ii  ruby1.9.1                1.9.3.484-2        armhf     Interpreter of object-oriented scripting language Ruby
ii  ruby1.9.1-dev            1.9.3.484-2        armhf     Header files for compiling extension modules for the Ruby 1.9.1
ii  ruby1.9.1-examples       1.9.3.484-2        all       Examples for Ruby 1.9
ii  ruby1.9.1-full           1.9.3.484-2        all       Ruby 1.9.1 full installation
ii  ruby1.9.3                1.9.3.484-2        all       Interpreter of object-oriented scripting language Ruby, version 1.9.3
ii  ruby2.1                  2.1.5-2+deb8u2     armhf     Interpreter of object-oriented scripting language Ruby
ii  rubygems-integration     1.8                all       integration of Debian Ruby packages with Rubygems

What happens when we try to remove it?

$ sudo apt-get remove ruby*
...
The following packages were automatically installed and are no longer required:
  javascript-common libboost-atomic1.55.0 libboost-filesystem1.55.0 libboost-program-options1.55.0
  libboost-regex1.55.0 libboost-thread1.55.0 libcwiid1 libfftw3-single3 libjs-jquery libjs-prettify
  libqscintilla2-11 libqscintilla2-l10n libqt4-network libqt4-xmlpatterns libqtwebkit4 libscsynth1
  libyaml-0-2 supercollider supercollider-common supercollider-ide supercollider-language
  supercollider-server supercollider-supernova
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  libruby1.9.1 libruby1.9.1-dbg libruby2.1 libtcltk-ruby1.9.1 ri1.9.1 ruby ruby1.9.1 ruby1.9.1-dev
  ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 ruby2.1 rubygems-integration sonic-pi
0 upgraded, 0 newly installed, 14 to remove and 1 not upgraded.
After this operation, 163 MB disk space will be freed.
Do you want to continue? [Y/n]

Before deleting anything, look to see what it is used for first.

The following packages were automatically installed and are no longer required: javascript-common libcwiid1 libfftw3-single3 libjs-jquery libjs-prettify libscsynth1

The following packages will be REMOVED: libruby1.9.1 libruby1.9.1-dbg libruby2.1 libtcltk-ruby1.9.1 ri1.9.1 ruby ruby1.9.1 ruby1.9.1-dev ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 ruby2.1 rubygems-integration

Here's what we do know.

  • We can remove sonic-pi (Found at the Sonic Pi website) and reinstall it later, possibly with a better version of it.
  • We can remove libscsynth1 supercollider supercollider-common supercollider-ide supercollider-language supercollider-server supercollider-supernova (Found at the Supercollider website) with sudo apt-get autoremove and reinstall that later.
  • We could remove libboost-atomic1.55.0 libboost-filesystem1.55.0 libboost-program-options1.55.0 libboost-regex1.55.0 libboost-thread1.55.0 as well as anything else libboost later and replace it with a newer version of the Boost C++ library later.
  • We could remove libyaml-0-2 with a better version of it from the YAML website. There's a good chance it could also be included with our new Ruby install as a gem.
  • We could remove libqscintilla2-11 libqscintilla2-l10n. According to the QScintilla website, QScintilla is a Qt port of Scintilla. Consider also looking at the [Qt5 for Raspberry Pi](Qt5 for Raspberry Pi) page of this wiki to attempt to replace the Qt4 packages libqt4-network libqt4-xmlpatterns libqtwebkit4
  • The following packages I still need to make a decision on, but I assure you I will have a response shortly. javascript-common libcwiid1 libfftw3-single3 libjs-jquery libjs-prettify

Install Ruby using RVM

The easiest way to install RVM, which is also the easiest way to install [Ruby on Rails](Ruby on Rails) and JRuby, a Ruby implementation built ontop of the Java Virtual Machine.

WARNING! If you are running tmux inside the terminal you are using, exit that first! Some of the RVM installation stuff might not install right within it.

For this installation, we're going to go all out and install Ruby on Rails with Ruby (a.k.a. Rails).

cd ~
gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3  # 1. Note: If this fails, try running it again.
curl -SL https://get.rvm.io | bash -s stable --ruby        # 2. Install Ruby. Don't forget the "--ruby" part! If you don't include it, you'll just have RVM stuff installed but not Ruby.
echo "source ~/.profile" >> ~/.bash_profile                # 3. A new version of RVM appears to create the export paths for RVM now.
source ~/.rvm/scripts/rvm                                  # 4. Activate RVM
rvm requirements                                           # 5. See any dependency requirements. If you are installing from cygwin, look up the missing software in the cygwin setup program. Try this step until "Requirements installation successful."

# echo 'export PATH="$PATH:$HOME/.rvm/bin"' >> ~/.profile    # Add the RVM path to $PATH (Not necessary anymore since it's already done in an earlier step.)
ruby --version                                             # 6. Check what version of ruby is installed if ruby is not found, something went wrong.

In lieu of using the --rails argument in the curl command, I recommend running gem install rails later. This would be recommended if you are thinking about using Jekyll instead of Ruby on Rails or if you are installing Ruby for Raspberry Pi.

For Cygwin, if a couple of the requirements for the rvm requirements step is to install mingw64-i686-gcc, mingw64-x86_64-gcc, install mingw64-i686-gcc-core, mingw64-x86_64-gcc-core, mingw64-i686-g++, mingw64-x86_64-g++, but none of the packages for Ada, Fortran, or ObjC. Those files are corrupt apparently.

NOTE: RVM will look for these packages in apt-get: gawk, libreadline6-dev, libssl-dev, libyaml-dev, libsqlite3-dev, sqlite3, libgdbm-dev, libncurses5-dev, bison, libffi-dev.

TODO: Show how to write a ruby script end execute it.

TODO: Wasn't there some program that could make ruby programs into executable programs?

IRB

Much like Python, Ruby has an interactive shell called irb.

Rails projects

Since I chose to install Rails with Ruby, I can start a new rails project by running the following command.

rails new $project_dir

Rails projects use the Model-View-Controler (MVC) software architectual pattern. My knowledge on Rails in quite limited at the moment.

TODO: Show how to create a rails project

Install JRuby and set which Ruby as default

PREQUIREMENT: If you haven't installed Java do so. From Oracle would be better than whatever IcedTea stuff that came with Odroid. The Java page has instructions for that.

We have Ruby and Rails installed, now it's time to install one more piece of the puzzle: JRuby. But when we do it, we will also need to know how to set our default version of ruby.

rvm install jruby             # Download and install jruby
rvm list                      # take note that ruby is not the current shell that irb is using.
rvm use ruby-2.2.0 --default  # set ruby as the irb shell.  As a good measure, let's remind it to set it as the default shell.

We can always set JRuby as the IRB shell by using rvm use jruby when we need it.

Before we wrap this up, close the terminal then reopen it. Check our versions of RVM and Ruby.

rvm --version
rvm 1.26.9 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
ruby --version
ruby 2.2.0p0 (2014-12-25 revision 49005) [armv7l-linux-eabihf]

Great! Now let's see how the path look.

echo $PATH
/usr/lib/arm-linux-gnueabihf/libfm:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/odroid/.rvm/bin

I'm not sure what /usr/lib/arm-linux-gnueabihf/libfm does, but we'll worry about that later. Let's open tmux and check our $PATH again.

tmux
echo $PATH
/home/odroid/.rvm/gems/ruby-2.2.0/bin:/home/odroid/.rvm/gems/ruby-2.2.0@global/bin:/home/odroid/.rvm/rubies/ruby-2.2.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/odroid/.rvm/bin:/home/odroid/.rvm/bin:/home/odroid/.rvm/bin

Clearly, we have a problem. The /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/home/odroid/.rvm/bin is OK, it's all that other stuff that make you wonder, "Why doesn't that show up when I'm not running tmux?" and "Why does /home/odroid/.rvm/bin show up twice?"

The second question is easy to answer. It's because when you open Tmux, you open another shell inside that shell. In fact if you ran bash inside of bash inside of bash, /home/odroid/.rvm/bin would show up three different times. Understandibly, we don't want that, and we should probably fix it. This means the instructions on this page need to be modified. Perhaps that path we added should be exported to ~/.bashrc instead of ~/.profile. (It probably should.)

TODO: Fix Ruby's path.

The first question is a little bit more complex. How did we get '/home/odroid/.rvm/gems/ruby-2.2.0/bin:/home/odroid/.rvm/gems/ruby-2.2.0@global/bin:/home/odroid/.rvm/rubies/ruby-2.2.0/binprefixed to the$PATH`? It's one that I should look up the answer too. So yeah, we should probably fix this. page.

TODO: FIX Ruby's path on PATH. This might be the solution but I'm have some trouble understanding what they mean. http://unix.stackexchange.com/questions/124528/rvm-tmux-duplicate-entries-in-path

Other than than, ruby, irb, rvm, gem, and jruby should be read to use.

TODO: Show examples of how to use Ruby.

Updating Ruby and the Gems

To update Ruby whenever a new version comes out, run rvm get stable.

To update the installed gems, run gem update --system

Gems worth installing

TODO: Explain what at gem is.

  • compass
  • sass
  • haml
  • execjs
  • less
  • commonjs

See Also

External Links

Clone this wiki locally