Развертывание Rails Heroku не удалось: не удалось найти драгоценные камни, не удалось установить драгоценные камни через Bundler

Итак, у меня есть приложение Rails, которое я пытаюсь отправить в Heroku. Когда я запускаю git push heroku master, я получаю:

$ git push heroku master
Enumerating objects: 1369, done.
Counting objects: 100% (1369/1369), done.
Delta compression using up to 12 threads
Compressing objects: 100% (906/906), done.
Writing objects: 100% (1369/1369), 35.15 MiB | 1.66 MiB/s, done.
Total 1369 (delta 755), reused 829 (delta 398), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (755/755), done.
remote: Updated 169 paths from d8b5ada
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpack: heroku/ruby
remote: -----> Ruby app detected
remote: -----> Installing bundler 2.5.6
remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-3.2.2
remote: -----> Installing dependencies using bundler 2.5.6
remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
remote:        Could not find rails-7.1.3.4, sprockets-rails-3.5.1, pg-1.5.6, puma-6.0.2,
remote:        importmap-rails-2.0.1, turbo-rails-2.0.5, stimulus-rails-1.3.3, jbuilder-2.12.0,
remote:        tzinfo-data-1.2024.1, bootsnap-1.18.3, sendgrid-ruby-6.7.0, devise-4.9.4,
remote:        letter_opener-1.10.0, activerecord-7.1.3.4, actiontext-7.1.3.4,
remote:        htmlbeautifier-1.4.3, base64-0.2.0, bigdecimal-3.1.8, mutex_m-0.2.0,
remote:        tailwindcss-rails-2.6.1, actioncable-7.1.3.4, actionmailbox-7.1.3.4,
remote:        actionmailer-7.1.3.4, actionpack-7.1.3.4, actionview-7.1.3.4, activejob-7.1.3.4,
remote:        activemodel-7.1.3.4, activestorage-7.1.3.4, activesupport-7.1.3.4,
remote:        railties-7.1.3.4, sprockets-4.2.1, nio4r-2.7.3, tzinfo-2.0.6, msgpack-1.7.2,
remote:        ruby_http_client-3.5.5, bcrypt-3.1.20, responders-3.1.1, launchy-3.0.1,
remote:        timeout-0.4.1, globalid-1.2.1, nokogiri-1.16.6, mini_magick-4.13.1,
remote:        ruby-vips-2.2.1, websocket-driver-0.7.6, zeitwerk-2.6.16, mail-2.8.1,
remote:        net-imap-0.4.14, net-smtp-0.5.0, rails-dom-testing-2.2.0, racc-1.8.0,
remote:        rack-3.1.6, rack-session-2.0.0, rack-test-2.1.0, rails-html-sanitizer-1.6.0,
remote:        builder-3.3.0, erubi-1.13.0, marcel-1.0.4, concurrent-ruby-1.3.3,
remote:        connection_pool-2.4.1, drb-2.2.1, i18n-1.14.5, minitest-5.24.1, irb-1.13.2,
remote:        rackup-2.1.0, rake-13.2.1, thor-1.3.1, addressable-2.8.7, childprocess-5.0.0,
remote:        mini_portile2-2.8.7, ffi-1.17.0, mini_mime-1.1.5, date-3.3.4,
remote:        net-protocol-0.2.2, loofah-2.22.0, rdoc-6.7.0, reline-0.5.9, webrick-1.8.1,
remote:        public_suffix-6.0.0, psych-5.1.2, io-console-0.7.2, stringio-3.1.1 in cached
remote:        gems or installed locally
remote:        Bundler Output: Could not find rails-7.1.3.4, sprockets-rails-3.5.1, pg-1.5.6, puma-6.0.2,
remote:        importmap-rails-2.0.1, turbo-rails-2.0.5, stimulus-rails-1.3.3, jbuilder-2.12.0,
remote:        tzinfo-data-1.2024.1, bootsnap-1.18.3, sendgrid-ruby-6.7.0, devise-4.9.4,
remote:        letter_opener-1.10.0, activerecord-7.1.3.4, actiontext-7.1.3.4,
remote:        htmlbeautifier-1.4.3, base64-0.2.0, bigdecimal-3.1.8, mutex_m-0.2.0,
remote:        tailwindcss-rails-2.6.1, actioncable-7.1.3.4, actionmailbox-7.1.3.4,
remote:        actionmailer-7.1.3.4, actionpack-7.1.3.4, actionview-7.1.3.4, activejob-7.1.3.4,
remote:        activemodel-7.1.3.4, activestorage-7.1.3.4, activesupport-7.1.3.4,
remote:        railties-7.1.3.4, sprockets-4.2.1, nio4r-2.7.3, tzinfo-2.0.6, msgpack-1.7.2,
remote:        ruby_http_client-3.5.5, bcrypt-3.1.20, responders-3.1.1, launchy-3.0.1,
remote:        timeout-0.4.1, globalid-1.2.1, nokogiri-1.16.6, mini_magick-4.13.1,
remote:        ruby-vips-2.2.1, websocket-driver-0.7.6, zeitwerk-2.6.16, mail-2.8.1,
remote:        net-imap-0.4.14, net-smtp-0.5.0, rails-dom-testing-2.2.0, racc-1.8.0,
remote:        rack-3.1.6, rack-session-2.0.0, rack-test-2.1.0, rails-html-sanitizer-1.6.0,
remote:        builder-3.3.0, erubi-1.13.0, marcel-1.0.4, concurrent-ruby-1.3.3,
remote:        connection_pool-2.4.1, drb-2.2.1, i18n-1.14.5, minitest-5.24.1, irb-1.13.2,
remote:        rackup-2.1.0, rake-13.2.1, thor-1.3.1, addressable-2.8.7, childprocess-5.0.0,
remote:        mini_portile2-2.8.7, ffi-1.17.0, mini_mime-1.1.5, date-3.3.4,
remote:        net-protocol-0.2.2, loofah-2.22.0, rdoc-6.7.0, reline-0.5.9, webrick-1.8.1,
remote:        public_suffix-6.0.0, psych-5.1.2, io-console-0.7.2, stringio-3.1.1 in cached
remote:        gems or installed locally
remote: 
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to *****.
remote: 
To https://git.heroku.com/*****.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/*****.git'

