Error installing mysql2 gem on Ubuntu 16.04LTS

百般思念 提交于 2019-12-06 12:23:18

问题


I tried sudo gem install mysql2 -v '0.4.4' and got error. Checking /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.4/mkmf.log:

"gcc -o conftest -I/usr/include/x86_64-linux-gnu/ruby-2.3.0 -I/usr/include/ruby-2.3.0/ruby/backward -I/usr/include/ruby-2.3.0 -I. -Wdate-time -D_FORTIFY_SOURCE=2   -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -fPIC conftest.c  -L. -L/usr/lib/x86_64-linux-gnu -L. -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic     -lruby-2.3  -lpthread -lgmp -ldl -lcrypt -lm   -lc"
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

So it seems to me ruby.h was the problem. But I can find it in:

/usr/include/ruby-2.3.0/ruby/ruby.h
/usr/include/ruby-2.3.0/ruby.h

I checked Error while installing json gem 'mkmf.rb can't find header files for ruby' but in fact I have installed ruby development.

sudo dpkg -l | grep ruby also shows I have:

sudo dpkg -l | grep ruby
ii  libruby2.3:amd64                      2.3.1-2~16.04                     amd64        Libraries necessary to run Ruby 2.3
ii  rake                                  10.5.0-2                          all          ruby make-like utility
ii  ruby                                  1:2.3.0+1                         all          Interpreter of object-oriented scripting language Ruby (default version)
ii  ruby-bundler                          1.11.2-1                          all          Manage Ruby application dependencies (runtime)
ii  ruby-dev:amd64                        1:2.3.0+1                         amd64        Header files for compiling extension modules for Ruby (default version)
ii  ruby-did-you-mean                     1.0.0-2                           all          smart error messages for Ruby > 2.3
ii  ruby-eventmachine                     1.0.7-3build3                     amd64        Ruby/EventMachine library
ii  ruby-minitest                         5.8.4-2                           all          Ruby test tools supporting TDD, BDD, mocking, and benchmarking
ii  ruby-molinillo                        0.4.3-1                           all          generic dependency resolution algorithm
ii  ruby-mysql                            2.9.1-1ubuntu1                    amd64        MySQL module for Ruby
ii  ruby-mysql2                           0.4.3-2ubuntu2                    amd64        simple, fast MySQL library for Ruby
ii  ruby-net-http-persistent              2.9.4-1                           all          Manages persistent connections using Net::HTTP
ii  ruby-net-telnet                       0.1.1-2                           all          telnet client library
ii  ruby-power-assert                     0.2.7-1                           all          library showing values of variables and method calls in an expression
ii  ruby-test-unit                        3.1.7-2                           all          unit testing framework for Ruby
ii  ruby-thor                             0.19.1-2                          all          Ruby scripting framework
ii  ruby2.3                               2.3.1-2~16.04                     amd64        Interpreter of object-oriented scripting language Ruby
ii  ruby2.3-dev:amd64                     2.3.1-2~16.04                     amd64        Header files for compiling extension modules for the Ruby 2.3
ii  rubygems-integration                  1.10                              all          integration of Debian Ruby packages with Rubygems

So how can I fix this?


回答1:


Try install gcc and make. This work for me.

apt-get install gcc make


来源:https://stackoverflow.com/questions/39737364/error-installing-mysql2-gem-on-ubuntu-16-04lts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!