install RVM offline completely - ruby

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?

As per the suggestion given editing this comment. :-)
Installing RVM offline :
- 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, rubygems and yaml :
- 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
Install dependencies :
- 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
Installing Ruby :
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.
Installing gems :
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
Example installing rails gem:
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
UNINSTALL rvm :
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

Related

Install RVM in a specific location

Installing RVM with command below gets installed to ${HOME}/.rvm. Instead, I'm looking for a way to specify the location where .rvm directory gets created so that I can control where RVM is installed.
curl -sSL https://get.rvm.io | bash
Is there a way to specify this while installing RVM?
Yes, by creating a symlink from ~/.rvm to $TARGET_DIR and before installing rvm. In this example I am using a directory called 'myrvm':
ln -sf myrvm/ ~/.rvm
Then when I check the contents of 'myrvm', I see rvm is installed there. RVM still works seemlessly

Why can't I install Sass on Mac OS? [duplicate]

I am not able to install and run fakes3 gem on El Capitan Beta 5.
I tried:
sudo gem install fakes3
ERROR: While executing gem ... (Errno::EPERM)
Operation not permitted - /usr/bin/fakes3
Then I tried doing it the cocoapods way. It worked for cocoapods but not for fakes3.
mkdir -p $HOME/Software/ruby
export GEM_HOME=$HOME/Software/ruby
gem install cocoapods
[...]
1 gem installed
gem install fakes3
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
Disclaimer: #theTinMan and other Ruby developers often point out not to use sudo when installing gems and point to things like RVM. That's absolutely true when doing Ruby development. Go ahead and use that.
However, many of us just want some binary that happens to be distributed as a gem (e.g. fakes3, cocoapods, xcpretty …). I definitely don't want to bother with managing a separate ruby. Here are your quicker options:
Option 1: Keep using sudo
Using sudo is probably fine if you want these tools to be installed globally.
The problem is that these binaries are installed into /usr/bin, which is off-limits since El Capitan. However, you can install them into /usr/local/bin instead. That's where Homebrew install its stuff, so it probably exists already.
sudo gem install fakes3 -n/usr/local/bin
Gems will be installed into /usr/local/bin and every user on your system can use them if it's in their PATH.
Option 2: Install in your home directory (without sudo)
The following will install gems in ~/.gem and put binaries in ~/bin (which you should then add to your PATH).
gem install fakes3 --user-install -n~/bin
Make it the default
Either way, you can add these parameters to your ~/.gemrc so you don't have to remember them:
gem: -n/usr/local/bin
i.e. echo "gem: -n/usr/local/bin" >> ~/.gemrc
or
gem: --user-install -n~/bin
i.e. echo "gem: --user-install -n~/bin" >> ~/.gemrc
(Tip: You can also throw in --no-document to skip generating Ruby developer documentation.)
In my case, I had to re-install Ruby using Brew. That seems to have solved the problem as I can install gems again.
brew install ruby
After this, you need to log out and log back in, either graphically or just restarting your terminal.
That is because of the new security function of OS X "El Capitan".
Try adding --user-install instead of using sudo:
$ gem install *** --user-install
For example, if you want to install fake3 just use:
$ gem install fake3 --user-install
sudo gem install -n /usr/local/bin cocoapods
Try this. It will definately work.
You have to update Xcode to the newest one (v7.0.1) and everything will work as normal.
If after you install the newest Xcode and still doesn't work try to install gem in this way:
sudo gem install -n /usr/local/bin GEM_NAME_HERE
For example:
sudo gem install -n /usr/local/bin fakes3
sudo gem install -n /usr/local/bin compass
sudo gem install -n /usr/local/bin susy
Looks like when upgrading to OS X El Capitain, the /usr/local directory is modified in multiple ways :
user permissions are reset (this is also a problem for people using Homebrew)
binaries and symlinks might have been deleted or altered
[Edit] There's also a preliminary thing to do : upgrade Xcode...
Solution for #1 :
$ sudo chown -R $(whoami):admin /usr/local
This will fix permissions on the /usr/local directory which will then help both gem install and brew install|link|... commands working properly.
Solution to #2 :
Ruby based issues
Make sure you have fixed the permissions of the /usr/local directory (see #1 above)
First try to reinstall your gem using :
sudo gem install <gemname>
Note that it will install the latest version of the specified gem.
If you don't want to face backward-compatibility issues, I suggest that you first determine which version of which gem you want to get and then reinstall it with the -v version. See an exemple below to make sure that the system won't get a new version of capistrano.
$ gem list | grep capistrano
capistrano (3.4.0, 3.2.1, 2.14.2)
$ sudo gem install capistrano -v 3.4.0
Brew based issues
Update brew and upgrade your formulas
$ brew update
$ brew upgrade
You might also need to re-link some of them manually
$ brew link <formula>
As it have been said, the issue comes from a security function of Mac OSX since "El Capitan".
Using the default system Ruby, the install process happens in the /Library/Ruby/Gems/2.0.0 directory which is not available to the user and gives the error.
You can have a look to your Ruby environments parameters with the command
$ gem env
There is an INSTALLATION DIRECTORY and a USER INSTALLATION DIRECTORY. To use the user installation directory instead of the default installation directory, you can use --user-install parameter instead as using sudo which is never a recommanded way of doing.
$ gem install myGemName --user-install
There should not be any rights issue anymore in the process. The gems are then installed in the user directory : ~/.gem/Ruby/2.0.0/bin
But to make the installed gems available, this directory should be available in your path. According to the Ruby’s faq, you can add the following line to your ~/.bash_profile or ~/.bashrc
if which ruby >/dev/null && which gem >/dev/null; then
PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
fi
Then close and reload your terminal or reload your .bash_profile or .bashrc (. ~/.bash_profile)
This is the solution that I have used:
Note: this fix is for compass as I wrote it on another SO question, but I have used the same process to restore functionality to all terminal processes, obviously the gems you are installing are different, but the process is the same.
I had the same issue. It is due to Apple implementing System Integrity Protection (SIP). You have to first disable that...
Reboot in recovery mode:
Reboot and hold Command + R until you see the apple logo.
Once booted select Utilities > Terminal from top bar.
type: csrutil disable
then type: reboot
Once rebooted
Open terminal back up and enter the commands:
sudo gem uninstall bundler
sudo gem install bundler
sudo gem install compass
sudo gem install sass
sudo gem update --system
The the individual gems that failed need to be fixed, so for each do the following:
On my machine this was the first dependency not working so I listed it:
sudo gem pristine ffi --version 1.9.3
Proceed through the list of gems that need to be repaired. In all you are looking at about 10 minutes to fix it, but you will have terminal commands for compass working.
Screenshot
If the gem you are trying to install requires xml libraries, then try this:
sudo gem install -n /usr/local/bin <gem_name> -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
Specifically, I ran into a problem while installing the nokogiri gem v 1.6.8 on OS X El Capitan
and this finally worked for me:
sudo gem install -n /usr/local/bin nokogiri -- --use-system-libraries --with-xml2-include=/usr/include/libxml2 --with-xml2-lib=/usr/lib/
To make sure you have libxml2 and libxslt installed, you can do:
brew install libxml2 libxslt
brew install libiconv
and then check to make sure you have xcode command line tools installed:
xcode-select --install
should return this error:
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Reinstalling RVM worked for me, but I had to reinstall all of my gems afterward:
rvm implode
\curl -sSL https://get.rvm.io | bash -s stable --ruby
rvm reload
I ran across the same issue after installing El Capitan, I tried to install sass and compass into a symfony project, the following command returned the following error:
$ sudo gem install compass
ERROR: Error installing compass:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for ffi.h... /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
So I then tried to install sass with:
$ sudo gem install sass
Got the same error message, after some googling I managed to install sass using the following command:
$ sudo gem install -n /usr/local/bin sass
The above worked for me with installing sass but did not work for installing compass. I read that someone somewhere had opened an instance of xcode then closed it again, then successfully ran the same command after which worked for them.
I attempted to open xcode but was prompted with a message saying that the version of xcode installed was not compatible with El Capitan.
So I then updated xcode from the app store, re-ran the following command which this time ran successfully:
$ sudo gem install -n /usr/local/bin compass
I was then able to run $ compass init
I now have all my gems working and can proceed to build some lovely sass stuff :)
I had to rm -rf ./vendor then run bundle install again.
You might have two options:
If you've installed ruby and rails, you can first try running the command:
rvm fix-permissions
You can uninstall ruby completely, and reinstall in your ~ directory aka your home directory.
If you're using homebrew the command is:
brew uninstall ruby
For rails uninstall without homebrew the command is:
rvm remove
This should reinstall the latest ruby by running command:
curl -L https://get.rvm.io | bash -s stable --rails<br>
Mac has 2.6.3 factory installed, and it's required... if not run this command:
rvm install "ruby-2.6.3"
and then:
gem install rails
You'll get a few error messages at the end saying you have to add some other bundles...
Just make sure you're in the home ~ directory when you're installing so the permissions won't be an issue, but just in case...
I again ran:
rvm fix-permissions
and:
rvm debug
which told me I had to download yarn, I didn't save the output for it. Basically I did whatever the prompt told me to do if it had to do with my OS.
-D
I don't like to install stuff with sudo.
once you start with sudo you can't stop..
try giving permissions to the Gems directory.
sudo chown -R $(whoami) /Library/Ruby/Gems/2.0.0
sudo chown -R $(whoami):admin /usr/local
That will give permissions back (Homebrew installs ruby there)