Я попробовал решения, найденные в этом вопросе, но ничего не помогло (я получаю ту же ошибку). На моей локальной машине все работает нормально, поэтому я не знаю, почему она не работает на Heroku.

Я также хочу спросить: вы должны запускать команды, найденные в этом вопросе, со своего локального сервера или из оболочки Heroku для вашего приложения? Потому что я пробовал запускать команды из оболочки Heroku, но безрезультатно:

$ heroku run bash --app *****
Running bash on ⬢ *****... up, run.4316 (Basic)
~ $ bundle install
bash: bundle: command not found

Вот мой драгоценный файл:

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '3.2.2'

# Core Rails gems
gem "rails", "~> 7.1.3", ">= 7.1.3.4"
gem "sprockets-rails"
gem "pg", "~> 1.1"
gem 'puma', '~> 6.0.0'
gem "importmap-rails"
gem "turbo-rails"
gem "stimulus-rails"
gem "jbuilder"
gem "tzinfo-data" # Removed platforms as Heroku uses Linux
gem "bootsnap", require: false
gem 'sendgrid-ruby'

# Other gems
gem "devise", "~> 4.8", ">= 4.8.1"
gem "letter_opener"
gem "activerecord"
gem 'actiontext', '7.1.3.4'
gem "htmlbeautifier"
gem "base64"
gem "bigdecimal"
gem "mutex_m"
gem "image_processing", "~> 1.2"
gem 'tailwindcss-rails'
# gem "bundler", '2.5.13'

# Development and test-specific gems
group :development, :test do
  gem "rufo"
  gem 'dotenv-rails'
end

group :development do
  gem "web-console"
end

