Mac snow leopard: ruby version kept coming back to 1.8.7 - ruby

I installed ruby 1.9.2 and checked with ruby -v and it was fine (1.9.2) but after I restarted my computer after terminal somehow stopped responding, ruby switched back to 1.8.7. This has happened before and I ended up re-intalling.
Do you know what might have happened?
Thank you so much!
Cheers,
eFan

Try:
$ which ruby
And:
$ echo $PATH
I bet you installed ruby in /usr/local/ruby/bin/ruby but are running the one in /usr/bin/ruby.

Presumably you edited your PATH variable in that one Terminal session, but not for all future sessions. Assuming that you have a symlink from /usr/local/bin/ruby to the correct install, you need to modify your PATH to look in /usr/local/bin before /usr/bin.
Create or edit a file named .profile in your home directory with this line in it:
export PATH="/usr/local/bin:$PATH"

$ curl -L http://get.rvm.io | bash
$ rvm install 1.9.2
$ rvm use 1.9.2 --default

Related

I upgraded Ruby to version 2.5.0 and when i run ruby -v it still shows an older version

I upgraded ruby from 2.2.3 using rbenv following these instructions
$ brew update
$ brew install ruby-build
$ brew install rbenv
$ rbenv install 2.5.0
$ rbenv global 2.5.0
$ rbenv local 2.5.0
i restarted my terminal and my computer but when i run
ruby -v
it shows that i have
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
when i run rbenv version
system
2.4.0
2.5.0 (set by /Users/****/.ruby-version)
it doesn't even show this version, i'm stuck on what i have to do to change this to point to the correct version.
When i run
$echo $PATH
it shows
-bash: /usr/local/opt/imagemagick#6/bin:/Users/****/.rvm/gems/ruby-2.2.3/bin:/Users/****/.rvm/gems/ruby-2.2.3#global/bin:/Users/****/.rvm/rubies/ruby-2.2.3/bin:/Users/****/anaconda/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/****/.rvm/bin: No such file or directory
From your path, it looks like you are using rvm. I think rvm and rbenv should not be both active on the same system. If you are going to use rbenv I suggest you disable rvm. You don't need to delete the .rvm directory containing rvm's rubies, gems, etc., you just need to stop the rvm shell code from being loaded when the terminal window starts up. To do this, disable or remove the rvm-related code in your .bashrc, .profile, .bash_profile, .zshrc, etc., and use a new terminal window that starts up after that removal.
I suspect the 2.2.3 version of Ruby is the system you see in the list. If you do a which ruby, you can see where it's located, and that will be a clue; if it's /usr/bin/ruby, then it's the system Ruby.
As an aside, you can get a list of directories in the PATH one to a line by using this command:
echo $PATH | tr : \\n
This would be much easier to follow than the long line containing all the directories.

Ruby Version Inconsistent [duplicate]