How to remove ruby completely from my linux system

I broke ruby in my system by doing this:
mkdir /tmp/ruby && cd /tmp/ruby
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p327.tar.gz
tar xfvz ruby-1.9.3-p327.tar.gz
cd ruby-1.9.3-p327
./configure
make
sudo make install
The problem occurs in many different circumstances:
Trying to acess IRB:
$ irb
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
Trying to install gems:
$ gem install rubygems-update
<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
I tried to use synaptic to remove all ruby related packages, and reinstalled it, but it didn't solve my problem. I didn't install ruby through rvm, I used rbenv:
rbenv uninstall 2.2.3
rbenv install 2.2.3
I also tried the purge command. I don't know what's happening. I'm very desperate looking for a solution. The directory /tmp/Ruby had been deleted by me... I deleted it using thunar.
Someone please help me.
If you still have that /tmp/ruby directory, than go there and run
$ sudo make uninstall
This command will uninstall all previously installed files from that ruby. It usually installs into /usr directory, so if you had a system ruby (installed from Synaptic or apt-get (it seems you're using Debian-based system such as Ubuntu) could also break your system ruby, you need to reinstall it too. You can find out it this way:
$ sudo apt-get install aptitude # install aptitude for easy searching
$ aptitude search ruby | grep ^i # find all installed packages, containing ruby in their titles
In contrast, rbenv or rvm don't use your system paths for installation, instead they use your home folder and install to a path like ~/.rbenv, but since you mess up your system folder rbenv may look to a different place (it's hard to say for sure what's going on right now).
After you've cleaned up your unwanted ruby installation, use ruby-build to install desired ruby with rbenv:
$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build # install ruby-build
$ rbenv install -l # list available versions
$ rbenv install 2.2.3 # install desired version
I hope that helps.
First uninstall the compiled from source version you installed:
cd /tmp/ruby
sudo make uninstall
Then purge system ruby:
sudo apt-get purge
Then install RVM, close and reopen your terminal, and do rvm install 2.2.0

Installing RVM on existing ruby1.8 installation

I have a big problem with my Debian server configuration. Someone before me has made a big mess with ruby installation and now i can't manage to get it all working. What i'm trying to do now is to get back to environment, where ruby1.8 is installed and rails app is working correctly with apache+passenger. If it would be working on RVM it would be perfect. Here is the story:
There was ruby 1.8 installed on a server. The person has removed it with sudo apt-get remove ruby1.8 and then installed version 2.0.x manually using those commands:
mkdir /tmp/ruby && cd /tmp/ruby
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | tar xz
cd ruby-2.0.0-p247
./configure
make
sudo make install
Then, he has removed all the dirs listed by whereis ruby with rm command.
And here i came - i want to install RVM on this server. The problem is, no matter what i do, i get a lot of errors from all sides. Steps i've done:
# Install RVM
curl -L https://get.rvm.io | bash -s stable
# install 1.8.7 version
rvm install 1.8.7
# use 1.8.7
rvm use 1.8.7
# Install gems
bundle install
First thing (and that's just a tip of iceberg) is that i'm not able to start apache2 in cause of the following error:
apache2: Syntax error on line 203 of /etc/apache2/apache2.conf: Syntax
error on line 1 of /etc/apache2/mods-enabled/passenger.load: Cannot
load
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
into server:
/usr/lib/ruby/gems/1.8/gems/passenger-4.0.5/libout/apache2/mod_passenger.so:
cannot open shared object file: No such file or directory Action
'configtest' failed.
Looks like there is even no /usr/lib/ruby/ dir on my system right now.
The question is: is there any way to reset all ruby-releated libraries on debian to the original state (debian without ruby installed) and install working RVM on top of that? Thanks in advance for any help.
Verify if, Is ruby installed correct by ruby -v
Install phusion passenger
$ sudo gem install passenger
$ sudo passenger-install-apache2-module
and then follow onscreen instructions

Ruby Installation

Silly question. I went to http://rubyinstaller.org/downloads/ and installed Ruby 1.9.2, but when I pull up command prompt and type ruby -v it's not recognized as a command. Am I doing something wrong? I had version 1.8.6 installed, but I couldn't figure out how to upgrade my Ruby version so I uninstalled it and tried a fresh install.
You need to add Ruby to your path variable, regardless of your operating system.
Say you're using Windows, and Ruby is installed in C:\Program Files\ruby1.9.2\ You'll need to find out which folder the ruby executable is in (ruby.exe). Sometimes it'll be in the main folder, but usually for open source packages it'll be in the subfolder bin. To add ruby to your path, then, you'll need to use C:\Program Files\ruby1.9.1\bin
You can do this on the command line like so:
path = %PATH%;C:\Program Files\ruby1.9.2\bin
Note that %PATH% has a percent sign on either side, and that there's a semi-colon separating it from the new value. You'll have to type it in each time you start a new command line window, but it might be a good idea to try this the first time, because any mistakes in typing it in won't be permanent.
To change it permanently you can find it in Control Panel > System > Advanced System Settings. Switch to the Advanced tab, then click Environment Variables... Find path under System Variables, and add ;C:\Program Files\ruby1.9.2\bin to the end. Note that you still need a semi-colon to separate the new value from everything else, and that you don't need %PATH% this time (in face, the value you see is what %PATH% represents). Once you've done that, restart any command windows you had open, and you should be able to access things just fine!
These instructions will be different if you're using Linux or a Mac - try googling environment variables if you'd like to know more!
Did you add your bin Directory to the PATH?
Ok, when you install it, it will go in a directory:
ex: c:/program files/ruby1.9.x/
inside you will have a /bin directory which contains all the command for the command line.
To be able to use ruby in the command line, you must add it to your $PATH variable in the OS environment.
ex:
path=c:/program files/ruby1.9.x/bin;etc...
Install RVM with RUBY
sudo apt-get install curl
after install
install rvm also ruby
\curl -sSL https://get.rvm.io | bash -s stable --ruby
if you face issue with the above line (Failed to connect to get.rvm.io port 443: Network is unreachable)
in browser go to https://get.rvm.io save the page in any location
make it executable file name rvm-installer
chmod +x rvm-installer
then do the following
bash rvm-installer stable --ruby
source /home/username/.rvm/scripts/rvm
then check rvm list
note the version of ruby listing on terminal
if you failed to install due to the dependency
sudo apt-get update
sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev
if the above steps not installed ruby latest version you can do it by
rvm install ruby-2.1.1
installation using rvm
sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
curl -L https://get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
echo "source ~/.rvm/scripts/rvm" >> ~/.bashrc
rvm install 2.1.1
rvm use 2.1.1 --default ruby -v
**change terminal to login shell. open a new terminal **
then rvm use 2.1.1 => ( 2.1.1 version )
then its done!
pd#admin:~$ ruby -v
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]
programmers keep on coding with ruby.

Resources