Rails new app_name fails due to Sqlite3 problem - ruby-on-rails

On Windows 10 64bit
Using Railsinstaller I installed the bundler necessary to build my App.
After the installation I checked the versions of:
$ ruby -v
ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
$ rails -v
Rails 5.2.2
$ gem -v
2.5.2
$ bundler -v
Bundler version 2.0.1
$ sqlite3 --version
3.8.7.2 2014-11-18 20:57:56 2ab564bf9655b7c7b97ab85cafc8a48329b27f93
Then I started rails new my_app_name which ended with these errors:
mkmf.log
package configuration for sqlite3 is not found
find_header: checking for sqlite3.h... -------------------- no
"gcc -o conftest.exe -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0/ruby/backward -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -L. -LC:/RailsInstaller/Ruby2.3.3/lib -L. -lmsvcrt-ruby230 -lshell32 -lws2_32 -liphlpapi -limagehlp -lshlwapi "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7: return 0;
8: }
/* end */
"gcc -E -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0/i386-mingw32 -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0/ruby/backward -IC:/RailsInstaller/Ruby2.3.3/include/ruby-2.3.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D__MINGW_USE_VC2005_COMPAT -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat conftest.c -o conftest.i"
conftest.c:5:21: fatal error: sqlite3.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: #include <sqlite3.h>
/* end */
--------------------
And gem_make.out
current directory: C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/sqlite3-1.4.0/ext/sqlite3
C:/RailsInstaller/Ruby2.3.3/bin/ruby.exe -r ./siteconf20190214-3564-1lpwzs0.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Install SQLite3 from http://www.sqlite.org/ first.
*** 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=C:/RailsInstaller/Ruby2.3.3/bin/$(RUBY_BASE_NAME)
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-config
--without-sqlite3-config
--with-pkg-config
--without-pkg-config
--with-sqlcipher
--without-sqlcipher
--with-sqlite3-dir
--without-sqlite3-dir
--with-sqlite3-include
--without-sqlite3-include=${sqlite3-dir}/include
--with-sqlite3-lib
--without-sqlite3-lib=${sqlite3-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/extensions/x86-mingw32/2.3.0/sqlite3-1.4.0/mkmf.log
extconf failed, exit code 1
I am total beginner with Ruby and this is my first attempt to create app so I can experiment. It seems to me that the problem is related with the Sqlite3 version. I tried to update it via gem and bundle but I got error again.

I have got the same issue and these are the two solutions I found.
1* After the bundle install fail to enter on the project folder and modify the Gemfile
gem 'sqlite3', '1.3.11'
this line change it by some of these 3 below
gem 'sqlite3', git: "https://github.com/sparklemotion/sqlite3-ruby"
gem 'sqlite3', git: "https://github.com/sparklemotion/sqlite3-ruby", branch: "add-gemspec"
gem 'sqlite3', git: "https://github.com/larskanis/sqlite3-ruby", branch: "add-gemspec"
It only works if you've installed first Ruby Devkit or RubyInstaller and later Rails Installer, otherwise Rails Installer Ruby folder will be choosed by system as "ruby folder"
2* you'll have to uninstall RailsInstaller and remove the remaining folder(if you don't remove manually the folder after uninstaller ends, when you execute gem command it'll says "RailsInstaller/Ruby2.3.3/bin" folder not found)
Ok, after it install rails by command line
gem install rails
And install by command line MinGW
C:\Sites>ridk exec pacman -S mingw-w64-x86_64-dlfcn
Download the gem file from https://rubygems.org/ and save it locally and install from file
gem install --local C:\sqlite3-1.4.0.gem
This second solution works globally so you've to run it only once and the next time you execute rails new blog the issue with sqlite won't appear again. Just make sure to execute it on the Sites folder not inside any project or it'll work only for that project.
If any of these works for you please feel free to try one of the methods I mention here https://mycodeissuesandfixes.blogspot.com/2019/02/ruby-on-rails-issue-about-sqlite-3-gem.html , I've tried to find a solution for more than a week to this.
Good Luck!! Hope it helps you

Related

"Error installing rails" because "extconf.rb failed" on Ubuntu 18.04

I'm failing to install Rails.
Background: My (brand new) system = Ubuntu 18.04, Ruby 2.6.0, latest rvm and bundler installed and updated. The first thing I did after installing Ruby was to do sudo apt install ruby-railties and sudo apt install rails...I don't know why I didn't use gem install. After that, I never have successfully executed rails new but I did once partially execute it, but it failed and that's when I started down the rabbit hole.
When I type rails -v I get this:
Traceback (most recent call last):
4: from /home/globewalldesk/.rvm/gems/ruby-2.6.0/bin/ruby_executable_hooks:24:in `<main>'
3: from /home/globewalldesk/.rvm/gems/ruby-2.6.0/bin/ruby_executable_hooks:24:in `eval'
2: from /home/globewalldesk/.rvm/gems/ruby-2.6.0/bin/rails:23:in `<main>'
1: from /usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:482:in `block in replace_bin_path'
/usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:462:in `block in replace_bin_path': can't find executable rails for gem railties. railties is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
When I try to execute gem install rails, I get this:
Successfully installed concurrent-ruby-1.1.4
HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.
Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.
For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0
Successfully installed i18n-1.5.2
Successfully installed thread_safe-0.3.6
Successfully installed tzinfo-1.2.5
Successfully installed activesupport-5.2.2
Successfully installed rack-2.0.6
Successfully installed rack-test-1.1.0
Successfully installed mini_portile2-2.4.0
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
current directory: /home/globewalldesk/.rvm/gems/ruby-2.6.0/gems/nokogiri-1.10.1/ext/nokogiri
/usr/share/rvm/rubies/ruby-2.6.0/bin/ruby -I /usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0 -r ./siteconf20190116-22693-tbjpnz.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
*** 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=/usr/share/rvm/rubies/ruby-2.6.0/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
/usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:408:in `block (2 levels) in replace_gem': mini_portile2 is not part of the bundle. Add it to your Gemfile. (Gem::LoadError)
from extconf.rb:469:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/globewalldesk/.rvm/gems/ruby-2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.1/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/globewalldesk/.rvm/gems/ruby-2.6.0/gems/nokogiri-1.10.1 for inspection.
Results logged to /home/globewalldesk/.rvm/gems/ruby-2.6.0/extensions/x86_64-linux/2.6.0/nokogiri-1.10.1/gem_make.out
I've looked through installation instructions and many similar questions here and elsewhere, and tried a bunch of stuff, and nothing seems to work.
I get a similar error message when I try gem install nokogiri.
Help!
UPDATE: Here is the mkmf.log file:
"gcc -o conftest -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/x86_64-linux -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/ruby/backward -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0 -I. -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wrestrict -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC conftest.c -L. -L/usr/share/rvm/rubies/ruby-2.6.0/lib -Wl,-rpath,/usr/share/rvm/rubies/ruby-2.6.0/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/share/rvm/rubies/ruby-2.6.0/lib -L/usr/share/rvm/rubies/ruby-2.6.0/lib -lruby -lm -lc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
"gcc -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/x86_64-linux -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0/ruby/backward -I/usr/share/rvm/rubies/ruby-2.6.0/include/ruby-2.6.0 -I. -O3 -ggdb3 -Wall -Wextra -Wdeclaration-after-statement -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wrestrict -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -fPIC -Werror -c conftest.c"
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main() {return 0;}
/* end */
UPDATE 2: Taking Javier's advice, I looked at the docs for installing Nokogiri and found the command gem install nokogiri -- --use-system-libraries, which worked. Then I did the same for rails and railties.
Now I'm getting a different error message when I try to run rails new:
Traceback (most recent call last):
2: from /home/globewalldesk/.rvm/gems/ruby-2.6.0/bin/rails:23:in `<main>'
1: from /usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:482:in `block in replace_bin_path'
/usr/share/rvm/rubies/ruby-2.6.0/lib/ruby/2.6.0/bundler/rubygems_integration.rb:462:in `block in replace_bin_path': can't find executable rails for gem railties. railties is not currently included in the bundle, perhaps you meant to add it to your Gemfile? (Gem::Exception)
O
UPDATE 3:
I accepted Javier's answer. I've been working with a fresh install (attempt), so it doesn't matter if I just start completely fresh. I don't know what ultimately screwed up my system (maybe because I copied an old .bashrc file from a different system without first removing the rvm lines?), but completely uninstalling all Ruby, Rails, other gems, and rvm, and reinstalling should fix the problem.
UPDATE THE LAST:
It took quite a bit to completely uninstall Ruby, Rails, and especially RVM. I didn’t realize how important the Bash profile scripts are, or that the lines about RVM need to be thoroughly removed from them, or how important the state of certain environment variables set by RVM are. I think the main reason I was having trouble installing Rails was simply about I had copied RVM settings from my old bash profiles. I should have removed them.
Everything is working as expected now.
Here are the docs to install nokogiri https://nokogiri.org/tutorials/installing_nokogiri.html, there is a note for rvm:
Note for RVM users: you may require libgmp, consider running sudo
apt-get install libgmp-dev.
Remove ruby with rvm https://rvm.io/rubies/removing
rvm remove 2.6.0
Install
Ruby
rvm install 2.6.0
Rails
gem install rails
For a existing project
bundle install

ruby:2.5.1-slim or ruby-2.5.1-alpine fails on nokogiri gem

FROM ruby:2.5.1-slim or ruby-2.5.1-alpine throws the following error, how I do use a smaller footprint for ruby as it doesn't seem to be using any of the above options which I would prefer to use. This error happens while running the bundle install command
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/bundle/gems/nokogiri-1.8.4/ext/nokogiri
/usr/local/bin/ruby -r ./siteconf20180828-6-l5tj3e.rb extconf.rb
checking if the C compiler accepts ... *** 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=/usr/local/bin/$(RUBY_BASE_NAME)
--help
--clean
/usr/local/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to
generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile'
from /usr/local/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror'
from /usr/local/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile'
from extconf.rb:138:in `nokogiri_try_compile'
from extconf.rb:162:in `block in add_cflags'
from /usr/local/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags'
from extconf.rb:161:in `add_cflags'
from extconf.rb:410:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /usr/local/bundle/gems/nokogiri-1.8.4 for
inspection.
Results logged to
/usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/gem_make.out
An error occurred while installing nokogiri (1.8.4), and Bundler cannot
continue.
Make sure that `gem install nokogiri -v '1.8.4' --source 'http://rubygems.org/'`
succeeds before bundling.
In Gemfile:
rails was resolved to 5.2.1, which depends on
actioncable was resolved to 5.2.1, which depends on
actionpack was resolved to 5.2.1, which depends on
actionview was resolved to 5.2.1, which depends on
rails-dom-testing was resolved to 2.0.3, which depends on
nokogiri
The command '/bin/sh -c bundle install --without development test' returned a non-zero code: 5
First of all, try to run gem install nokogiri manually and check the log as suggested in the output above:
...
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
/usr/local/bundle/extensions/x86_64-linux/2.5.0/nokogiri-1.8.4/mkmf.log
...
I recently had a problem while installing the nokogiri gem too. So I opened my mkmf.log file and found the reason of the problem there (the stdio.h library was missing out of the distribution):
"gcc -o conftest -I/usr/local/include/ruby-2.5.0/x86_64-linux-musl -I/usr/local/include/ruby-2.5.0/ruby/backward -I/usr/local/include/ruby-2.5.0 -I. -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wmisleading-indentation -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn -Wsuggest-attribute=format -Wduplicated-cond -Wno-maybe-uninitialized -fPIC conftest.c -L. -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lruby -lpthread -ldl -lcrypt -lm -lc "
In file included from /usr/local/include/ruby-2.5.0/ruby/ruby.h:29:0,
from /usr/local/include/ruby-2.5.0/ruby.h:33,
from conftest.c:1:
/usr/local/include/ruby-2.5.0/ruby/defines.h:112:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
The problem was solved by installing the libc-dev package for me.
So. To solve your problem you should iteratively run gem install nokogiri command, check mkmf.log file after each failure and fix missing dependencies until the package is installed.
BTW here's my final list of dependencies which was enough to install Rails in Alpine:
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
&& apk update \
&& apk add --update-cache postgresql-client nodejs \
libffi-dev readline sqlite build-base postgresql-dev \
libc-dev linux-headers libxml2-dev libxslt-dev readline-dev gcc libc-dev \
&& rm -rf /var/cache/apk/*
try this:
run sudo gem install nokogiri. It will install the latest version of nokogiri.
Then update the version of nokogiri in your Gemfile.lock file to the latest version of nokogiri you juste installed.
And finally run bundle install. Maybe it'll help. Worked for me.

Installing Postgres gem on Rails 5.2 throws error – Gem::Ext::BuildError: ERROR: Failed to build gem native extension

I'm trying to set up a Rails project with Vagrant. Using Rails 5.2 as well.
In my original bundle install, it told me
Your user account isn't allowed to install to the system RubyGems.
You can cancel this installation and run:
bundle install --path vendor/bundle
to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.
...So I tried that and got:
Fetching pg 1.0.0
Installing pg 1.0.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /app/vendor/bundle/ruby/2.5.0/gems/pg-1.0.0/ext
/usr/local/bin/ruby -r ./siteconf20180501-2212-1algyv4.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.
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=/usr/local/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/app/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0-static/pg-1.0.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /app/vendor/bundle/ruby/2.5.0/gems/pg-1.0.0 for inspection.
Results logged to /app/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0-static/pg-1.0.0/gem_make.out
An error occurred while installing pg (1.0.0), and Bundler cannot continue.
Make sure that `gem install pg -v '1.0.0'` succeeds before bundling.
Looking at the log file mentioned has this in it:
find_executable: checking for pg_config... -------------------- no
--------------------
find_header: checking for libpq-fe.h... -------------------- no
"gcc -o conftest -I/usr/local/include/ruby-2.5.0/x86_64-linux -I/usr/local/include/ruby-2.5.0/ruby/backward -I/usr/local/include/ruby-2.5.0 -I. -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn conftest.c -L. -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L. -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lruby-static -lpthread -lrt -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 */
"gcc -E -I/usr/local/include/ruby-2.5.0/x86_64-linux -I/usr/local/include/ruby-2.5.0/ruby/backward -I/usr/local/include/ruby-2.5.0 -I. -O3 -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wno-tautological-compare -Wno-parentheses-equality -Wno-constant-logical-operand -Wno-self-assign -Wunused-variable -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -Wdeprecated-declarations -Wno-packed-bitfield-compat -Wsuggest-attribute=noreturn conftest.c -o conftest.i"
conftest.c:3:22: fatal error: libpq-fe.h: No such file or directory
compilation terminated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <libpq-fe.h>
/* end */
Unclear how to proceed and get this working. Would love some help or advice. Thanks!
Edit:
I run sudo apt-get install libpq-dev and then get an error related to and old version.
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /tmp/bundler20180501-4263-lecb9zpg-1.0.0/gems/pg-1.0.0/ext
/usr/local/bin/ruby -r ./siteconf20180501-4263-1qowxi6.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQsetSingleRowMode()... no
Your PostgreSQL is too old. Either install an older version of this gem or upgrade your database to at least PostgreSQL-9.2.
*** 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.

gem install pg for ruby on rails

Postgresql will not install on OSX
here is my data below
n error occurred while installing pg (0.18.4), and Bundler cannot continue.
Make sure that gem install pg -v '0.18.4' succeeds before bundling.
chriss-MacBook-Pro:shine chriswilson$ bundle exec install
usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 file2
install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode]
[-o owner] file1 ... fileN directory
install -d [-v] [-g group] [-m mode] [-o owner] directory ...
chriss-MacBook-Pro:shine chriswilson$ gem install pg -v '0.18.4'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /Users/chriswilson/.rvm/gems/ruby-2.3.0/gems/pg-0.18.4/ext
/Users/chriswilson/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160902-1617-e1qwb1.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.
Provided configuration options:
--with-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=/Users/chriswilson/.rvm/rubies/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/chriswilson/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-15/2.3.0/pg-0.18.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/chriswilson/.rvm/gems/ruby-2.3.0/gems/pg-0.18.4 for inspection.
Results logged to /Users/chriswilson/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-15/2.3.0/pg-0.18.4/gem_make.out
chriss-MacBook-Pro:shine chriswilson$ gem install pg -v '0.18.4'
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /Users/chriswilson/.rvm/gems/ruby-2.3.0/gems/pg-0.18.4/ext
/Users/chriswilson/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160902-1643-jfhxyo.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.
Provided configuration options:
--with-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=/Users/chriswilson/.rvm/rubies/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/chriswilson/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-15/2.3.0/pg-0.18.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/chriswilson/.rvm/gems/ruby-2.3.0/gems/pg-0.18.4 for inspection.
Results logged to /Users/chriswilson/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-15/2.3.0/pg-0.18.4/gem_make.out
find_executable: checking for pg_config... -------------------- no
--------------------
find_header: checking for libpq-fe.h... -------------------- no
"gcc -o conftest -I/Users/chriswilson/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/x86_64-darwin15 -I/Users/chriswilson/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/backward -I/Users/chriswilson/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -L. -L/Users/chriswilson/.rvm/rubies/ruby-2.3.0/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -L. -fstack-protector -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -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 */
"gcc -E -I/Users/chriswilson/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/x86_64-darwin15 -I/Users/chriswilson/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/backward -I/Users/chriswilson/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0 -I. -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens -fno-common -pipe conftest.c -o conftest.i"
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 */
--------------------
This basically means that you're missing a library or program on your setup. I've had this issue a couple of times now so here are a few different things to try (hopefully one of them will work for you):
Install a common missing library:
brew install libpqxx
gem install pg
Reinstall postgres (not ideal I know):
brew uninstall postgresql
brew install postgresql
gem install pg
Explicitly define path of pg_config:
1) Get location of pg_config
which pg_config
2) pass that path into gem install
gem install pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Try this it will work
sudo apt-get install -y libpq-dev build-essential postgresql-server-dev-all libpgsql-ruby postgresql ruby-dev && gem install pg

