1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to upgrade Ruby 1.8.7 to 1.9.2

Discussion in 'Installation and Maintenance of Ports or Packages' started by mzelensky, May 23, 2011.

  1. mzelensky

    mzelensky New Member

    Messages:
    30
    Likes Received:
    0
    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!
     
  2. SirDice

    SirDice Moderator Staff Member Moderator

    Messages:
    17,392
    Likes Received:
    7
    Build from ports. Build lang/ruby19 first, then the rest of what you need.
     
  3. mzelensky

    mzelensky New Member

    Messages:
    30
    Likes Received:
    0
    I already did this, I tried both prior to and after Rails installation - no result. Both give the same:
    # ruby -v
    Code:
    1.8.7
     
  4. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,206
    Likes Received:
    15
    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.
     
  5. mzelensky

    mzelensky New Member

    Messages:
    30
    Likes Received:
    0
    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

    Code:
    ruby 1.9.2p136 (2010-12-25 revision 30365) [i386-freebsd8]
    It seems like everything works with that "patch".
     
  6. wblock@

    wblock@ Administrator Staff Member Administrator Moderator Developer

    Messages:
    11,206
    Likes Received:
    15
    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.
     
  7. UNIXgod

    UNIXgod New Member

    Messages:
    1,089
    Likes Received:
    0
    I can help you with rvm. What is the issue/error you where having?
     
  8. mzelensky

    mzelensky New Member

    Messages:
    30
    Likes Received:
    0
    I simply cannot find installation instructions. Those on rvm site are obsolete and don't work (wrong URLs etc.)
     
  9. mzelensky

    mzelensky New Member

    Messages:
    30
    Likes Received:
    0
    We'll see :)
     
  10. UNIXgod

    UNIXgod New Member

    Messages:
    1,089
    Likes Received:
    0
    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
    Code:
    [[ -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.
     
  11. vtypal

    vtypal New Member

    Messages:
    7
    Likes Received:
    0
    Remove ruby 1.8 installation and all the 1.8-based rubygems packages from the ports (if any).

    Code:
    cd /usr/ports/lang/ruby18 && make deinstall
    Remove the whole /usr/local/lib/ruby directory

    Code:
    rm -rf /usr/local/lib/ruby
    Append
    Code:
    RUBY_DEFAULT_VER=1.9
    in /etc/make.conf to hardlink: ruby1.9 -> ruby

    Code:
    echo "RUBY_DEFAULT_VER=1.9" >> /etc/make.conf
    Install ruby19, reboot and you're done ;)

    Code:
    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)
     
  12. mzelensky

    mzelensky New Member

    Messages:
    30
    Likes Received:
    0
    Thanks, vtypal! That seems very reasonable, I will try this also and let you know shortly!
     
  13. mzelensky

    mzelensky New Member

    Messages:
    30
    Likes Received:
    0
    Thanks, vtypal! This is a really simple and very useful solution. It worked! :) Thank you!

    # ruby -v
    Code:
    ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-freebsd8]
     
  14. mzelensky

    mzelensky New Member

    Messages:
    30
    Likes Received:
    0
    OOOPS!
    # rails
    Code:
    rails: Command not found.
    
     
  15. UNIXgod

    UNIXgod New Member

    Messages:
    1,089
    Likes Received:
    0
    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.

    ~