Installing RVM (Ruby Version Manager) - ruby

Can someone please translate this into manageable steps I need to take:
~ Wayne
You must now finish the install manually:
1) Place the folowing line at the end of your shell's loading files(.bashrc or .bash_profile for bash and .zshrc for zsh), after all path/variable settings:
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
Please note that this must only occur once - so, you only need to add it the first time you install rvm.
2) Ensure that there is no 'return' from inside the .bashrc file. (otherwise rvm will be prevented from working properly).
This means that if you see '[ -z ] && return' then you must change this line to:
if [[ ! -z ]] ; then
... original content that was below the && return line ...
fi # <= be sure to close the if.
#EOF .bashrc
Be absolutely *sure* to REMOVE the '&& return'.
If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile.
placing all non-interactive items in the .bashrc, including the 'source' line above
3) Then CLOSE THIS SHELL and open a new one in order to use rvm.
[ -z "$PS1" ] && return
WARNING: you have a 'return' statement in your .bashrc, likely this will cause untold havoc.
This means that if you see '[ -z $PS1 ] && return' then you must change this line to:
if [[ -n $PS1 ]] ; then
... original content that was below the && return line ...
fi # <= be sure to close the if.
#EOF .bashrc
Even if you use zsh you should still adjust the .bashrc as above.
If you have any questions about this please visit #rvm on irc.freenode.net.
Installation of RVM to /home/kapplej/.rvm/ is complete.
I'm a complete newbie, so I am not even sure which one is shell's loading file, and how do I edit it?

I found out how to do this, hope this saves someone time:
to install RVM, enter the following in your terminal:
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
once you install rvm,
depending on which text editor you are using, I am using mate, so I typed in:
mate .bashrc
then once your text editor window opens up, copy and paste this line into it:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
now save and close that window.
then repeat for:
mate .bash_profile
close that terminal and restart a new terminal
type in:
rvm use 1.9.1 (or 1.9.2)
then type in:
ruby -v
and you should see ruby1.9.1
to get back to default, type:
rvm default
now you should get ruby 1.8.6 (or 1.8.7 depending on your default).

