その他
    ホーム 技術発信 DoRuby rvmで外部ライブラリもインストール

    rvmで外部ライブラリもインストール

    この記事はアピリッツの技術ブログ「DoRuby」から移行した記事です。情報が古い可能性がありますのでご注意ください。

    OpenSSLをアップデートしたところ、地味に面倒な事になってしまいました。

    railsプロジェクトを新規作成しようとした矢先です。

    % rails test
    /Users/hachinen/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/i686-darwin10.3.0/digest/md5.bundle: dlopen(/Users/hachinen/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/i686-darwin10.3.0/digest/md5.bundle, 9): Library not loaded: /opt/local/lib/libcrypto.0.9.8.dylib (LoadError)
      Referenced from: /Users/hachinen/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/i686-darwin10.3.0/digest/md5.bundle
      Reason: image not found - /Users/hachinen/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/1.8/i686-darwin10.3.0/digest/md5.bundle
            from /Users/hachinen/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.6/lib/active_support/dependencies.rb:156:in `require'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.6/lib/active_support/dependencies.rb:521:in `new_constants_in'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.6/lib/active_support/dependencies.rb:156:in `require'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/rails-2.3.6/lib/rails_generator/generators/applications/app/app_generator.rb:3
            from /Users/hachinen/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
            from /Users/hachinen/.rvm/rubies/ruby-1.8.7-p249/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.6/lib/active_support/dependencies.rb:156:in `require'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.6/lib/active_support/dependencies.rb:521:in `new_constants_in'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/activesupport-2.3.6/lib/active_support/dependencies.rb:156:in `require'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/rails-2.3.6/lib/rails_generator/spec.rb:17:in `klass'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/rails-2.3.6/lib/rails_generator/lookup.rb:140:in `instance'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/rails-2.3.6/lib/rails_generator/scripts/../scripts.rb:31:in `run'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/gems/rails-2.3.6/bin/rails:19
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/bin/rails:19:in `load'
            from /Users/hachinen/.rvm/gems/ruby-1.8.7-p249/bin/rails:19
    

    なんかエラーになってしまいました。libsslがないとか言われているので最近何やったっけな…と思ったんですが、そういえばopensslを先日0.9から1.0にアップグレードしてみたのでした。

    なのでリンクしていた libcrypto.0.9.8.dylibがなくなってしまい、実行できない状態になってしまってました。

    仕方がないのでもう一度 rvm から1.8.7を再インストールしました。が、rvm的な解決方法は他にもある模様で、

    rvm update --head 
    rvm package install openssl
    

    とするとよいようです。1.9.1を試してみました。あとはrubyを以下のようにインストールします。

    rvm install 1.9.1 -C --with-openssl-dir=$HOME/.rvm/usr
    

    他、zlib,readline,iconv,ncursesなど、外部パッケージに依存しそうなものはrvm内でも管理できるようになっているようです。

    これならmacportsなどのパッケージ管理システムのアップグレードの度にrubyをコンパイルしなおさずに済みそうで、便利ですね。

    モバイルバージョンを終了