Installing Ruby on Rails in your MathLAN home directory using rbenv
You can use Ruby on Rails on the MathLAN, but you will need to upgrade the versions for your account. The following steps were tested to get Ruby 2.6.3 and Rails 5.2.3 installed under your home directory. ITS has been working on upgrading Ruby on Rails on MathLAN so that you should be able to use Ruby 2.7.1 and Rails 6.0.0, but if you have difficulty, please let me know as soon as possible and submit a Help Desk ticket.
1) First you’ll install the rbenv environment
In your home directory, issue this command:
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
Add the .rbenv/bin folder to your PATH environment variable
Watch out, the ending single quote follows the ending double quote!! You should type this in, not copy-and-paste, since the formatting tends to mess things up
$ echo 'export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"' >> ~/.bashrc && source .bashrc
Check to see if that worked:
$ rbenv
If the message says that rbenv was not found, the previous command didn’t work. To fix it, you need to open your .bashrc file, remove anything extra that got in it and put the correct path information in. If you aren’t sure how to do that, follow these steps:
$ emacs ~/.bashrc
You should now have an Emacs window open, scroll to the bottom of the file, there should be a comment about customizations. Unless you know that you need something after that comment, delete all of it and type in:
export PATH="$HOME/.rbenv/bin:$HOME/.rbenv/shims:$PATH"
Save and close the file. You need to run it by typing into the Terminal:
$ source .bashrc
Verify that rbenv is now found:
$ rbenv
Install ruby-build to allow ruby installation:
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
2) Second, you’ll use rbenv to install ruby
In your home directory (this step will take some time):
$ rbenv install 2.6.3 $ rbenv global 2.6.3
Verify that your ruby version is the one you just installed
$ ruby -v
3) Third, install Rails using the gem command
$ gem install bundler
make sure gems are being installed under the .rbenv directory in your home directory
$ gem env home
Should return “/home/*username*/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/”
Install rails:
$ gem install rails -v 5.2.3
Verify rails was installed under your .rbenv folder:
$ which rails
/home/*username*/.rbenv/shims/rails
$ rails -v
Rails 5.2.3