Instailling Rails 2.0.0 extconf.rb failure on windows 7

I'm trying to install rails 2.0.0 on my computer. I already have already installed ruby on my computer, running the
ruby -v
command returns
ruby 2.0.0p247 (2013-06-27) [x64-mingw32]
Now, I'm trying to install rails 2.0.0 by running
gem install rails
However, I am running into an error:
C:/Ruby200-x64/bin/ruby.exe extconf.rb
*** 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=C:/Ruby200-x64/bin/ruby
--with-atomic_reference-dir
--without-atomic_reference-dir
--with-atomic_reference-include
--without-atomic_reference-include=${atomic_reference-dir}/include
--with-atomic_reference-lib
--without-atomic_reference-lib=${atomic_reference-dir}/
C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:430:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:515:in `try_link0'
from C:/Ruby200-x64/lib/ruby/2.0.0/mkmf.rb:813:in `try_run'
from extconf.rb:24:in `<main>'
4th line up says I need to install development tools, so I downloaded the dev kit from http://rubyinstaller.org/downloads/ for my 64 bit windows, and ran the following commands without issue:
ruby dk.rb init
ruby dk.rb install
However, I still got the same error after running gem rails install... .am I installing the wrong development tools or something? I'm not sure what's going wrong
Additionally I'm using pik to control my ruby version, if that information is relevant.
Note: I checked out another possible solution that said that my userfolder had spaces in it, causing the install to go wonky, but my user account doesn't have spaces in it, so that didn't help.
*edit: the mkmf file with more info:
"x86_64-w64-mingw32-gcc -o conftest.exe -IC:/Ruby200-x64/include/ruby-2.0.0/x64-mingw32 -IC:/Ruby200-x64/include/ruby-2.0.0/ruby/backward -IC:/Ruby200-x64/include/ruby-2.0.0 -I. -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -march=native conftest.c -L. -LC:/Ruby200-x64/lib -L. -lx64-msvcrt-ruby200 -lshell32 -lws2_32 -limagehlp -lshlwapi "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7: return 0;
8: }
/* end */

Resources