Search code examples
ruby-on-railsrubyrbenvmysql2

How can I solve "incompatible library version" problem with ruby 2.7.4 on ubuntu 20.04?


Hello it's my first question here. I'm trying to build a redmine system on my server but facing some problems.

my system - ubuntu20.04 + nginx1.18 + mariadb10.3.30 + ruby2.7.4 + redmine4.2.2 / use rbenv to install ruby

when I'm trying to connect the redmine server, I got this error

App 716658 output: Error: The application encountered the following error: libruby.so.2.7: cannot open shared object file: No such file or directory - /opt/redmine/vendor/cache/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so (LoadError)

so I did cd /usr/lib

ln -s /root/.rbenv/versions/2.7.4/lib/libruby.so.2.7 libruby.so.2.7

then incompatible library version error occurred

App 722799 output: Error: The application encountered the following error: incompatible library version - /opt/redmine/vendor/cache/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.so (LoadError)

I tried gem pristine --all but not worked.

How can I solve this problem? so many errors occurred so I guess there is a problem on my setting.

gem env

 - RUBYGEMS VERSION: 3.2.25
 - RUBY VERSION: 2.7.4 (2021-07-07 patchlevel 191) [x86_64-linux]
 - INSTALLATION DIRECTORY: /root/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0
 - USER INSTALLATION DIRECTORY: /root/.gem/ruby/2.7.0
 - RUBY EXECUTABLE: /root/.rbenv/versions/2.7.4/bin/ruby
 - GIT EXECUTABLE: /usr/bin/git
 - EXECUTABLE DIRECTORY: /root/.rbenv/versions/2.7.4/bin
 - SPEC CACHE DIRECTORY: /root/.gem/specs
 - SYSTEM CONFIGURATION DIRECTORY: /root/.rbenv/versions/2.7.4/etc
 - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
 - GEM PATHS:
    - /root/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0
    - /root/.gem/ruby/2.7.0
 - GEM CONFIGURATION:
    - :update_sources => true
    - :verbose => true
    - :backtrace => false
    - :bulk_threshold => 1000
 - REMOTE SOURCES:
    - https://rubygems.org/
 - SHELL PATH:
    - /root/.rbenv/versions/2.7.4/bin
    - /root/.rbenv/libexec
    - /root/.rbenv/plugins/ruby-build/bin
    - /root/.rbenv/shims
    - /root/.rbenv/bin
    - /usr/local/sbin
    - /usr/local/bin
    - /usr/sbin
    - /usr/bin
    - /sbin
    - /bin
    - /usr/games
    - /usr/local/games
    - /snap/bin

bundle env

Bundler       2.2.25
  Platforms   ruby, x86_64-linux
Ruby          2.7.4p191 (2021-07-07 revision a21a3b7d23704a01d34bd79d09dc37897e00922a) [x86_64-linux]
  Full Path   /root/.rbenv/versions/2.7.4/bin/ruby
  Config Dir  /root/.rbenv/versions/2.7.4/etc
RubyGems      3.2.25
  Gem Home    /root/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0
  Gem Path    /root/.gem/ruby/2.7.0:/root/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0
  User Home   /root
  User Path   /root/.gem/ruby/2.7.0
  Bin Dir     /root/.rbenv/versions/2.7.4/bin
Tools         
  Git         2.25.1
  RVM         not installed
  rbenv       rbenv 1.1.2-61-g585ed84
  chruby      not installed

Bundler Build Metadata

Built At          2021-07-30
Git SHA           7f0f257c7a
Released Version  true

Solution

  • It seems that you have configured bundler (a gem version manager for Ruby projects) to install the gems for Redmine in a different location from the usual system gems, namely to /opt/redmine/vendor/cache.

    As such, the usual gem commands will not touch those bundler-installed gems since gem does not know about them. To re-install all bundler managed gems, you can instead run the following command within your Redmine directory (i/e/ the directory containing the Gemfile:

    bundle pristine
    

    This is effectively the same as gem pristine --all but just for the bundler-managed gems. See the documentation for details.