Can not RUN rails assets:precompile on my build when use cache vendor/bundle

Hi all,
I stuck this issue in 2 days :frowning:
Really stress!
Here is my config.yml

jobs:
test_and_build:
<<: *test_and_build_container
steps:
- checkout
- <<: *setup_specific_docker
- <<: *restore_dependencies_cache
- run:
name: Install dependencies
command: |
set -x

        if [[ ! -d vendor/bundle ]]; then
          gem install bundler -v 2.0.2
          bundle check --path vendor/bundle || bundle install --jobs=4 --retry=3 --path vendor/bundle
        fi
  - save_cache:
      paths:
        - vendor/bundle
      key: v1-dependencies-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "Gemfile.lock" }}
  - <<: *push_docker_image
  - <<: *persist_artifacts

My Dockerfile:

RUN gem install rails

RUN bundle check --path vendor/bundle

RUN bundle install --jobs=4 --retry=3 --path vendor/bundle

RUN ls -la vendor/bundle

RUN rails assets:precompile

CMD [“bundle”, “exec”, “puma”, “-C”, “config/puma.rb”]

And when CircleCI run:

40 gems installed
Removing intermediate container 2234d0c693d3
—> a353860652f2
Step 11/15 : RUN bundle check --path vendor/bundle
—> Running in 8708ed438a14
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java.
The Gemfile’s dependencies are satisfied
Removing intermediate container 8708ed438a14
—> 307f6239f085
Step 12/15 : RUN bundle install --jobs=4 --retry=3 --path vendor/bundle
—> Running in 9afeffeab83c
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java.
Using rake 12.3.3
Using concurrent-ruby 1.1.5
Using i18n 1.6.0
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using zeitwerk 2.1.9
Using activesupport 6.0.0
Using builder 3.2.3
Using erubi 1.8.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.4
Using rails-dom-testing 2.0.3
Using crass 1.0.4
Using loofah 2.2.3
Using rails-html-sanitizer 1.2.0
Using actionview 6.0.0
Using rack 2.0.7
Using rack-test 1.1.0
Using actionpack 6.0.0
Using nio4r 2.4.0
Using websocket-extensions 0.1.4
Using websocket-driver 0.7.1
Using actioncable 6.0.0
Using globalid 0.4.2
Using activejob 6.0.0
Using activemodel 6.0.0
Using activerecord 6.0.0
Using mimemagic 0.3.3
Using marcel 0.3.3
Using activestorage 6.0.0
Using mini_mime 1.0.2
Using mail 2.7.1
Using actionmailbox 6.0.0
Using actionmailer 6.0.0
Using actiontext 6.0.0
Using ast 2.4.0
Using execjs 2.7.0
Using autoprefixer-rails 9.6.1
Using aws-eventstream 1.0.3
Using aws-partitions 1.203.0
Using aws-sigv4 1.1.0
Using jmespath 1.4.0
Using aws-sdk-core 3.63.0
Using aws-sdk-kms 1.24.0
Using aws-sdk-s3 1.46.0
Using bcrypt 3.1.13
Using bindex 0.8.1
Using msgpack 1.3.1
Using bootsnap 1.4.4
Using popper_js 1.14.5
Using method_source 0.9.2
Using thor 0.20.3
Using railties 6.0.0
Using ffi 1.11.1
Using sassc 2.0.1
Using sprockets 3.7.2
Using sprockets-rails 3.2.1
Using tilt 2.0.9
Using sassc-rails 2.1.2
Using bootstrap 4.3.1
Using bundler 2.0.2
Using byebug 11.0.1
Using diff-lcs 1.3
Using exception_notification 4.4.0
Using temple 0.8.1
Using hamlit 2.9.3
Using hamlit-rails 0.2.3
Using jaro_winkler 1.5.3
Using jbuilder 2.9.1
Using jquery-rails 4.3.5
Using kaminari-core 1.1.1
Using kaminari-actionview 1.1.1
Using kaminari-activerecord 1.1.1
Using kaminari 1.1.1
Using rb-fsevent 0.10.3
Using rb-inotify 0.10.0
Using ruby_dep 1.5.0
Using listen 3.1.5
Using mini_magick 4.9.5
Using parallel 1.17.0
Using parser 2.6.3.0
Using pg 1.1.4
Using puma 4.1.0
Using rails 6.0.0
Using rails-controller-testing 1.0.4
Using rainbow 3.0.0
Using rspec-support 3.8.2
Using rspec-core 3.8.2
Using rspec-expectations 3.8.4
Using rspec-mocks 3.8.1
Using rspec-rails 3.8.2
Using ruby-progressbar 1.10.1
Using unicode-display_width 1.6.0
Using rubocop 0.74.0
Using seed-fu 2.3.9
Using select2-rails 4.0.3
Using slack-notifier 2.3.2
Using spring 2.1.0
Using spring-watcher-listen 2.0.1
Using uglifier 4.1.20
Using web-console 4.0.1
Bundle complete! 29 Gemfile dependencies, 102 gems now installed.
Bundled gems are installed into ./vendor/bundle
Removing intermediate container 9afeffeab83c
—> ac2b07cbf6be
Step 13/15 : RUN ls -la vendor/bundle
—> Running in 7e21bf36b625
total 12
drwxr-xr-x 4 root root 4096 Aug 21 04:53 .
drwxr-xr-x 4 root root 4096 Aug 21 04:53 …
drwxr-xr-x 4 root root 4096 Aug 21 04:53 ruby
Removing intermediate container 7e21bf36b625
—> 15b8d148405e
Step 14/15 : RUN rails assets:precompile
—> Running in a2dbf9bf72e0
rails aborted!
> LoadError: Error loading shared library liblzma.so.5: No such file or directory (needed by /unimate-airtailor-web/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/nokogiri.so) - /unimate-airtailor-web/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.10.4/lib/nokogiri/nokogiri.so
> /unimate-airtailor-web/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in require'*** ***> /unimate-airtailor-web/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in block in require_with_bootsnap_lfi’
> /unimate-airtailor-web/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.4.4/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register’

Everything will be OK when modify Dockerfile:

RUN bundle install --jobs=4 --retry=3

without --path will make the bundle install start from begin…and take a long time for installing and my cache is useless :frowning:

Could you please help me out.