group :test do
  gem "capybara"
  gem "selenium-webdriver"
  gem "webdrivers"
end

И вот мой gemfile.lock:

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (7.1.3.4)
      actionpack (= 7.1.3.4)
      activesupport (= 7.1.3.4)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
      zeitwerk (~> 2.6)
    actionmailbox (7.1.3.4)
      actionpack (= 7.1.3.4)
      activejob (= 7.1.3.4)
      activerecord (= 7.1.3.4)
      activestorage (= 7.1.3.4)
      activesupport (= 7.1.3.4)
      mail (>= 2.7.1)
      net-imap
      net-pop
      net-smtp
    actionmailer (7.1.3.4)
      actionpack (= 7.1.3.4)
      actionview (= 7.1.3.4)
      activejob (= 7.1.3.4)
      activesupport (= 7.1.3.4)
      mail (~> 2.5, >= 2.5.4)
      net-imap
      net-pop
      net-smtp
      rails-dom-testing (~> 2.2)
    actionpack (7.1.3.4)
      actionview (= 7.1.3.4)
      activesupport (= 7.1.3.4)
      nokogiri (>= 1.8.5)
      racc
      rack (>= 2.2.4)
      rack-session (>= 1.0.1)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.2)
      rails-html-sanitizer (~> 1.6)
    actiontext (7.1.3.4)
      actionpack (= 7.1.3.4)
      activerecord (= 7.1.3.4)
      activestorage (= 7.1.3.4)
      activesupport (= 7.1.3.4)
      globalid (>= 0.6.0)
      nokogiri (>= 1.8.5)
    actionview (7.1.3.4)
      activesupport (= 7.1.3.4)
      builder (~> 3.1)
      erubi (~> 1.11)
      rails-dom-testing (~> 2.2)
      rails-html-sanitizer (~> 1.6)
    activejob (7.1.3.4)
      activesupport (= 7.1.3.4)
      globalid (>= 0.3.6)
    activemodel (7.1.3.4)
      activesupport (= 7.1.3.4)
    activerecord (7.1.3.4)
      activemodel (= 7.1.3.4)
      activesupport (= 7.1.3.4)
      timeout (>= 0.4.0)
    activestorage (7.1.3.4)
      actionpack (= 7.1.3.4)
      activejob (= 7.1.3.4)
      activerecord (= 7.1.3.4)
      activesupport (= 7.1.3.4)
      marcel (~> 1.0)
    activesupport (7.1.3.4)
      base64
      bigdecimal
      concurrent-ruby (~> 1.0, >= 1.0.2)
      connection_pool (>= 2.2.5)
      drb
      i18n (>= 1.6, < 2)
      minitest (>= 5.1)
      mutex_m
      tzinfo (~> 2.0)
    addressable (2.8.7)
      public_suffix (>= 2.0.2, < 7.0)
    base64 (0.2.0)
    bcrypt (3.1.20)
    bigdecimal (3.1.8)
    bindex (0.8.1)
    bootsnap (1.18.3)
      msgpack (~> 1.2)
    builder (3.3.0)
    capybara (3.40.0)
      addressable
      matrix
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.11)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      regexp_parser (>= 1.5, < 3.0)
      xpath (~> 3.2)
    childprocess (5.0.0)
    concurrent-ruby (1.3.3)
    connection_pool (2.4.1)
    crass (1.0.6)
    date (3.3.4)
    devise (4.9.4)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 4.1.0)
      responders
      warden (~> 1.2.3)
    dotenv (3.1.2)
    dotenv-rails (3.1.2)
      dotenv (= 3.1.2)
      railties (>= 6.1)
    drb (2.2.1)
    erubi (1.13.0)
    ffi (1.17.0)
    globalid (1.2.1)
      activesupport (>= 6.1)
    htmlbeautifier (1.4.3)
    i18n (1.14.5)
      concurrent-ruby (~> 1.0)
    image_processing (1.12.2)
      mini_magick (>= 4.9.5, < 5)
      ruby-vips (>= 2.0.17, < 3)
    importmap-rails (2.0.1)
      actionpack (>= 6.0.0)
      activesupport (>= 6.0.0)
      railties (>= 6.0.0)
    io-console (0.7.2)
    irb (1.13.2)
      rdoc (>= 4.0.0)
      reline (>= 0.4.2)
    jbuilder (2.12.0)
      actionview (>= 5.0.0)
      activesupport (>= 5.0.0)
    launchy (3.0.1)
      addressable (~> 2.8)
      childprocess (~> 5.0)
    letter_opener (1.10.0)
      launchy (>= 2.2, < 4)
    loofah (2.22.0)
      crass (~> 1.0.2)
      nokogiri (>= 1.12.0)
    mail (2.8.1)
      mini_mime (>= 0.1.1)
      net-imap
      net-pop
      net-smtp
    marcel (1.0.4)
    matrix (0.4.2)
    mini_magick (4.13.1)
    mini_mime (1.1.5)
    mini_portile2 (2.8.7)
    minitest (5.24.1)
    msgpack (1.7.2)
    mutex_m (0.2.0)
    net-imap (0.4.14)
      date
      net-protocol
    net-pop (0.1.2)
      net-protocol
    net-protocol (0.2.2)
      timeout
    net-smtp (0.5.0)
      net-protocol
    nio4r (2.7.3)
    nokogiri (1.16.6)
      mini_portile2 (~> 2.8.2)
      racc (~> 1.4)
    orm_adapter (0.5.0)
    pg (1.5.6)
    psych (5.1.2)
      stringio
    public_suffix (6.0.0)
    puma (6.0.2)
      nio4r (~> 2.0)
    racc (1.8.0)
    rack (3.1.6)
    rack-session (2.0.0)
      rack (>= 3.0.0)
    rack-test (2.1.0)
      rack (>= 1.3)
    rackup (2.1.0)
      rack (>= 3)
      webrick (~> 1.8)
    rails (7.1.3.4)
      actioncable (= 7.1.3.4)
      actionmailbox (= 7.1.3.4)
      actionmailer (= 7.1.3.4)
      actionpack (= 7.1.3.4)
      actiontext (= 7.1.3.4)
      actionview (= 7.1.3.4)
      activejob (= 7.1.3.4)
      activemodel (= 7.1.3.4)
      activerecord (= 7.1.3.4)
      activestorage (= 7.1.3.4)
      activesupport (= 7.1.3.4)
      bundler (>= 1.15.0)
      railties (= 7.1.3.4)
    rails-dom-testing (2.2.0)
      activesupport (>= 5.0.0)
      minitest
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.6.0)
      loofah (~> 2.21)
      nokogiri (~> 1.14)
    railties (7.1.3.4)
      actionpack (= 7.1.3.4)
      activesupport (= 7.1.3.4)
      irb
      rackup (>= 1.0.0)
      rake (>= 12.2)
      thor (~> 1.0, >= 1.2.2)
      zeitwerk (~> 2.6)
    rake (13.2.1)
    rdoc (6.7.0)
      psych (>= 4.0.0)
    regexp_parser (2.9.2)
    reline (0.5.9)
      io-console (~> 0.5)
    responders (3.1.1)
      actionpack (>= 5.2)
      railties (>= 5.2)
    rexml (3.3.1)
      strscan
    ruby-vips (2.2.1)
      ffi (~> 1.12)
    ruby_http_client (3.5.5)
    rubyzip (2.3.2)
    rufo (0.18.0)
    selenium-webdriver (4.10.0)
      rexml (~> 3.2, >= 3.2.5)
      rubyzip (>= 1.2.2, < 3.0)
      websocket (~> 1.0)
    sendgrid-ruby (6.7.0)
      ruby_http_client (~> 3.4)
    sprockets (4.2.1)
      concurrent-ruby (~> 1.0)
      rack (>= 2.2.4, < 4)
    sprockets-rails (3.5.1)
      actionpack (>= 6.1)
      activesupport (>= 6.1)
      sprockets (>= 3.0.0)
    stimulus-rails (1.3.3)
      railties (>= 6.0.0)
    stringio (3.1.1)
    strscan (3.1.0)
    tailwindcss-rails (2.6.1)
      railties (>= 7.0.0)
    thor (1.3.1)
    timeout (0.4.1)
    turbo-rails (2.0.5)
      actionpack (>= 6.0.0)
      activejob (>= 6.0.0)
      railties (>= 6.0.0)
    tzinfo (2.0.6)
      concurrent-ruby (~> 1.0)
    tzinfo-data (1.2024.1)
      tzinfo (>= 1.0.0)
    warden (1.2.9)
      rack (>= 2.0.9)
    web-console (4.2.1)
      actionview (>= 6.0.0)
      activemodel (>= 6.0.0)
      bindex (>= 0.4.0)
      railties (>= 6.0.0)
    webdrivers (5.3.1)
      nokogiri (~> 1.6)
      rubyzip (>= 1.3.0)
      selenium-webdriver (~> 4.0, < 4.11)
    webrick (1.8.1)
    websocket (1.2.10)
    websocket-driver (0.7.6)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.5)
    xpath (3.2.0)
      nokogiri (~> 1.8)
    zeitwerk (2.6.16)

