-
Notifications
You must be signed in to change notification settings - Fork 1
Ruby
Ruby is a dynamic, reflective, object-oriented, general-purpose programming language. It was designed and developed by Yukihiro "Matz" Matsumoto.
The easiest way to install RVM, which is also the eaisest 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 # Note: If this fails, try running it again.
curl -SL https://get.rvm.io | bash -s stable --rails # Install Ruby. Adding --rails also installs Rails
source ~/.rvm/scripts/rvm # Activate RVM
rvm requirements # See any dependency requirements
echo 'export PATH="$PATH:$HOME/.rvm/bin"' >> ~/.profile # Add the RVM path to $PATH
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?
Much like Python, Ruby has an interactive shell called irb.
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
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.
To update Ruby whenever a new version comes out, run rvm get stable.
To update the installed gems, run gem update --system
TODO: Explain what at gem is.
- compass
- sass
- haml
- execjs
- less
- commonjs