I installed rbenv according to the github directions. I am running OSX but I have tried this on a Ubuntu 12.04 VM and got the same results. The following is what i get in my terminal when I try to change ruby versions:
rbenv versions
* 1.9.3-p0 (set by /Users/user/.rbenv/version)
1.9.3-p125
rbenv global
1.9.3-p0
rbenv rehash
ruby -v
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]
which ruby
/usr/bin/ruby
Anyone have any ideas as to why rbenv isn't switching the ruby version like it thinks it is? Also there is no .rbenv file in the local directory that would be causing the ruby version to default to 1.8.7
rbenv local
rbenv: no local version configured for this directory
Check that PATH contains $HOME/.rbenv/shims and $HOME/.rbenv/bin
$ env | grep PATH
Also check that you have the following in your ~/.bash_profile if using bash or ~/.zshenv if using zsh
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
NOTE:
Make sure it's the last setting in your ~/.bash_profile . I ran into an issue where I installed a program that updated my .bash_profile and reset PATH.
Finally, make sure your $HOME folder doesn't have a .ruby-version file that you may have created by accident if you were to have done $ rbenv local <ruby-version> in your $HOME folder. Doing $ rbenv global <ruby-version> modifies the $HOME/.rbenv/version file, and the existence of a .ruby-version file in the $HOME folder would override the version set by $HOME/.rbenv/version.
From the docs:
Choosing the Ruby Version
When you execute a shim, rbenv determines which Ruby version to use by reading it from the following sources, in this order:
The RBENV_VERSION environment variable, if specified. You can use the rbenv shell command to set this environment variable in your current shell session.
The first .ruby-version file found by searching the directory of the script you are executing and each of its parent directories until reaching the root of your filesystem.
The first .ruby-version file found by searching the current working directory and each of its parent directories until reaching the root of your filesystem. You can modify the .ruby-version file in the current working directory with the rbenv local command.
The global ~/.rbenv/version file. You can modify this file using the rbenv global command. If the global version file is not present, rbenv assumes you want to use the "system" Ruby—i.e. whatever version would be run if rbenv weren't in your path.
I fixed this by adding the following to my ~/.bash_profile:
#PATH for rbenv
export PATH="$HOME/.rbenv/shims:$PATH"
This is what is documented at https://github.com/sstephenson/rbenv.
From what I can tell there isn't ~/.rbenv/bin directory, which was mentioned in the post by #rodowi.
This may be an old question, but Google led me here and, for posterity sake, thought I'd share.
My problem persisted after many of the recommended solutions above. Like the OP, I installed rbenv and then a ruby version, but my laptop defaulted to system. What I had overlooked was that when I ran:
[~/.rbenv] $ rbenv versions
* system (set by /Users/alphadogg/.rbenv/version)
2.0.0-p247
IOW, it was still defaulting to system. A quick
[~/.rbenv] $ rbenv local 2.0.0-p247
switched it to the new version.
First step is to find out which ruby is being called:
$ which ruby
Your system says:
/usr/bin/ruby
This is NOT the shim used by rbenv, which (on MacOS) should look like:
/Users/<username>/.rbenv/shims/ruby
The shim is actually a script that acts like a redirect to the version of ruby you set.
I recommend that for trouble shooting you unset the project specific "local" version, and the shell specific "shell" version and just test using the "global" version setting which is determined in a plain text file in ~/.rbenv/version which will just be the version number "1.9.3" in your case.
$ rbenv global 1.9.3
$ rbenv local --unset
$ rbenv shell --unset
You can do ls -laG in the root of your project folder (not the home folder) to make sure there is no longer a ".ruby-version" file there.
You can use rbenv versions to identify which version rbenv is set to use (and the location and name of the file that is setting that):
$ rbenv versions
NONE OF THAT MATTERS until you set the path correctly.
Use this to make sure your *MacOS will obey you:
$ rbenv init -
Followed by:
$ which ruby
To make sure it looks like:
/Users/<username>/.rbenv/shims/ruby
Then run this to add the line to your profile so it runs each time you open a new terminal window:
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
There are other ways to modify the path, feel free to substitute any of them instead of running the rbenv init.
NOTE: reinstall Rails with:
$ gem install rails
If you were trying to run Ruby on Rails, then you need to have this all working first, then install the rails gem again. A previous install of Rails will use a hard coded path to the wrong ruby and several other things will be in the wrong place, so just install the gem again.
P. S. If your MacOS won't obey you (*mentioned above) then you may have to find another way to modify your path, but that's unlikely to be a problem because "Macs just work" ;)
I had this issue when setting up Ruby using rbenv on MacBook Pro Catalina OS and MacBook Pro Big Sur.
Here's how I fixed:
First run the command below to initialize rbenv:
rbenv init
This will give you some instruction on what to do. Basically you will have to open the ~/.zshrc file and add this to the file eval "$(rbenv init -)". You can accomplish this by running the command below:
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
Next, run the command below to set your Ruby version:
rbenv local <your-desired-ruby-version>
In my case, my desired Ruby version was 3.0.1, so it was:
rbenv local 3.0.1
When you are done, quit your terminal using Command + Q, and then open a new terminal, this time when you run the command:
ruby -v
rbenv versions
You will see that your desired Ruby version has already been set up for you.
In my case changing the ~/.zshenv did not work. I had to make the changes inside ~/.zshrc.
I just added:
# Include rbenv for ZSH
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
at the top of ~/.zshrc, restarted the shell and logged out.
Check if it worked:
➜ ~ rbenv install 2.4.0
➜ ~ rbenv global 2.4.0
➜ ~ rbenv global
2.4.0
➜ ~ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
I just found this same problem. What I did was uninstall rbenv (via homebrew) and reinstall it. I also added
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
into ~/.bash_profile when I reinstalled rbenv. Works perfectly now.
Run this command
Add rbenv to bash so that it loads every time you open a terminal
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
source ~/.bash_profile
this will solve your problem Reference
If you are using bash, go to
~/.bash_profile
and add the following line (if it's not already there)
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
If you are using Zsh, go to
~/.zshrc
and add the same line of code, at the end of the .zshrc file.
Then simply restart your terminal and it should be fine now.
rbenv help shell
"Sets a shell-specific Ruby version by setting the 'RBENV_VERSION' environment variable in your shell. This version overrides localapplication-specific versions and the global version. should be a string matching a Ruby version known to rbenv.The special version string 'system' will use your default system Ruby. Run rbenv versions' for a list of available Ruby versions."
Provided rbenv was installed correctly, ruby -v will correspond to
rbenv shell 1.9.3-p125
I had the same problem, but caused by Homebrew:
[~]$ rbenv version
2.3.0 (set by /Users/user/.rbenv/version)
[~]$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
[~]$ which ruby
/usr/local/bin/ruby
Somehow I had installed Ruby via Homebrew too, and the Homebrew path was ahead of the rbenv path in my $PATH. Running brew uninstall ruby fixed it for me.
run:
rbenv init
After I ran that, when i set my local rbenv version:
rbenv local 2.4.0
then my ruby -v and my rbenv local versions coincided.
Note: You might also want to exit the directory you're in and then go back into it, i've noticed that was necessary for me in order to get things to work.
for fish shell user
set --universal fish_user_paths $fish_user_paths ~/.rbenv/shims/
As for me the easiest way to use rbenv along with zsh is adding rbenv to plugins section in .zshrc config. In my case it looks similar to:
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git bower rails ruby rbenv gulp npm node nvm sublime)
After that there're no problems when installing, switching, using ruby versions with help of rbenv.
Mind to restart your terminal session after made changes.
The accepted answer suggests to add the following:
export PATH="$HOME/.rbenv/bin:$PATH"
This will not work on Mac OSX, which the OP references. In fact, if you install rbenv via brew install rbenv, which is really the only installation method in Mac OSX, since curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer | bash will FAIL in OSX, then the rbenv executable will be installed in:
$ which rbenv
/usr/local/bin/rbenv
However, even in OSX, the rbenv root will remain in the $HOME directory:
~ viggy$ rbenv root
/Users/viggy/.rbenv
What does this mean? It means when you install rubies, they will install in the given home directory under .rbenv:
$ rbenv install 2.6.0
$ ls ~/.rbenv/versions
2.6.0
Now the brew installation did some work that you would have to perform manually in Linux. For example, in Linux, you would have to install ruby-build manually as a plugin:
$ mkdir -p "$(rvbenv root)/plugins"
$ git clone https://github.com/rbenv/ruby-build.git "(rbenv root)"/plugins/ruby-build
This is already done with the homebrew installation. There is one important step that must be done in the homebrew installation, as in the Linux installation. You must add the rbenv shims to your path. In order to do that, when your shell starts, you have to evaluate the following command (which will in turn add the rbenv shims to the beginning of your $PATH):
$ vim ~/.bash_profile
eval "$(rbenv init -)"
$ source ~/.bash_profile
Now when you run echo $PATH, you will see the rbenv shims:
$ echo $PATH
/Users/viggy/.rbenv/shims:
Now check your ruby version and it will reflect the rbenv ruby installed:
ruby -v
ruby 2.6.0p0
When I had these symptoms, the problem turned out to be that install had failed halfway through for the new Ruby version I was trying to switch to, without me noticing. The fix was to delete & reinstall it.
(This meant that even though ruby 1.9.3 showed up in the rbenv list of available versions, it didn't have an executable on the path where rbenv assumed it would. Since rbenv tries to change your ruby version just by prepending a location to your path, if there's nothing actually in the location it prepends, your OS will happily continue searching your default path and find your system version, in my case like the question's 1.8.7.)
Make sure the last line of your .bash_profile is:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
I came to the same problem.
Fixed this by run the rbenv global command with sudo.
I think it was something permission problem.
update:
I finally found the solution.
There was one same file "version" on my mac, which is under /usr/local/Cellar/rbenv/0.3.0/.
I think it was created by mistake occasionally. you should remove it.
Adding the following to .bashrc works for me -
export PATH="$HOME/.rbenv/shims:$PATH"
This happened to me right after I reinstalled rbenv. Apparently I had a .ruby-version file in my home directory, specifying a version that no longer existed. Once I deleted the file, everything worked.
Update 2023 (Macbook Ventura+)
Even if you have rbenv installed, your computer could still serve the default ruby version. To fix this, just run the following:
rbenv init
This might give an output like this:
# Load rbenv automatically by appending
# the following to ~/.zshrc:
eval "$(rbenv init - zsh)"
Just open your .zshrc file:
sudo nano ~/.zshrc
(Or you can also open this file with any other text editor)
Add this line:
eval "$(rbenv init - zsh)"
Save the file (if used sudo nano, you can do so like this:)
CTRL + X then Y then Enter (For Mac)
Now, refresh your .zshrc profile like this:
source ~/.zshrc
Now type ruby --version, this must give you the ruby version that was provided by rbenv.
There a lot of of misleading answers that work. I thought it was worth mentioning the steps from the rbenv README.
$ brew install rbenv
$ rbenv init and follow the instructions it gives you. This is what I got:
~ $ rbenv init
# Load rbenv automatically by appending
# the following to ~/.bash_profile:
eval "$(rbenv init -)"
I updated my ~/.bash_profile...
Close terminal and open it again
Verify it's working correctly by running:
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Now just install the version you want by doing: rbenv install <version>
Linux / Ubuntu Users
Step 1:
$ rbenv versions
system
2.6.0
* 2.7.0 (set by /home/User/Documents/sample-app/.ruby-version) #Yours will be different
2.7.2
Step 2:
$ nano /home/User/Documents/sample-app/.ruby-version
Step 3:
$ ruby -v
ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]
I tried every solution, but nothing worked for me. Even I was including the path in the .zshrc file.
In my case, I'm using MacBook Pro M2 with macOS Ventura 13.2. And I'm using React Native 0.71.2, which needed Ruby 2.7.6 version.
I simply placed the following code in the .zprofile instead of .zshrc, and it worked:
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init - zsh)"
You could try using chruby? chruby does not rely on shims, instead it only modifies PATH, GEM_HOME, GEM_PATH.
I forgot to delete rvm before installing rbenv. I deleted rvm and re-installed rbenv, but system still wasn't using the version of Ruby being designated as global by rbenv. I tried shutting Terminal, but it only worked once I restarted the whole machine.
All the other answers here give good advice for various situations, but there is an easier way.
The rbenv docs point us to the rbenv-doctor diagnostic tool that will quickly verify all these potential pitfalls on your system:
curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
When all is well, you'll see this:
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash <aws:hd-pmp-developer>
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
Checking `rbenv install' support: /usr/local/bin/rbenv-install (ruby-build 20201005)
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
Now, if we break one of those expectations (e.g. remove rbenv-install), the tool will point us directly to the problem, with a link to how to fix it:
$ mv /usr/local/bin/rbenv-install rbenv-install-GONE
$ curl -fsSL https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-doctor | bash
Checking for `rbenv' in PATH: /usr/local/bin/rbenv
Checking for rbenv shims in PATH: OK
===> Checking `rbenv install' support: not found <===
Unless you plan to add Ruby versions manually, you should install ruby-build.
Please refer to https://github.com/rbenv/ruby-build#installation
Counting installed Ruby versions: 1 versions
Checking RubyGems settings: OK
Auditing installed plugins: OK
Strangely, rbenv version did not set the .rbenv file.
Check with: ls -ltra --> to see that a rbenv was written.
Adding eval "$(rbenv init -)" to the .bash_profile on my mac resolved this issue.
rbenv local
ruby -v gave the set
Apparently, it worked for me when I used the Rosetta terminal
You can try doing the same thing using Rosetta terminal
by going into
Finder > Utilities > Terminal > Get Info

How can I switch to ruby 1.9.3 installed using Homebrew?

I have installed ruby 1.9.3 using hombrew
brew install ruby
But default 1.8.7 is still used. How can I switch osx to use 1.9.3 as default ruby?
I suggest you take a look at rvm.
You can then set it as default with rvm use 1.9.3 --default
But if you are happy with your homebrew install.
Then just change the precedence of directories in the PATH
Here is my /etc/paths
# homebrews should always take precedence
/usr/local/bin
# the default stack
/usr/bin
/bin
/usr/sbin
/sbin
This is important generally for homebrew, else the system version of git, ruby, pg_admin,... will all be used instead of the brew version.
if you say which -a ruby you'll see all the installed rubies, and the precedence in the PATH
eg.
$ which -a ruby
/Users/matthew/.rvm/rubies/ruby-1.9.3-p0/bin/ruby
/Users/matthew/.rvm/bin/ruby
/usr/bin/ruby
UPDATE: I now don't think you should change /etc/paths
Instead you need to check which of .profile, .bashrc, or .bash_login is being loaded in your shell, and just add /usr/local/bin to your path.
For me, I only have a .profile. You can create that file if none of those files already exist in your home directory.
# homebrews should always take precedence
export PATH=/usr/local/bin:$PATH
SHORT ANSWER:
after installing ruby via homebrew just do this:
brew link --overwrite ruby
and restart or reopen your Terminal
LONG ANSWER
So I did a normal install of ruby using homebrew
brew install ruby
that installed fine BUT it was still using the system's default ruby.
which I verified by doing:
which ruby
#/usr/bin/ruby
So as per Matthew Rudy's suggestion, I checked the order of my /etc/paths, and all was good.
Then I decided to do:
which -a ruby
#/usr/bin/ruby
#usr/local/bin/ruby
so nothing was broken as such.
tried to reinstall ruby again using the homebrew method, and then i found it.
Homebrew mentioned:
Warning: ruby-2.3.1 already installed, it's just not linked
so had to do:
brew link --overwrite ruby
If you'd like to use homebrew to install 1.9.3, you can follow these steps:
$ brew update
$ brew install rbenv
$ brew install ruby-build
Once you have rbenv and ruby-build installed, you can run the following command to get Ruby 1.9.3 installed.
$ rbenv install 1.9.3-p125
Now if you’d like to use 1.9.3 by default, you can run the following command:
$ rbenv global 1.9.3-p125
I had similar situation. I installed ruby using Homebrew. which -a ruby gave me the following output:
#usr/local/bin/ruby
#/usr/bin/ruby
Which means that newly installed version should have been used, but ruby --version still returned the old system version.
I quit terminal (Cmd+Q), and after restart ruby --version returned the correct version. So make sure you restart terminal after installing before trying any other (potentially unnecessary) fixes.
Ruby was installed by Homebrew at /usr/local/opt/ruby. So, we need to add this path to bash or Zsh.
# Type this to find out which shell you're using (e.g., bash, Zsh)
echo $SHELL
# If you're using Bash (e.g., echo $SHELL returns /bin/bash)
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
# If you're using Zsh
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
Then, source the file
# E.g., if you're using bash
source ~/.bash_profile
Finally, verify ruby's version
ruby -v
SHORT:
Do note what you want to change it for.
If you're on OS X and trying to use Ruby for something like Jekyll, then don't use homebrew because that's what Apple is using for Ruby for and it might not be good to use if you're not sure what you're doing. Instead, use rbenv or RVM.
LESS SHORT:
I was trying to switch from the default version to an updated version (from 2.0) to use Jekyll because it required Ruby version 2.2.5 and above. I updated it and version 2.5 was installed, but when I checked "ruby -v", it was still 2.0. Once I finally got around to changing the default version, I wasn't able to install the package I needed because I didn't have write permission. For example, if you come across something like this, then you probably are having the same problem
$ gem install jekyll bundler
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.0.0 directory.
In OSX you can change the path using:
sudo nano /etc/paths
And then add a path or change the order.
After seeing Craig Wayne's answer I thought maybe I had missed a warning when installing ruby with Homebrew. So I reinstalled it with brew reinstall ruby#2.7 and there it was:
==> Caveats
By default, binaries installed by gem will be placed into:
/usr/local/lib/ruby/gems/2.7.0/bin
You may want to add this to your PATH.
ruby#2.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have ruby#2.7 first in your PATH, run:
echo 'export PATH="/usr/local/opt/ruby#2.7/bin:$PATH"' >> ~/.zshrc
For compilers to find ruby#2.7 you may need to set:
export LDFLAGS="-L/usr/local/opt/ruby#2.7/lib"
export CPPFLAGS="-I/usr/local/opt/ruby#2.7/include"
For pkg-config to find ruby#2.7 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/ruby#2.7/lib/pkgconfig"
So the solution for me was adding /usr/local/opt/ruby#2.7/bin: to the beginning of PATH in ~/.zshrc.
Just as an alternative approach for anyone else looking for an answer to this - you can set an alias in your .bash_profile e.g
ruby="/usr/local/bin/ruby"
this is how i got around the issue

Updating to Ruby 1.9.2 on Leopard 10.5.8 using RVM

There seems to be a lot documented on migrating to 1.9.2 via snow leopard but not a lot on Leopard specifically.
running Mac OS X Leopard 10.5.8
rvm 1.6.3
xcode 3.1.4
I had a hard time installing rvm to begin with- but used this fix and got rvm installed. I type:
$ rvmsudo rvm install ruby-1.9.2-head
Install of ruby-1.9.2-head - #complete
(I get a failure if I try install without a sudo command) To switch default versions:
$ rvmsudo rvm --default use ruby-1.9.2-head
Using /usr/local/rvm/gems/ruby-1.9.2-head
$ ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin9]
When I set it as the default without a sudo command.
rvm --default use ruby-1.9.2-head
I get an error log that ends with:
cp: /usr/local/rvm/bin/rdoc: Permission denied
cp: /usr/local/rvm/bin/ri: Permission denied
cp: /usr/local/rvm/bin/ruby: Permission denied
cp: /usr/local/rvm/bin/testrb: Permission denied
Then I type
$ ruby -v
ruby 1.9.2p188 (2011-03-28 revision 31204) [i386-darwin9.8.0]
But when I close out terminal and reopen it is back to 1.8.7
Any ideas on how to get this ruby install to stick as my default?
Here is my bash profile
PS1="\u$ "
alias ll="ls -lahG"
export PATH="/usr/local/rvm/rubies/ruby-1.9.2-head/bin:/usr/local/bin:/usr/loca$
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loa$
##
# Your previous /Users/mikalfm/.bash_profile file was backed up as /Users/mikal$
##
# MacPorts Installer addition on 2011-04-23_at_21:38:56: adding an appropriate $
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.
# MacPorts Installer addition on 2011-04-23_at_21:38:56: adding an appropriate $
export MANPATH=/opt/local/share/man:$MANPATH
# Finished adapting your MANPATH environment variable for use with MacPorts.
UPDATE
Solved.
I went to the file location from 'which ruby' (the 1.8.7 version)
Backed up the file and deleted it.
Now ruby -v returns
ruby 1.9.2p188 (2011-03-28 revision 31204) [i386-darwin9.8.0]
See comment below about why this was a bad idea.
Update 2
Solved, Really Unless of course I did something dumb.
So after following the instructions from the thread- I cleared up all of the Sudo issues in the original question. I did it by uninstalling RVM using an implode command, removing the folder and reinstalling without using any sudo commands.
The following problem was I could force rvm to use 1.9.2 as a default for only one session at a time. I just fixed this by reading this stackthread force rails to use 1.9.2 in it someone proposed using the $ echo $PATH command. I did it and it looked fundamentally different than what I thought was in my bash profile.
It looked like
/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/Users/mikalfm/.rvm/gems/ruby-1.9.2-p180/bin:/Users/mikalfm/.rvm/gems/ruby-1.9.2-p180#global/bin:/Users/mikalfm/.rvm/rubies/ruby-1.9.2-p180/bin:/Users/mikalfm/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin
Turns out, I thought a few lines in my .bash_profile were commented out by ## and weren't.
export PATH=/opt/local/bin:/opt/local/sbin:$PATH and export MANPATH=/opt/local/share/man:$MANPATH. They directly contradict what I thought was my $PATH export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
I deleted those lines from my profile. I figure I can add them back in if and when there is a dependency and I need to use Mac Ports again. Again, some one let me know if this is the wrong approach, but it works for me now even when I start a new terminal.
Solved. I went to the file location from 'which ruby' (the 1.8.7 version) Backed up the file and deleted it. Now ruby -v returns ruby 1.9.2p188 (2011-03-28 revision 31204) [i386-darwin9.8.0]
NO NO NO!
The version of Ruby installed by Mac OS in /usr is owned by Apple and installed for their use. Applications installed by Apple use it, and you could have broken them.
If you run find /usr -name '*.rb' you'll find a number of files used by Apple, that are not part of the normal Ruby install.
It's not a problem of 10.5, I use it on my MB pro too. You need to learn to stop using sudo, when you do your not in scope of 'Mikal' anymore. I seldom have to use that anymore.
I'm not too familiar with rvmsudo. What happens when you do
rvm list
rvmsudo rvm list
?
My advice, uninstall rvm installed as root (with sudo), re-try and follow the guide at rvm.beginrescued.com
remove the PATH ruby1.9.2/bin from .bash_profile to avoid confusion. Let rvm handle it, and stay off sudo and rvmsudo (I've never used the latter).
rvm install 1.9.2
rvm use 1.9.2 --default
rvm list #see your rubies
should be sufficient. Hope it helps.
maybe you should just add:
rvm use 1.9.2
to your .bash_profile file :)

RVM doesn't switch Rubies

I'm running Ruby 1.9.1p243 on CentOS, and I decided to install rvm to handle upgrading to 1.9.2 or downgrading to 1.8.7 (whichever turns out to work better for rails3).
I followed the instructions here: http://rvm.beginrescueend.com/rvm/install/ and everything installed correctly. I was able to compile and install Ruby 1.8.7, 1.9.1, and 1.9.2.
However, if I try to actually switch to one of the rvm installed Rubies, with rvm use 1.8.7, for example, nothing works. My system still uses the Ruby I have installed in /usr/local/bin/ruby.
An example of the output I get:
$ rvm use 1.8.7
$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
$ which ruby
/usr/local/bin/ruby
$ rvm use 1.9.2
$ ruby -v
ruby 1.9.1p243 (2009-07-16 revision 24175) [i686-linux]
$ which ruby
/usr/local/bin/ruby
I have no idea why this is happening, and I can't seem to find anything online about the issue either. Any help would be appreciated.
Just came across the same problem.
Instead of appending the following script to ~/.bash_profile, append it to ~/.bashrc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
And then restart the terminal.
Typically rvm support is easiest via IRC (#rvm on freenode) - in this particular case, what does running "type rvm | head -n1" show? it should show "rvm is a function". If not, that means the line to source rvm isn't being run correctly and hence switching doesn't work. Typically this means you either have a return in your ~/.bashrc or you missed adding the line to source rvm.
Your install it as root account.
Try this in shell:
[[ -s "/usr/local/rvm/scripts/rvm" ]] && . "/usr/local/rvm/scripts/rvm"
before rvm switch operation. I add this line in my profile file and now all is ok.
Can be a problem of Terminal and
you should try to close your Terminal's window
and to open new one. :)
Try again to see if it has changed...
I've been struggling with setting default rvm ruby to no avail, until I've tried this:
sudo bash -l -c 'rvm alias create default ruby-1.9.3-p392'
"sudo" is for writing into /usr/local/rvm/config/alias (in my example it would contain "default=ruby-1.9.3-p392")
"bash -l" is to make sure it runs all the scripts (/etc/profile, /etc/bash.bashrc, etc..) of login shell

Resources