PLATFORMS
  ruby

DEPENDENCIES
  actiontext (= 7.1.3.4)
  activerecord
  base64
  bigdecimal
  bootsnap
  capybara
  devise (~> 4.8, >= 4.8.1)
  dotenv-rails
  htmlbeautifier
  image_processing (~> 1.2)
  importmap-rails
  jbuilder
  letter_opener
  mutex_m
  pg (~> 1.1)
  puma (~> 6.0.0)
  rails (~> 7.1.3, >= 7.1.3.4)
  rufo
  selenium-webdriver
  sendgrid-ruby
  sprockets-rails
  stimulus-rails
  tailwindcss-rails
  turbo-rails
  tzinfo-data
  web-console
  webdrivers

RUBY VERSION
   ruby 3.2.2p53

BUNDLED WITH
   2.5.14

Примечание. Я попробовал добавить x86_64-linux под платформами в свой gemfile.lock, затем запустить bundle install, затем git push heroku master, но это все равно не сработало.

Я также попробовал заменить BUNDLED WITH в своем Gemfile.lock на:

BUNDLED WITH
   2.3.25

и совершение и подталкивание, но все та же проблема.

🤔 А знаете ли вы, что...
Этот фреймворк поддерживает TDD (Test-Driven Development) и BDD (Behavior-Driven Development) с помощью фреймворков RSpec и Cucumber.


