sqlite3 Install Failing on Deploy

This is my first Rails app and my first time using Fly. I have been attempting to follow the Rails starting guide, and upon trying to deploy, the build fails on the fourth step:

ERROR [build  4/10] RUN bundle install &&     bundle exec bootsnap precompile --gemfile &&     rm -rf ~/.  81.4s
------
 > [build  4/10] RUN bundle install &&     bundle exec bootsnap precompile --gemfile &&     rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git:
#0 0.652 Bundler 2.4.21 is running, but your lockfile was generated with 2.3.5. Installing Bundler 2.3.5 and restarting using that version.
#0 3.696 Fetching gem metadata from https://rubygems.org/.
#0 3.768 Fetching bundler 2.3.5
#0 3.902 Installing bundler 2.3.5
#0 4.958 Fetching gem metadata from https://rubygems.org/..........
...
#0 81.24 Fetching sass-rails 6.0.0
#0 81.25 Installing sass-rails 6.0.0
#0 81.29 Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
#0 81.29
#0 81.29 current directory:
#0 81.29 /rails/vendor/bundle/ruby/3.0.0/gems/sqlite3-1.4.2/ext/sqlite3
#0 81.29 /usr/local/bin/ruby extconf.rb
#0 81.29 checking for sqlite3.h... no
#0 81.29 sqlite3.h is missing. Try 'brew install sqlite3',
#0 81.29 'yum install sqlite-devel' or 'apt-get install libsqlite3-dev'
#0 81.29 and check your shared library search path (the
#0 81.29 location where your sqlite3 shared library is located).
#0 81.29 *** extconf.rb failed ***
#0 81.29 Could not create Makefile due to some reason, probably lack of necessary
#0 81.29 libraries and/or headers.  Check the mkmf.log file for more details.  You may
#0 81.29 need configuration options.
...
#0 81.29 An error occurred while installing sqlite3 (1.4.2), and Bundler cannot continue.
#0 81.29
#0 81.29 In Gemfile:
#0 81.29   sqlite3
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c bundle install &&     bundle exec bootsnap precompile --gemfile &&     rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git]: exit code: 5

When running fly doctor, everything passes:

Testing authentication token... PASSED
Testing flyctl agent... PASSED
Testing local Docker instance... PASSED
Pinging WireGuard gateway (give us a sec)... PASSED

App specific checks for congress-chart-dev:
Checking that app has ip addresses allocated... Nope
        No ip addresses assigned to this app. If the app is not intended to receive traffic, this is fine.
        Otherwise, it likely means that the services configuration is not correctly setup to receive http, tls, tcp, or udp traffic.
        https://fly.io/docs/reference/configuration/#the-services-sections
No public ipv4 or ipv6 ip addresses allocated to app congress-chart-dev

Build checks for congress-chart-dev:
Checking docker context size (this may take little bit)... PASSED (170 kB)
Checking for .dockerignore... PASSED

I have tried installing sqlite3 separately and then running bundle install, but have had no luck. I also edited the Gemfile to have the following line:

gem 'sqlite3', '~> 1.4', '>= 1.4.2'

Any suggestions on what to do would be very helpful.

Hey there,

I’m not well-versed when it comes to Rails, however I did find something pretty similar to the error you received, and I’m wondering if it would help.

I’m not sure what is making your Rails app different than other Rails apps that use sqlite3, but you can get dockerfile-rails to propose changes to your dockerfile to address this using:

bin/rails generate dockerfile --add-build=libsqlite3-dev
2 Likes

This seemed to fix the issue with sqlite3, (although I can’t tell if it actually made it to the step where it mattered), as it now fails when trying to download node-v12.22.9-linux-x64.tar.gz:

=> ERROR [build  2/10] RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C   222.0s
------
 > [build  2/10] RUN curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ &&     /tmp/node-build-master/bin/node-build "12.22.9" /usr/local/node &&     npm install -g yarn@1.22.19 &&     rm -rf /tmp/node-build-master:
#0 0.925 Downloading node-v12.22.9-linux-x64.tar.gz...
#0 0.925 -> https://nodejs.org/dist/v12.22.9/node-v12.22.9-linux-x64.tar.gz
#0 222.0 error: failed to download node-v12.22.9-linux-x64.tar.gz
#0 222.0
#0 222.0 BUILD FAILED (Debian GNU/Linux 11 using node-build 4.9.128)
#0 222.0
#0 222.0 Binary installation failed; try compiling from source with `--compile` flag
#0 222.0
#0 222.0 Inspect or clean up the working tree at /tmp/node-build.20231024133432.14.u3lIRI
#0 222.0 Results logged to /tmp/node-build.20231024133432.14.log
#0 222.0
#0 222.0 Last 10 log lines:
#0 222.0 /tmp/node-build.20231024133432.14.u3lIRI /rails
#0 222.0 curl: (18) transfer closed with 19490382 bytes remaining to read
------
Error: failed to fetch an image or build from source: error building: failed to solve: executor failed running [/bin/sh -c curl -sL https://github.com/nodenv/node-build/archive/master.tar.gz | tar xz -C /tmp/ &&     /tmp/node-build-master/bin/node-build "${NODE_VERSION}" /usr/local/node &&     npm install -g yarn@$YARN_VERSION &&     rm -rf /tmp/node-build-master]: exit code: 1

I did check out this issue originally, but after looking in my Gemfile, the source is correct. (https://rubygems.org)

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.