# how to upgrade Ruby 1.8.7 to 1.9.2



## mzelensky (May 23, 2011)

Hello,

I've got an application running on Windows 7 / Ruby on Rails 3.0.4 (Ruby 1.9.2) and I need to move it to production server running on FreeBSD 8.2-RELEASE.

I installed Ruby on Rails 3.0.3 with *pkg_add -r rails* This also installed Ruby 1.8.7, which is not the version of Ruby I need. I need 1.9.2 and I am trying to upgrade to it but no luck.

I found some instructions of upgrading Ruby with RVM(Ruby version management tool), but I cannot install rvm either (I cloned it from github, but I don't understand how to use it after that)

Are there any solutions to installing Ruby on Rails with Ruby 1.9.2 or upgrading Ruby to 1.9.2?

Thanks in advance!


----------



## SirDice (May 23, 2011)

Build from ports. Build lang/ruby19 first, then the rest of what you need.


----------



## mzelensky (May 23, 2011)

I already did this, I tried both prior to and after Rails installation - no result. Both give the same:
`# ruby -v`

```
1.8.7
```


----------



## wblock@ (May 23, 2011)

If all of the ports that depend on Ruby 1.8 will actually work with Ruby 1.9 (not a safe assumption), I would be doing this:
`# portmaster -o lang/ruby19 lang/ruby18`

And then rebuild all of the ports that depend on Ruby:
`# portmaster -r ruby`
That will rebuild ruby19 again.  It might be possible to combine these two commands to avoid that, but I haven't experimented with it.


----------



## mzelensky (May 23, 2011)

wblock said:
			
		

> `# portmaster -o lang/ruby19 lang/ruby18`



I found a simple solution for the time being: 

1. installed Ruby 1.9.2
`# pkg_add -r ruby19`

2. renamed executable /usr/local/bin/ruby19 to /usr/local/bin/ruby
`# mv /usr/local/bin/ruby /usr/local/bin/ruby.bak`
`# mv /usr/local/bin/ruby19 /usr/local/bin/ruby`
`# ruby -v`


```
ruby 1.9.2p136 (2010-12-25 revision 30365) [i386-freebsd8]
```

It seems like everything works with that "patch".


----------



## wblock@ (May 23, 2011)

You're optimistic, but probably the worst that would happen is mysterious failures, and it won't be hard to figure out what to blame in that case.


----------



## UNIXgod (May 23, 2011)

I can help you with rvm. What is the issue/error you where having?


----------



## mzelensky (May 24, 2011)

UNIXgod said:
			
		

> I can help you with rvm. What is the issue/error you where having?



I simply cannot find installation instructions. Those on rvm site are obsolete and don't work (wrong URLs etc.)


----------



## mzelensky (May 24, 2011)

wblock said:
			
		

> You're optimistic, but probably the worst that would happen is mysterious failures, and it won't be hard to figure out what to blame in that case.



We'll see


----------



## UNIXgod (May 24, 2011)

mzelensky said:
			
		

> I simply cannot find installation instructions. Those on rvm site are obsolete and don't work (wrong URLs etc.)



I suggest you set up a FreeBSD jail. rvm is a great tool but since it's outside the ports system it won't trip portaudit when there is an issue.

rvm relies on these tools to be installed:


bash (>= 3.2)
    awk
    sed
    grep
    which
    ls
    cp
    tar
    curl
    gunzip
    bunzip2
    git w/ svn flag i.e. WITH_SVN=1

You can use which(1) to see if they are there.  If your using bash or zsh run the install one-liner and then you will need to put 

```
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
```
 inside your respective profile file.

Rehash and run `% rvm install 1.9.2-head`

For jruby you'll need java/jdk16

Let me know if this info was helpful.


----------



## vtypal (May 28, 2011)

Remove ruby 1.8 installation and all the 1.8-based rubygems packages from the ports (if any).


```
cd /usr/ports/lang/ruby18 && make deinstall
```

Remove the whole /usr/local/lib/ruby directory


```
rm -rf /usr/local/lib/ruby
```

Append 
	
	



```
RUBY_DEFAULT_VER=1.9
```
 in /etc/make.conf to hardlink: ruby1.9 -> ruby


```
echo "RUBY_DEFAULT_VER=1.9" >> /etc/make.conf
```

Install ruby19, reboot and you're done 


```
cd /usr/ports/lang/ruby19 && make install clean
```

All FreeBSD ports with ruby-1.8 dependencies will use ruby 1.9 installation files. Install your gems as root, using the *gem install* way (avoid rubygems from the ports as are outdated)


----------



## mzelensky (May 29, 2011)

Thanks, vtypal! That seems very reasonable, I will try this also and let you know shortly!


----------



## mzelensky (May 29, 2011)

Thanks, vtypal! This is a really simple and very useful solution. It worked!  Thank you!

`# ruby -v`

```
ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-freebsd8]
```


----------



## mzelensky (May 29, 2011)

OOOPS!
`# rails`

```
rails: Command not found.
```


----------



## UNIXgod (May 29, 2011)

mzelensky said:
			
		

> OOOPS!
> `# rails`
> 
> ```
> ...



some helpful tips to see where rails is

`% which rails`
`% gem list | cut -d" " -f1 | grep rails`

Removing the stale gems and reinstalling against your new version will/shouldâ„¢ fix your issue for rails 3.x on your new Ruby.

~


----------