174
1

Ответ:

Решено

При развертывании Ruby on Rails на Heroku и получении сообщения об ошибке от Bundler, которое сообщает об этом Could not find <list of gem> in cached gems or installed locally, это может быть вызвано различными причинами:

  1. Папка vendor/cache в репозитории приложения.

    Если в репозитории приложения есть папка vendor/cache, Bundler попытается установить драгоценный камень из этого репозитория. Если репозиторий пуст, в нем отсутствуют драгоценные камни или включены только драгоценные камни, установленные на другой платформе, произойдет сбой.

    Чтобы это исправить, попробуйте удалить подпапку cache в vendor перед развертыванием.

  2. Bundler не настроен для установки драгоценных камней для платформы, используемой на Heroku.

    Цитата из документации Heroku об использовании Bundler:

    Gemfile.lock приложения, созданный локально с помощью Bundler 2.2.3, может не работать на Heroku, если платформа Linux явно не «заблокирована»:

    $ bundle lock --add-platform ruby
    $ bundle lock --add-platform x86_64-linux
    $ bundle install
    $ git add . ; git commit -m "Bundler fix"
    

    Добавление отсутствующей платформы с помощью bundle lock --add-platform x86_64-linux, повторный запуск bundle install, а затем фиксация изменений в git и отправка в Heroku может решить проблему.