Search code examples
ruby-on-railsredminemysql2

Secret generation in redmine installation fails with error in mysql2/mysql2


I am trying to install redmine 2.3.x on my Debian vServer. I already managed to build ruby from source and installed gems, rails and the apache passenger module. It should work until that point. I used the turotial at domainfactory: http://www.df.eu/de/service/df-faq/cloudserver/anleitungen/ruby-on-rails-installieren-debian-ubuntu/ .

After that I downloaded and extracted the redmine application as described here: http://www.redmine.org/projects/redmine/wiki/RedmineInstall#Installation-procedure. I created a mysql account and database, made a copy of the config/database.yml.example -> config/database.yml and filled in the correct values.

After that I installed bundler with

gem install bundler

And did go on with preparing the environment:

bundle install --without development test

All these commands did succeed.

After that I wanted to generate the secret token with the fallowing command:

rake generate_secret_token

The execution was interrupted with the fallowing message:

 # rake generate_secret_token --trace
rake aborted!
cannot load such file -- mysql2/mysql2
/usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `require'
/usr/local/lib/ruby/gems/2.0.0/gems/mysql2-0.3.13/lib/mysql2.rb:8:in `<top (required)>'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `require'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:72:in `block (2 levels) in require'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `each'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:70:in `block in require'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `each'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:59:in `require'
/usr/local/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:132:in `require'
/var/www/potato/config/application.rb:7:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/custom_require.rb:36:in `require'
/var/www/potato/Rakefile:5:in `<top (required)>'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:637:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:94:in `block in load_rakefile'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:93:in `load_rakefile'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:77:in `block in run'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/usr/local/lib/ruby/gems/2.0.0/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<main>'

I was trying to resolve this by checking versions and installed gems.

Ruby: ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]
Rails: Rails 3.2.13
Gems: 1.8.25
Redmine: 2.3.3

I verified with gem list --local that the gem "mysql2" is installed.

gem "mysql": mysql2 (0.3.13)

As the problem seems to rely on this, I tried reinstalling the package, but this did not help.

What did I wrong here?

Thanks in advance, Sebastian Büttner


Solution

  • I found this error happens if you don't have the following package installed in your system (at least on Debian 9). So run command:

    apt-get install default-libmysqlclient-dev