I was having trouble with this same step from the RVM website:
The first time you install RVM, you must put the following line into your profile at the very end, after all path loads etc: [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Finally got it working after inserting that line into the .profile file, .bash_profile, and .bashrc files in the home directory of my user on OS X.
It seems like all of these are not necessary. Since the RVM website only says "put the following line into your profile" it's sort of misleading to a noob like me that doesn't really know what my profile is.
Can someone tell me which of these files (profile file, .bash_profile, and .bashrc files) that I can remove that line from?

Related

Need to Fix PATH in my bashrc File for RVM

I did a clean install of my operating system recently and copied my old .bashrc file from a backup. I installed rvm version 1.26.10 (latest stable version). I installed ruby 2.2.0. When I source the .bashrc file I get the following error:
Warning! PATH is not properly set up, '/Users/myusername/.rvm/gems/ruby-2.2.0#mygemset/bin' is not at first place,
usually this is caused by shell initialization files - check them for 'PATH=...' entries,
it might also help to re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles',
to fix temporarily in this shell session run: 'rvm use ruby-2.2.0#mygemset'.
Here are my PATH statements. The first line I included here is one that was in the new install of RVM in the .bash_profile file. I copied them into .bashrc. I'm also running postgres.app which requires the last statement in order to set it as the current PostgreSQL instance.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
export PATH="$PATH:$HOME/.rvm/bin"
export PATH=/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH
I started with the .bashrc file recommended by the Ruby on Rails Tutorial by Michael Hartl (the version current in 2011 or 2012) and the settings used by RVM back then. I know things have changed a bit since then.
My bash knowledge is limited so any help would be appreciated.
UPDATE: 2/2/2015 2:40 pm CST
I changed my bash statements to the following and got rid of the warning:
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
UPDATE: 2/2/2015 5:14 pm CST
Here are my Bash statements:
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/bin/psql"
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Here is the output for echo $PATH:
/Users/username/.rvm/gems/ruby-2.2.0#gemsetname/bin:/Users/username/.rvm/gems/ruby-2.2.0#global/bin:/Users/username/.rvm/rubies/ruby-2.2.0/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin:/Users/username/.rvm/bin:/Users/username:/.rvm/rubies/ruby-2.2.0/bin/ruby:/Applications/Postgres.app/Contents/Versions/9.4/bin:/usr/bin/psql:/Users/username/.rvm/bin
My RVM wouldn't stop complaining about PATH even though the last thing in my .bashrc was this line:
# RVM
source ~/.rvm/scripts/rvm
So I just redirected the complaining to /dev/null:
# RVM
source ~/.rvm/scripts/rvm > /dev/null 2>&1
rvm use default > /dev/null 2>&1
The last line also makes sure RVM is first in PATH, so it doesn't really have anything to complain about.
rvm expects its $PATH stuff to come first in $PATH. You should add items to the $PATH before sourcing rvm, not after.
After dealing with this for several days I decided to go ahead and continue to proceed with my implementation of postgres.app with the warning message I got with RVM. I ran my original bash statements in a different order.
export PATH="$PATH:$HOME/.rvm/bin"
PATH="$PATH:$HOME:/.rvm/rubies/ruby-2.2.0/bin/ruby:/usr/bin/psql:/usr/local:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
export PATH=/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH
I was successful in implementing postgres.app. I still get the warning message but my Ruby on Rails applications are able to find the correct gems and run successfully.
You should add the line like this
export PATH= '/Users/myusername/.rvm/gems/ruby-2.2.0#mygemset/bin:other"
Maybe that can help you

RVM not reading .ruby-gemset files when I open a new tab in my terminal

I have a new install of RVM on Fedora 20.
If I cd to myapp, RVM will read the .ruby-gemset file and switch to the appropriate gemset, but if I open a new tab (control-shift-t) and run rvm gemset list I find that it's using the default gemset.
Does any have any idea what I might be doing wrong?
I've got the following in .bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$HOME/.rvm/bin
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
And I've got more ore less identical content in .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
PATH=$PATH:$HOME/.local/bin:$HOME/bin:$HOME/.rvm/bin
export PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
The terminal is the bog standard one that comes with Fedora.
Putting cd . to ~/.profile fixed the issue for me.
If you are using zsh, put cd . to ~/.zlogin.
I had the same issue, and I was able to fix it. However, my exact solution might be useless for you. I had oh-my-zsh installed. It looks like during installation, it was trying to mimic my .bashrc files and it screwed PATH variable for me. Here's the line I had trouble with:
export PATH="/home/alexander/.rvm/gems/ruby-2.1.1#security/bin:/home/alexander/.rvm/gems/ruby-2.1.1#global/bin:/home/alexander/.rvm/rubies/ruby-2.1.1/bin:/home/alexander/.nvm/v0.10.25/bin:/home/alexander/work/gc-sdk/google-cloud-sdk/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/home/alexander/.rvm/bin"
So, you need to verify if your PATH variable isn't tempered with. And you need to let RVM configure it for you. Both these things can be done with a simple command in your terminal (assuming you have RVM installed):
rvm get stable --auto-dotfiles
Also, there're couple of issues created on GitHub. The common advice is to use command from above and switch your terminal to login shell.
Hope it helps!
Go to:
Preferences(Locate it by clicking bars at the Top-Right immediately after the search icon) -> Choose Your Profile(Located left at the bottom) If you don't have a profile then you can add a new one by clicking the plus icon that precedes the name profiles -> Click on 'Command'(Located at the top) -> Check by clicking the checkbox that states, 'Run command as a login shell'
That worked for me.

OS X lion rvm, ruby install successfully, but doesn't execute. What am I missing?

Okie dokie - IT recently updated my system to lion, fresh install.
I followed the instructions at Federico Araujo's blog to prep for my install (http://www.frederico-araujo.com/2011/07/30/installing-rails-on-os-x-lion-with-homebrew-rvm-and-mysql/), with the exception that I used
curl -L get.rvm.io | bash -s stable --rails
from http://beginrescueend.com/rvm/install/ to handle the rvm/rubygems/rails install. No errors reported.
I've added
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM function
to my .profile, closed all windows, reopened terminal and ensured that .profile was sourced on launching terminal.
But no matter what I do, I am unable to use RVM to switch into 1.9.3 and use rails.
Nothing in path or $HOME/.rvm/scripts/rvm added to path:
$ rvm list
-sh: rvm: command not found
and
$ type rvm | head -1
-sh: type: rvm: not found
If I add $HOME/.rvm/bin to path, I can see the RVM jazz, but
$ type rvm | head -1
rvm is hashed (/Users/soychicka/.rvm/bin/rvm)
And if I add $HOME/.rvm/scripts to path, and
$ type rvm | head -1
rvm is /Users/soychicka/.rvm/scripts/rvm
And in the last case, issuing 'rvm list' doesn't throw an error, but simply returns a new prompt.
Again, it appears that everything compiled and installed properly; just can't get RVM to jf Ruby 1.9.3 and assorted gems into use.
What is wrong here? I've looked through all apparently relevant questions, but haven't een anything that appears to match...
This does not bode well for my attempts to open my team's eyes to the ease of prototyping with Rails...
UPDATE:
Adding the following to my .profile (but not .bash_profile) appears to have resolved the issue:
PATH=$HOME/.rvm/bin:$PATH
if [ -s "$HOME/.rvmrc" ]; then
source "$HOME/.rvmrc"
fi # to have $rvm_path defined if set
if [ -s "${rvm_path-$HOME/.rvm}/scripts/rvm" ]; then
source "${rvm_path-$HOME/.rvm}/scripts/rvm"
fi
But to me, it feels a bit too hacky to be comfortable, and it still isn't clear why this differs from my other lion installs... First install was in February, but attempts to set up rvm on systems last month and this following the same set of instructions failed. Anybody have ideas?
From man bash
After reading that file, it looks for ~/.bash_profile,
~/.bash_login, and ~/.profile, in that order, and reads and
executes commands from the first one that exists and is readable.
Are you sure none of the other files exist?
Also execute
source "$HOME/.rvm/scripts/rvm"
in your shell and see if it works as expected.
I hope you're aware of the security implications of piping curl output directly into bash.
Adding the following to my .profile (but not .bash_profile) appears to have resolved the issue:
PATH=$HOME/.rvm/bin:$PATH
if [ -s "$HOME/.rvmrc" ]; then
source "$HOME/.rvmrc"
fi # to have $rvm_path defined if set
if [ -s "${rvm_path-$HOME/.rvm}/scripts/rvm" ]; then
source "${rvm_path-$HOME/.rvm}/scripts/rvm"
fi

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm": What does it do?

I am installing Ruby on Rails on Mac OS X. The tutorial I am following says to add:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
to ~/.bash_profile.
What does this line do?
Thanks
[[ -s "$HOME/.rvm/scripts/rvm" ]]
This portion is a test condition ([[ is the new test command). -s returns TRUE if the file rvm present over at $HOME/.rvm/scripts/ location exists and is of size greater than zero.
&&
This is a logical and operator. It executes the statement on the right IF AND ONLY IF statement on the left returns true.
. "$HOME/.rvm/scripts/rvm"
. is short for source command. You are sourcing the file in your current shell and not forking a new sub-shell
It checks if the file exists and has size great than zero, and if so, it executes the file.
The file is "$HOME/.rvm/scripts/rvm. $HOME is a variable, usually set to your homedir (~), something like /home/youruser. In that directory you should find a hidden folder .rvm, which contains a folder scripts, which contains an executable file called rvm.
I just installed rvm and run rvm notes as a shell command. The output includes besides other useful information the following lines.
If you wish to use RVM in an interactive fashion in other shells
then place the following line at the end of your shell's loading files
(.bashrc or .bash_profile for bash and .zshenv for zsh),
after all PATH/variable settings:
[[ -s "/home/username/.rvm/scripts/rvm" ]] && source "/home/username/.rvm/scripts/rvm" # This loads RVM into a shell session.
I guess it is always a good idea to take a look at the latest release notes.
Also I found the "How to use RVM" screencast very helpful! It also includes information about your question in the first minutes.

Syntax error when running RVM function

First of all, I'm running bash 3.2.48 on mac osx 10.7.1 with xCode 4 installed.
I've downloaded RVM like specified in the official documentation but when I do
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
I get an error
-bash: /Users/kevin/.rvm/scripts/rvm: line 28: syntax error near unexpected token `done'
-bash: /Users/kevin/.rvm/scripts/rvm: line 28: ` done'
I've searched either on Google, the rvm github issue tracker and stackoverflow but I didn't get any info on similar issue or anything that helped me find a solution.
Nobody seems to have trouble like this installing RVM 1.8.3 so I guess something is going wrong when I install on my mac.
Here's the corresponding part of the script.
#!/usr/bin/env bash
# rvm : Ruby enVironment Manager
# https://rvm.beginrescueend.com
# https://github.com/wayneeseguin/rvm
# Is RVM loaded as a shell function already?
export HOME="${HOME%%+(\/)}" # Remove trailing slashes if they exist on HOME
if (( ${rvm_ignore_rvmrc:=0} == 0 ))
then
for rvmrc in /etc/rvmrc "$HOME/.rvmrc"
do
if [[ -f "$rvmrc" ]]
then
if \grep '^\s*rvm .*$' "$rvmrc" >/dev/null 2>&1
then
printf "\nError:
$rvmrc is for rvm settings only.
rvm CLI may NOT be called from within $rvmrc.
Skipping the loading of $rvmrc"
return 1
else
source "$rvmrc"
fi
fi
done
fi
The error triggers on done just before the last if
Any help would be greatly appreciated.
EDIT: I found the problem, I mispelled an alias as fi. I just renamed it and it worked.
Thank you for your help. Sorry for this useless question.
I believe you're not supposed to type that but rather add it to your ~/.bash_profile at least that's how I did it on linux before, could you point where are you reading the steps for installation from?
That is correct, thats not for running at the commandline, that goes in your .bash_profile or .bashrc (with a corresponding
if [ -f "$HOME/.bashrc" ]; then
source $HOME/.bashrc
fi
in your .bash_profile)
So I decided to switch to zsh for a few reasons and it worked without doing anything but putting the line into the zshrc. But I will try to find the problem anyway.

Resources