LoginSignup
4
3

More than 3 years have passed since last update.

ruby:2.5.0-alpine3.7 に gem install sqlite3 する

Last updated at Posted at 2020-05-15

ruby:2.5.0-alpine3.7 の Docker image に sqlite3 をインストールしようとしたときのメモです。
このときは、sqlite3 の 1.4.2 が最新でした。

make, g++, sqlite-dev を入れると install できました

/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.3-180-g5372bc29f3 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.3-183-gcc9ad2b48d [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
OK: 9066 distinct packages available
/ # apk add make g++ sqlite-dev
(1/19) Upgrading musl (1.1.18-r3 -> 1.1.18-r4)
(2/19) Installing libgcc (6.4.0-r5)
(3/19) Installing libstdc++ (6.4.0-r5)
(4/19) Installing binutils-libs (2.30-r2)
(5/19) Installing binutils (2.30-r2)
(6/19) Installing gmp (6.1.2-r1)
(7/19) Installing isl (0.18-r0)
(8/19) Installing libgomp (6.4.0-r5)
(9/19) Installing libatomic (6.4.0-r5)
(10/19) Installing mpfr3 (3.1.5-r1)
(11/19) Installing mpc1 (1.0.3-r1)
(12/19) Installing gcc (6.4.0-r5)
(13/19) Installing musl-dev (1.1.18-r4)
(14/19) Installing libc-dev (0.7.1-r0)
(15/19) Installing g++ (6.4.0-r5)
(16/19) Upgrading musl-utils (1.1.18-r3 -> 1.1.18-r4)
(17/19) Installing make (4.2.1-r0)
(18/19) Installing sqlite-libs (3.25.3-r2)
(19/19) Installing sqlite-dev (3.25.3-r2)
Executing busybox-1.27.2-r7.trigger
OK: 187 MiB in 47 packages
/ # gem install sqlite3
Fetching: sqlite3-1.4.2.gem (100%)
Building native extensions. This could take a while...
Successfully installed sqlite3-1.4.2
1 gem installed
/ #

それぞれ、足りない時のエラー

他の OS でも似たようなエラーが出る可能性があると思うので記載しておきます。

make がない

/ # gem install sqlite3
Fetching: sqlite3-1.4.2.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/sqlite3-1.4.2/ext/sqlite3
/usr/local/bin/ruby -r ./siteconf20200515-13-8rgmaw.rb extconf.rb
checking for sqlite3.h... yes
checking for pthread_create() in -lpthread... yes
checking for -ldl... yes
checking for sqlite3_libversion_number() in -lsqlite3... yes
checking for rb_proc_arity()... yes
checking for rb_integer_pack()... yes
checking for sqlite3_initialize()... yes
checking for sqlite3_backup_init()... yes
checking for sqlite3_column_database_name()... yes
checking for sqlite3_enable_load_extension()... yes
checking for sqlite3_load_extension()... yes
checking for sqlite3_open_v2()... yes
checking for sqlite3_prepare_v2()... yes
checking for sqlite3_int64 in sqlite3.h... yes
checking for sqlite3_uint64 in sqlite3.h... yes
creating Makefile

current directory: /usr/local/bundle/gems/sqlite3-1.4.2/ext/sqlite3
make "DESTDIR=" clean
sh: make: not found

current directory: /usr/local/bundle/gems/sqlite3-1.4.2/ext/sqlite3
make "DESTDIR="
sh: make: not found

make failed, exit code 127

g++ がない

/ # gem install sqlite3
Fetching: sqlite3-1.4.2.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/sqlite3-1.4.2/ext/sqlite3
/usr/local/bin/ruby -r ./siteconf20200515-10-llmpwx.rb 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=/usr/local/bin/$(RUBY_BASE_NAME)
    --with-sqlcipher
    --without-sqlcipher
    --with-sqlite3-config
    --without-sqlite3-config
    --with-pkg-config
    --without-pkg-config
/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:541:in `try_link0'
    from /usr/local/lib/ruby/2.5.0/mkmf.rb:559:in `try_link'
    from /usr/local/lib/ruby/2.5.0/mkmf.rb:660:in `try_ldflags'
    from /usr/local/lib/ruby/2.5.0/mkmf.rb:1820:in `pkg_config'
    from extconf.rb:35: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/sqlite3-1.4.2/mkmf.log

extconf failed, exit code 1

sqlite-dev がない

/ # gem install sqlite3
Fetching: sqlite3-1.4.2.gem (100%)
Building native extensions. This could take a while...
ERROR:  Error installing sqlite3:
    ERROR: Failed to build gem native extension.

    current directory: /usr/local/bundle/gems/sqlite3-1.4.2/ext/sqlite3
/usr/local/bin/ruby -r ./siteconf20200515-10-s4bcgw.rb extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'brew install sqlite3',
'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
and check your shared library search path (the
location where your sqlite3 shared library is located).
*** 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-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:

  /usr/local/bundle/extensions/x86_64-linux/2.5.0/sqlite3-1.4.2/mkmf.log

extconf failed, exit code 1
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3