5
respostas

Erro na Instalação da gem 'pg'

Olá, infelizmente não consegui instalar o pg 1.1.3 no meu Mac. Vou passar abaixo as mensagens de erro que aparecem no meu Terminal. Além disso foi criado um arquivo de log com o texto que também transcrevo abaixo.

Será que alguém consegue me auxiliar nesta instalação? Valeu

Erro Terminal

Fetching pg 1.1.3 Installing pg 1.1.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Library/Ruby/Gems/2.3.0/gems/pg-1.1.3/ext /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20181224-4683-1xgimlw.rb extconf.rb checking for pg_config... no No pg_config... trying anyway. If building fails, please try again with --with-pg-config=/path/to/pg_config checking for libpq-fe.h... no Can't find the 'libpq-fe.h header * 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.

Log Erro Arquivo mkmf.log

find_executable: checking for pg_config... -------------------- no


find_header: checking for libpq-fe.h... -------------------- no

"xcrun clang -o conftest -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib -L. -lruby.2.3.0 -lpthread -ldl -lobjc " checked program was: /* begin / 1: #include "ruby.h" 2: 3: int main(int argc, char **argv) 4: { 5: return 0; 6: } / end */

"xcrun clang -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin18 -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/backward -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS -c conftest.c" conftest.c:3:10: fatal error: 'libpq-fe.h' file not found

#include <libpq-fe.h> ^~ 1 error generated. checked program was: /* begin / 1: #include "ruby.h" 2: 3: #include <libpq-fe.h> / end */


5 respostas

Fala Vicente tudo certo ?

Pode postar seu GemFile pra gente dar uma olhada ?

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.3.7'

gem 'rails-i18n', '~> 5.1' gem 'twitter-bootstrap-rails'

Bundle edge Rails instead: gem 'rails', github: 'rails/rails'

gem 'rails', '~> 5.2.2'

Use Puma as the app server

gem 'puma', '~> 3.11'

Use SCSS for stylesheets

gem 'sass-rails', '~> 5.0'

Use Uglifier as compressor for JavaScript assets

gem 'uglifier', '>= 1.3.0'

See https://github.com/rails/execjs#readme for more supported runtimes

gem 'mini_racer', platforms: :ruby

Use CoffeeScript for .coffee assets and views

gem 'coffee-rails', '~> 4.2'

Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks

gem 'turbolinks', '~> 5'

Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder

gem 'jbuilder', '~> 2.5'

Use Redis adapter to run Action Cable in production

gem 'redis', '~> 4.0'

Use ActiveModel has_secure_password

gem 'bcrypt', '~> 3.1.7'

Use ActiveStorage variant

gem 'mini_magick', '~> 4.8'

Use Capistrano for deployment

gem 'capistrano-rails', group: :development

Reduces boot times through caching; required in config/boot.rb

gem 'bootsnap', '>= 1.1.0', require: false

group :development, :test do

Call 'byebug' anywhere in the code to stop execution and get a debugger console

gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]

Use sqlite3 as the database for Active Record

gem 'sqlite3' end

group :development do

Access an interactive console on exception pages or by calling 'console' anywhere in the code.

gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2'

Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring

gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end

group :test do

Adds support for Capybara system testing and selenium driver

gem 'capybara', '>= 2.15' gem 'selenium-webdriver'

Easy installation and use of chromedriver to run system tests with Chrome

gem 'chromedriver-helper' end

Windows does not include zoneinfo files, so bundle the tzinfo-data gem

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

group :production do gem 'pg' end

Olá Vicente, tudo bem?

Por gentileza, remove o postgresql com o brew, atualiza o brew e instala novamente rodando no seu terminal os seguintes comandos:

brew uninstall postgresql

brew update

brew install postgresql

Fazendo isso, executa o seguinte comando para instalar a gem do postgresql:

gem install pg

Faz esse teste por favor e nos diz o que acontece?

Valeu

: )

Olá Guilherme, o que está acontecendo agora me parece que refere-se a versão do Ruby que está rodando.

Quando digito o comando 'ruby -v' aparece:

ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]

Se coloco o 'rbenv versions' aparece:

system 2.3.7

  • 2.5.1 (set by /Users/Vicente/ruby on rails/projeto/.ruby-version)

Mesmo assim não consigo de forma alguma alterar a versão do Ruby para o 2.5.1 sugerido para rodar no curso.

Pelo que li me alguns forums a versão 2.3 é que vem instalada no Mac e por isso está dando erro de falta de permissão de acesso ao diretório para instalar as gems.

ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

Olá Vicente, tudo bem?

Isso mesmo. O Mac já vem com uma versão do ruby instalada. Para atualizar a versão do ruby, siga as instruções abaixo:

Execute este comando no seu terminal:

\curl -sSL https://get.rvm.io | bash -s stable

Quando finalizar, feche seu terminal e abra novamente.

Veja a lista das versões do ruby que você possui com o seguinte comando:

rvm list known

Para instalar a versão 2.5.1 do ruby, rode o seguinte comando:

rvm install ruby-2.5.1

Agora, vamos deixar padrão a versão 2.5.1 do ruby:

rvm use ruby-2.5.1 --default

Por gentileza, execute este teste e nos diga se deu certo?

: )