← Back to Upcase

Setting the ruby version using rbenv so bundle update sees it


(Dean Richardson) #1

I’m finally getting back to upgrading my app from Rails 2.3.8 to 3.1/3.2. After getting your post today about rbenv, I decided to install it, looking ahead to the need to upgrade my ruby version from 1.8.7 to 1.9.2 or 1.9.3. This in turn involved ripping out rvm, and then ripping out macports so I could install rbenv.

After (somewhat successfully) making those changes, I went to start my server and received an error message about the bundler version in my Gemfile, telling me I needed to change it from 1.0.22 to 1.3.5. After I’d done that, when I restarted the server, some sort of nokogiri error appeared, prompting me to uninstall and reinstall 1.5.9.

Somehow, though, in the process of switching from macports to homebrew, the various libraries nokogiri needs had gotten messed up. After consulting numerous blog posts and SO questions, I’m left with a “can’t find libxslt” error whenever I try to reinstall nokogiri 1.5.9. I’m unable to succesfully brew link libxml2 and libxslt, unfortunately.

Anyway, as a potential way around that, I thought of trying to install nokogiri 1.6.0, which apparently has libxml2 and libxslt already included. But when I set the nokogiri gem version in my Gemfile to 1.6.0 and try to bundle update --source nokogiri, I’m told I need ruby version 1.9.2. :smile:

Great, so now I can use rbenv to make that happen! I use rbenv install 1.9.2-p320, which seems to work fine. But when I go to bundle update --source nokogiri again, it doesn’t see the new ruby version. Typing ruby -v from the command line shows the old 1.8.7 version. rbenv version shows 1.9.2-p320, but nothing else seems to.

Sorry, ridiculously long preamble, but basically I’m struggling to get rbenv to set my ruby version in such a way that the bundle command sees it. And I’m also struggling with getting nokogiri to install. Any and all help would be greatly appreciated. Thanks!


(Lenart Rudel) #2

Have you set the default/local ruby version? You can make the 1.9.2 global by running rbenv global 1.9.2-p320 or local if you only want to use it within a project. In your project folder run rbenv local 1.9.2-p320 and rbenv will use specified version.

Also make sure you’ve updated your ~/.bashrc or .zshrc (depending on the shell you’re using).

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

(Dean Richardson) #3

Your suggested changes to my ~/.bashrc file helped. Now ruby -v displays the right version.

Bundler unfortunately is still having problems. I successfully ran

gem install nokogiri -v 1.6.0

but when I run

bundle update nokogiri

I get

Installing nokogiri (1.6.0)
Gem::InstallError: nokogiri requires Ruby version >= 1.9.2.
An error occurred while installing nokogiri (1.6.0), and Bundler cannot
continue.
Make sure that gem install nokogiri -v '1.6.0' succeeds before bundling.

This is troubling, since I did succeed in installing nokogiri previously.

When I run nokogiri --version, I get:

hikari-2:genlighten dean$ nokogiri --version
# Nokogiri (1.6.0)
    ---
    warnings: []
    nokogiri: 1.6.0
    ruby:
      version: 1.9.2
      platform: x86_64-darwin10.8.0
      description: ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin10.8.0]
      engine: ruby
    libxml:
      binding: extension
      source: packaged
      libxml2_path: /Users/dean/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/ports/i686-apple-darwin10/libxml2/2.8.0
      libxslt_path: /Users/dean/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/nokogiri-1.6.0/ports/i686-apple-darwin10/libxslt/1.1.26
      compiled: 2.8.0
      loaded: 2.8.0

Here I worry about the mention of “ports” in the path for these dependent libraries, since that sounds like I wasn’t able to completely clean macports off my system before I installed homebrew.

So bottom line, I’m still not able to get the server to run because I apparently haven’t been completely successful in upgrading nokogiri or compiling it against the right libraries. I read on an SO thread something about trying:

bundle config build.nokogiri

with parameters that specify the location of the libraries, mentioned above, but I’m afraid to try that until I know what’s up with the “port” subdirectories.

Any advice for my smartest next steps?

Thanks,

Dean