ruby-on-railsrubylinuxslackware

I can't install pg in Slackware


I need to run a ruby project with gems and specs. When I type bundle install I received:

bash-5.1# bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and
installing your bundle as root will break this application for all non-root
users on this machine.
Fetching gem metadata from https://rubygems.org/...
Resolving dependencies...
Using bundler 2.3.9
Using diff-lcs 1.5.0
Using rspec-support 3.1.2
Fetching pg 1.3.4
Using rspec-core 3.1.7
Using rspec-expectations 3.1.2
Using rspec-mocks 3.1.3
Using rspec 3.1.0
Installing pg 1.3.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /usr/lib64/ruby/gems/3.0.0/gems/pg-1.3.4/ext
/usr/bin/ruby -I /usr/lib64/ruby/3.0.0 -r ./siteconf20220320-7556-sm89ck.rb
extconf.rb
Calling libpq with GVL unlocked
checking for pg_config... no
checking for libpq per pkg-config... no
Using libpq from 
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*****************************************************************************

Unable to find PostgreSQL client library.

Please install libpq or postgresql client package like so:
  sudo apt install libpq-dev
  sudo yum install postgresql-devel
  sudo zypper in postgresql-devel
  sudo pacman -S postgresql-libs

or try again with:
  gem install pg -- --with-pg-config=/path/to/pg_config

or set library paths manually with:
gem install pg -- --with-pg-include=/path/to/libpq-fe.h/
--with-pg-lib=/path/to/libpq.so/

*** 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}/lib64
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/usr/bin/$(RUBY_BASE_NAME)
    --with-pg
    --without-pg
    --enable-gvl-unlock
    --disable-gvl-unlock
    --enable-windows-cross
    --disable-windows-cross
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-libpq-config
    --without-libpq-config
    --with-pkg-config
    --without-pkg-config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib64

To see why this extension failed to compile, please check the mkmf.log which can
be found here:

  /usr/lib64/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/pg-1.3.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/lib64/ruby/gems/3.0.0/gems/pg-1.3.4 for
inspection.
Results logged to
/usr/lib64/ruby/gems/3.0.0/extensions/x86_64-linux/3.0.0/pg-1.3.4/gem_make.out

  /usr/lib64/ruby/3.0.0/rubygems/ext/builder.rb:93:in `run'
  /usr/lib64/ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:47:in `block in build'
  /usr/lib64/ruby/gems/3.0.0/gems/tempfile-0.1.2/lib/tempfile.rb:317:in `open'
  /usr/lib64/ruby/3.0.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
  /usr/lib64/ruby/3.0.0/rubygems/ext/builder.rb:159:in `build_extension'
/usr/lib64/ruby/3.0.0/rubygems/ext/builder.rb:193:in `block in
build_extensions'
  /usr/lib64/ruby/3.0.0/rubygems/ext/builder.rb:190:in `each'
  /usr/lib64/ruby/3.0.0/rubygems/ext/builder.rb:190:in `build_extensions'
  /usr/lib64/ruby/3.0.0/rubygems/installer.rb:845:in `build_extensions'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/rubygems_gem_installer.rb:71:in
`build_extensions'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/source/rubygems.rb:204:in
`install'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/installer/gem_installer.rb:54:in
`install'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/installer/parallel_installer.rb:186:in
`do_install'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/installer/parallel_installer.rb:177:in
`block in worker_pool'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/worker.rb:62:in
`apply_func'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/worker.rb:57:in
`block in process_queue'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/worker.rb:54:in
`loop'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/worker.rb:54:in
`process_queue'
/usr/lib64/ruby/gems/3.0.0/gems/bundler-2.3.9/lib/bundler/worker.rb:91:in
`block (2 levels) in create_threads'

An error occurred while installing pg (1.3.4), and Bundler cannot
continue.

In Gemfile:
  pg

I am trying to convince them to switch to Slackware as the main OS but I am having trouble installing and running the skeleton program that uses psql, ruby and soon enough ruby on rails.

I installed libpqxx slackbuild, sqlite3 gem, postgresql (14.2) slackbuild and when I run rnu ./import_db.sh it says: bash-5.1# ./import_db.sh dropdb: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket? createdb: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket? psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory Is the server running locally and accepting connections on that socket? bash-5.1#


Solution

  • I've just realised that Slackware uses slackpkg as package manager. Not quite sure if this is the library you need, but try installing with:

    slackpkg install libpqxx