1

Faz um tempinho que comecei a brincar com Ruby on Rails no Ubuntu e criei alguns projetinhos.

Atualmente instalei a distro Manjaro e fiz a instalação do ruby e do rails e quero executar o meu projeto criado no Ubuntu, porém estou enfrentando um problema com a gem mysql2.

Ao tentar startar a aplicação "rails s" é apresentado o seguinte erro:

Could not find proper version of railties (4.2.1) in any of the sources Run bundle install to install missing gems.

Ao executar o comando bundle install ocorre o seguinte erro:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
 ERROR: Failed to build gem native extension.
    current directory: /home/wagner/.rvm/gems/ruby-2.3.1/gems/mysql2-0.3.18>>/ext/mysql2
/home/wagner/.rvm/rubies/ruby-2.3.1/bin/ruby -r >./siteconf20160831-4570-57p5rs.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You >may
need configuration options.
Provided configuration options:
 --with-opt-dir
 --without-opt-dir
 --with-opt-include
 --without-opt-include=${opt-dir}/include
 --with-opt-lib
 --without-opt-lib=${opt-dir}/lib
 --with-make-prog
 --without-make-prog
 --srcdir=.
 --curdir
 --ruby=/home/wagner/.rvm/rubies/ruby-2.3.1/bin/$(RUBY_BASE_NAME)
 --with-mysql-dir
 --without-mysql-dir
 --with-mysql-include
 --without-mysql-include=${mysql-dir}/include
 --with-mysql-lib
 --without-mysql-lib=${mysql-dir}/lib
 --with-mysql-config
 --without-mysql-config
 --with-mysql-dir
 --without-mysql-dir
 --with-mysql-include
 --without-mysql-include=${mysql-dir}/include
 --with-mysql-lib
 --without-mysql-lib=${mysql-dir}/lib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-mlib
 --without-mlib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-zlib
 --without-zlib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-socketlib
 --without-socketlib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-nsllib
 --without-nsllib
 --with-mysqlclientlib
 --without-mysqlclientlib
 --with-mygcclib
 --without-mygcclib
 --with-mysqlclientlib
 --without-mysqlclientlib
To see why this extension failed to compile, please check the mkmf.log >which can be found here:
  /home/wagner/.rvm/gems/ruby-2.3.1/extensions/x86_64-linux/2.3.0>/mysql2-0.3.18/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/wagner/.rvm/gems/ruby-2.3.1/gems/mysql2-0.3.18 for inspection.
Results logged to /home/wagner/.rvm/gems/ruby-2.3.1/extensions/x86_64->linux/2.3.0/mysql2-0.3.18/gem_make.out

No meu gemfile a gem está configurada da seguinte maneira gem 'mysql2', '~> 0.3.18'

Alguém tem ideia do que pode estar errado ? Muito obrigado pela atenção.

2 Respostas 2

0

Olá você precisa instalar as bibliotecas nativas de compilação do MySQL

sudo apt-get install libmysqlclient-dev

Caso você não tenha instalado, instale também o build-essential

sudo apt-get install build-essential

E ai sim, instale a gem do MySQL

gem install mysql2
4
  • 1
    Olá, o Manjaro não possui o comando apt-get. No fim de semana quando estiver em casa irei procurar o comando equivalente para o Manjaro . Obrigado pela dica. 2/09/2016 às 14:50
  • @WagnerRodrigues deu certo? 5/09/2016 às 12:16
  • 1
    Nem tive tempo de ver no fim de semana. Hoje eu procurei e não encontrei os comandos equivalentes para o Manjaro, porém ao pesquisar por mysql no gerenciador de pacotes pacman eu encontrei o pacote libmariadbclient e o instalei. Após isto executei o bundle install e funcionou. Obrigado pela ajuda. 7/09/2016 às 0:15
  • A resposta não responde a pergunta. 13/04/2020 às 16:18
0

No Manjaro e em qualquer outra distribuição baseada em ArchLinux, conforme o comentário do @WagnerRodrigues, é preciso instalar o pacote libmariadbclient com o comando:

pacman -S libmariadbclient

Feito isso, retorne à instalação normal da gem mysql2 e vai funcionar.

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .