【초학자용】Ruby3.0, Rails6.1.3, MySQL로 Heroku 배포와 격투한 이야기

본 기사는 필자 최초 투고로 보기 흉한 점 있다고 생각합니다! 양해 바랍니다
포트폴리오의 기초 기능 완성 후, heroku 배포에 주저했기 때문에 비망록으로 기록합니다.

개발 환경


  • macOS Mojave 10.14.6
  • Ruby3.0 → 나중에 2.7.2로 버전 다운
  • Rails6.1.3
  • DB MySQL8.0

  • 결론



    Ruby 버전을 3.0 → 2.7.2로 낮추고 오류를 제거하면서 배포

    일어난 일



    포트폴리오를 heroku 배포하는 동안 오류가,,,

    terminal
    
    remote: -----> Installing bundler 2.2.11
    remote: -----> Removing BUNDLED WITH version in the Gemfile.lock
    remote: -----> Compiling Ruby/Rails
    remote: -----> Using Ruby version: ruby-3.0.0
    remote: -----> Installing dependencies using bundler 2.2.11
    remote:        Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
    remote:        Your bundle only supports platforms ["x86_64-darwin-20"] but your local platform
    remote:        is x86_64-linux. Add the current platform to the lockfile with `bundle lock
    remote:        --add-platform x86_64-linux` and try again.
    remote:        Bundler Output: Your bundle only supports platforms ["x86_64-darwin-20"] but your local platform
    remote:        is x86_64-linux. Add the current platform to the lockfile with `bundle lock
    remote:        --add-platform x86_64-linux` and try again.
    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: ! Failed to install gems via Bundler. 에서 조사하면 Heroku측과 local에서 사용하고 있는 Bundler의 버젼에 있어서 local측의 버젼이 높으면 에러를 토한다는 기사를 발견했다. 따라서 Bundler 버전 확인.

    terminal
    $ bundle -v
    Bundler version 2.2.11
    

    특히 버전의 차이도 없고 에러 해소에는 이르지 않는다.$ gem list bundle 를 봐도 다른 버전은 보이지 않는다.
    다른 기사에서 성공했던 것처럼, Bundler의 버전을 2.1.4로 낮추어도 같은 에러를 뱉는다.

    해결에



    Google 선생님이 에러 문장을 그대로 붙여넣고 검색 기간을 1개월 이내에 좁히기 기사를 잡고 있던 곳 stackoverflow에 비슷한 오류로 고민하는 것이. 답변을 보면 ,,,

    Seem you have error in your ruby ​​versions, please check by changing ruby ​​version to 2.7.2 in your Gemfile and install localy same version.

    3.0은 지원되지 않는 것으로 판명. 로컬 버전 변경, gem 다시 bundle $ git push heroku master 실행.
    ※사전에 아래와 같은 기사를 참고로 heroku에의 어플리 작성과 DB설정 완료.
    htps : // 이 m / 무라카미 m / ms / 9587 에 21fc0 에 d57c803d0

    도중에 에러를 토했지만 여기도 선인의 분들의 힘을 빌려 클리어.
    htps : // m / zy zy1031 / ms / 64598d44b428d cd7 a bc5

    terminal
    ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
    remote:        /tmp/build_f57de2e7/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3/lib/active_support/message_encryptor.rb:203:in `rescue in _decrypt'
    remote:        /tmp/build_f57de2e7/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3/lib/active_support/message_encryptor.rb:180:in `_decrypt'
    remote:        /tmp/build_f57de2e7/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3/lib/active_support/message_encryptor.rb:154:in `decrypt_and_verify'
    remote:        /tmp/build_f57de2e7/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3/lib/active_support/messages/rotator.rb:22:in `decrypt_and_verify'
    remote:        /tmp/build_f57de2e7/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3/lib/active_support/encrypted_file.rb:92:in `decrypt'
    remote:        /tmp/build_f57de2e7/vendor/bundle/ruby/2.7.0/gems/activesupport-6.1.3/lib/active_support/encrypted_file.rb:54:in `read'
    remote:        /tmp/build_f57de2e
    ---- 以下省略 ----
    

    위의 오류를 지우고 무사히 푸시 완료.
    마지막으로 $ heroku run rails db:migrate 에서 무사히 heroku에 배포할 수 있었습니다!

    마지막으로



    Ruby의 버전 자체가 오류의 요인이었기 때문에, gem이나 툴의 의존관계, 공식의 가이드를 지금까지 이상으로 조사하는, 「원래」를 의심하는 리서치 능력을 보다 닦아 가고 싶었습니다! 이 기사가 누군가의 도움이되면 다행입니다. 여기까지 읽어 주셔서 감사합니다.

    좋은 웹페이지 즐겨찾기