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.
Related
As the title says, after running the rvm get stable code in bash, I started getting an error, -bash: [: too many arguments. This error pops up when I do any command, but executes the command properly. ls and cd for instance will execute as expected, but then print out the error.
I'm running macOS Sierra. Any help is greatly appreciated!
I had the same issue after running rvm get stable.
Since rvm needs to run in the shell session as a function, removing the line [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" from your .bash_profile or .bashrc is not an option.
On my environment the cause was due to a conflict between an old installation of bash-it and rvm. If you're using bash-it and encountering this issue, this may help.
I took the following steps:
Backed up my .bash_profile (if you have .bashrc you may want to back it up as well).
Ran bash-it's uninstall script (see instructions in the link above) and removed ~/.bash-it folder.
Reinstalled bash-it.
Added to .bash_profile what was missing based on my .bash_profile backup created on step 1.
Reenabled the bash-it aliases, completions, and plugins that I needed.
As soon as I opened a new shell, I stopped receiving the error and rvm started working properly.
For anyone who runs into this issue, I was able to stop the error message from showing up by removing the following line of code from ~/.profile and ~/.bash_profile:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
This was added by updating rvm, which is still working after these lines being removed.
UPDATE: This stopped the error, but popped my ruby version backwards from 2.2 back to 2.0
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
Ever since installing RVM, my manpages are broken. Current versions of man don't use the MANPATH variable, so why is it being set to .rvm/man and why isn't there a full catalog of manpages inside that folder?
Apparently in the script ~/.rvm/scripts/initialize there is a little block that sets MANPATH and exports. Just comment this block out. Modern manpages compute path dynamically.
The offending lines are:
# if [[ -z "${MANPATH:-}" ]]
# then
# export MANPATH="${rvm_man_path}"
#
# elif ! [[ ":${MANPATH}:" =~ ":${rvm_man_path}:" ]]
# then
# export MANPATH="${MANPATH}:${rvm_man_path}"
# fi
This was fixed already as #Ashely noted in comment, proper way is to update RVM: rvm get head and to open new terminal / relogin depending on the installation type.
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
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?