1

I'm trying to install Ruby (3.2.0) (and Rails [7.0.4]) on an Intel Mac (OS 12.6). I'm running into issues with sqlite3 — no surprise. My current error message is this:

package configuration for /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ports/x86_64-apple-darwin21.6.0/sqlite3/3.40.0/lib/pkgconfig/sqlite3.pc is not found

When I enter gem install sqlite3 I get the following ugly error message:

Building native extensions. This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ext/sqlite3
/usr/local/opt/ruby/bin/ruby -I /usr/local/lib/ruby/site_ruby/3.2.0 extconf.rb
Building sqlite3-ruby using packaged sqlite3.
Extracting sqlite-autoconf-3400000.tar.gz into tmp/x86_64-apple-darwin21.6.0/ports/sqlite3/3.40.0... OK
Running 'configure' for sqlite3 3.40.0... OK
Running 'compile' for sqlite3 3.40.0... OK
Running 'install' for sqlite3 3.40.0... OK
Activating sqlite3 3.40.0 (from /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/ports/x86_64-apple-darwin21.6.0/sqlite3/3.40.0)...

Could not configure the build properly (pkg_config). Please install either the `pkg-config` utility or the `pkg-config` rubygem.

*** 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:

[insert long list of options...]

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

  /usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-21/3.2.0/sqlite3-1.5.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4 for inspection.
Results logged to /usr/local/lib/ruby/gems/3.2.0/extensions/x86_64-darwin-21/3.2.0/sqlite3-1.5.4/gem_make.out

I've been through many iterations of solutions found across the interwebs (changing permissions, installing pkg-config per the error message, changing $PATH in .zshrc, installing sqlite binary packages, modifying the Gemfile, total uninstalls of both, and restarts) to no avail.

The Homebrew-installed sqlite3 is working properly. which sqlite3 produces

/usr/local/opt/sqlite3/bin/sqlite3

Happy to provide any more relevant information that's helpful. Any guidance appreciated!

masomaster
  • 13
  • 3
  • https://stackoverflow.com/questions/25839142/gem-install-sqlite3-error - have you check this solution? – 000723-weict Jan 11 '23 at 05:39
  • Have you looked into the log files mentioned in your quoted output? What's in there? Have you followed the advice in the message regarding pkg-config, namely "Could not configure the build properly (pkg_config). Please install either the `pkg-config` utility or the `pkg-config` rubygem."? What happened? – Holger Just Jan 11 '23 at 12:06
  • @000723-weict, I'm not using RVM, but I'll give those instructions a shot. Thanks – masomaster Jan 11 '23 at 17:08
  • @HolgerJust, see my comment in response to Guilherme below. – masomaster Jan 11 '23 at 17:08
  • @000723-weict, Update: I think I shouldn't have used the outdate echo $PATH CLI, as now `$ gem install sqlite3` produces the following error message: "ERROR: While executing gem ... (Errno::EPERM) Operation not permitted @ apply2files - /usr/local/lib/ruby/gems/3.2.0/gems/sqlite3-1.5.4/.gemtest" followed by a long list of files paths. – masomaster Jan 11 '23 at 17:17

1 Answers1

0

If you do not have pkg-config installed, you should install to proceed

You can check it using:

$ which pkg-config

If not found, install it:

$ curl https://pkg-config.freedesktop.org/releases/pkg-config-0.28.tar.gz -o pkgconfig.tgz
$ tar -zxf pkgconfig.tgz && cd pkg-config-0.28
$ ./configure && make install

I'm just following this page

  • I've tried `gem install pkg-config` and the three-line installation code you've got above and confirmed that pkg-config is on the `gem list`, and still `which pkg-config` doesn't find pkg-config. – masomaster Jan 11 '23 at 17:02
  • In this case, I strongly recommend you to use [RVM](https://rvm.io/) or [rbenv](https://github.com/rbenv/rbenv#homebrew) They will handle all these problems for you. I noticed you had some permissions problems. These guys will solve that also – Guilherme Cruz Jan 11 '23 at 23:29
  • Thanks @Guilhereme Cruz, I'll try that next then – masomaster Jan 12 '23 at 06:48
  • yes @GuilhermeCruz i even recommend same thats what my first solution post to. – 000723-weict Jan 12 '23 at 10:50
  • Thank you, @GuilhermeCruz and 000723-weict for the recommendation. Install RVM and it all worked like a charm! – masomaster Jan 14 '23 at 05:52