dev-g
August 6, 2025, 3:37am
1
Hello everyone,
Can someone help me resolve this issue:
Error: failed to fetch an image or build from source: error building: failed to solve: process "/bin/sh -c bundle install && bundle exec bootsnap precompile --gemfile && rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git" did not complete successfully: exit code: 18
I ran the bundle commands, but I’m running windows so I couldn’t run the last part and the build still fails.
Thanks
rubys
August 6, 2025, 12:41pm
2
Need more logs.
rm -rf
pretty much never fails so the problem is almost certainly one of the bundle commands. You likely have some gem or configuration that works on Windows but not on Linux. The logs will provide more insight as to where the real problem is.
dev-g
August 8, 2025, 1:23am
3
Thanks @rubys for the quick reply. Here is the full error message
==> Building image
Waiting for depot builder...
Waiting for depot builder...
Waiting for depot builder...
Waiting for depot builder...
Waiting for depot builder...
Waiting for depot builder...
==> Building image with Depot
--> build: ()
[+] Building 2.4s (15/22)
=> [internal] load build definition from Dockerfile 0.2s
=> => transferring dockerfile: 2.47kB 0.2s
=> resolve image config for docker-image://docker.io/docker/dockerfile:1 0.1s
=> CACHED docker-image://docker.io/docker/dockerfile:1@sha256:38387523653efa0039f8e1c89bb74a30504e76ee9f565e25c9a09841f9427b05 0.0s
=> => resolve docker.io/docker/dockerfile:1@sha256:38387523653efa0039f8e1c89bb74a30504e76ee9f565e25c9a09841f9427b05 0.0s
=> [internal] load build definition from Dockerfile 0.0s
=> => Deduplicating step ID [internal] load build definition from Dockerfile, another build is calculating it 0.0s
=> WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 5) 0.0s
=> WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 24) 0.0s
=> [internal] load metadata for docker.io/library/ruby:3.1.3-slim 0.1s
=> [internal] load .dockerignore 0.5s
=> => transferring context: 766B 0.5s
=> [base 1/3] FROM docker.io/library/ruby:3.1.3-slim@sha256:9326196714b206561a89136b2d65957a994a37d52737cfca906a138be897fa51 0.0s
=> => resolve docker.io/library/ruby:3.1.3-slim@sha256:9326196714b206561a89136b2d65957a994a37d52737cfca906a138be897fa51 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 10.90kB 0.1s
=> CACHED [base 2/3] WORKDIR /rails 0.0s
=> CACHED [base 3/3] RUN gem update --system --no-document && gem install -N bundler 0.0s
=> CACHED [build 1/7] RUN apt-get update -qq && apt-get install --no-install-recommends -y build-essential pkg-config 0.0s
=> CACHED [build 2/7] COPY --link Gemfile Gemfile.lock ./ 0.0s
=> ERROR [build 3/7] RUN bundle install && bundle exec bootsnap precompile --gemfile && rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache 1.2s
------
> [build 3/7] RUN bundle install && bundle exec bootsnap precompile --gemfile && rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git:
0.270 Bundler 2.6.9 is running, but your lockfile was generated with 2.7.1. Installing Bundler 2.7.1 and restarting using that version.
1.010 Fetching gem metadata from https://rubygems.org/.
1.064 Your lockfile is locked to a version of bundler (2.7.1) that doesn't exist at https://rubygems.org/. Going on using 2.6.9
1.103 Your Ruby version is 3.1.3, but your Gemfile specified 3.4.5
------
Error: failed to fetch an image or build from source: error building: failed to solve: process "/bin/sh -c bundle install && bundle exec bootsnap precompile --gemfile && rm -rf ~/.bundle/ $BUNDLE_PATH/ruby/*/cache $BUNDLE_PATH/ruby/*/bundler/gems/*/.git" did not complete successfully: exit code: 18
rubys
August 8, 2025, 1:30am
4
Modify your Dockerfile
to match the Ruby version you are using locally. Specifically look for:
ARG RUBY_VERSION=3.1.3