Need help setting up my database application with activerecord without rails. I have followed the documentation so far and I am encountering an error in regards to installing the pg gem
. This is inside of my environment.rb.
require 'bundler/setup'
Bundler.require(:default, ENV['SINATRA_ENV'])
require 'active_record'
ActiveRecord::Base.establish_connection("postgres://localhost/development")
require_all 'app'
Every time I install postgres on the CLI with sudo ARCHFLAGS="-arch x86_64" gem install pg
. I get an error of:
Building native extensions. This could take a while...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
current directory: /Users/kenkuts/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/pg-1.1.4/ext
/Users/kenkuts/.rvm/rubies/ruby-2.5.3/bin/ruby -r ./siteconf20190206-73835-1tfhfez.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/kenkuts/.rvm/rubies/ruby-2.5.3/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/kenkuts/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/pg-1.1.4/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Users/kenkuts/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/gems/pg-1.1.4 for inspection.
Results logged to /Users/kenkuts/.rvm/rubies/ruby-2.5.3/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-18/2.5.0/pg-1.1.4/gem_make.out