I am planning to create an installer for a ruby script but I want to be able to ensure that the machine has RVM installed. Is there a way to install RVM completely offline and unobtrusive as well(by unobtrusive, as in create a script that can do everything instead of ask users to add something to their bash_profile or bashrc)
I am not asking for the script itself, just a quick pointer as to how to go about this route(if it is even possible). We have also looked into this question which was helpful enough:
RVM - is there a way for simple offline install?
but a bit misleading as the answer only shows us how to install a ruby in RVM offline. We need to be able to install RVM itself offline, and looking at the script
https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer
do I just include this whole script and change the rvm_releases_url into something else? And is it safe to just append the rvm path to a user's bash_profile, or bashrc instead of asking them to do it?
RVM supports most UNIX like systems and Windows (with Cygwin or Bash on Ubuntu on Windows). The basic requirements are bash , curl , gpg2 and overall GNU version of tools - but RVM tries to autodetect it and install anything that is needed.
RVM is easier to install than Rbenv, RVM has more features than Rbenv, RVM includes a built-in Ruby installation mechanism while Rbenv does not.
As per the suggestion given editing this comment. :-)
- Download the rvm tarball:
curl -sSL https://github.com/rvm/rvm/tarball/stable -o rvm-stable.tar.gz
- Create and enter rvm directory:
mkdir rvm && cd rvm
- Unpack the tar file :
tar --strip-components=1 -xzf ../rvm-stable.tar.gz
- Install rvm:
./install --auto-dotfiles
use --help to get the options
- Load rvm:
source ~/.rvm/scripts/rvm
- Download ruby
o Find tar.bz2 version at:
https://ftp.ruby-lang.org/pub/ruby/ (check sub-directories)
o Download with curl: :
curl -sSL https://ftp.ruby-lang.org/pub/ruby/ruby-2.2.0.tar.bz2 -o ruby-2.2.0.tar.bz2
o Make sure you are downloading with the extension " .tar.bz2 "
- Download rubygems
o Find version at:
https://github.com/rubygems/rubygems/tags
o Download with curl:
curl -sSL http://production.cf.rubygems.org/rubygems/rubygems-2.4.6.tgz -o rubygems-2.4.6.tgz
- Disable automatic dependencies ("requirements") fetching using the following command.
rvm autolibs read-fail
- Manually download and install dependencies
o Get the list of dependencies using
rvm requirements
Clean default gems:
echo "" > ~/.rvm/gemsets/default.gems
Clean global gems:
echo "" > ~/.rvm/gemsets/global.gems
Install Ruby:
rvm install 2.2.0 --rubygems 2.4.6 (this may require sudo password for autolibs)
Install any other Ruby versions you want similarly
Set default Ruby version: rvm use 2.2.0 --default
NOTE : The ruby and other packages should be placed in the " $rvm_path/archives/ " directory.
There are multiple ways to install gems, we can download the gem files,
but the best way seems to be Bundler: http://bundler.io/bundle_package.html
Offline
--------
Create a directory:
mkdir gems; cd gems
Unpack gems:
tar xzf gems.tgz
Install bundler:
gem install bundler-1.8.3.gem
[ This needs internet, to avoid internet connection you need to install bundler gem using --local option with the bundler.x.x.gem file ]
Install gems:
bundle install --local
rvm implode --force
Then remove rvm from following locations:
rm -rf /usr/local/rvm
sudo rm /etc/profile.d/rvm.sh
sudo rm /etc/rvmrc
sudo rm ~/.rvmrc
Check the following files and remove or comment out references to rvm
~/.bashrc
~/.bash_profile
~/.profile
~/.zshrc
~/.zlogin
Comment-out / Remove the following lines from /etc/profile
source /etc/profile.d/sm.sh
source /etc/profile.d/rvm.sh
/etc/profile is a readonly file so use
sudo vim /etc/profile
You can find the installation method here also...
Reference : https://github.com/rvm/rvm-site/blob/master/content/rvm/offline.md
Update: Finally finally finally!!! We have it!
https://rvm.io/rvm/offline/
Full instructions for offline installation!
It should be enough to get copy of the sources and run:
./install
in the root of it,
for installing ruby you will need to get archives of ruby and rubygems to rvm/archives
and set rubygems_version=1.8.24
in rvm/user/db
There is also another project I'm involved that will embed RVM and allow offline installation: https://github.com/railsinstaller/railsinstaller-nix
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With