ruby-on-rails - Heroku:在推送到 Heroku 期间,无法在 MacOS 上的 Rails 6 中通过 Bundler 安装 gem
问题描述
我正在尝试使用 Git 在 heroku 上推送我的 rails 6 (6.1.3.1) 应用程序。我正在使用heroku CLI。在开发中一切都很好,但是每次我尝试将应用程序推送到 heroku 时都会出现此错误。我更新了 bundler,复制了 gemfile.lock,然后提交到了 github。但是在git push heroku master之后仍然出现这个错误
这是我的 Gemfile
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '3.0.1'
gem 'rails', '~> 6.1.3', '>= 6.1.3.1'
gem 'pg', '~> 1.2', '>= 1.2.3'
gem 'puma', '~> 5.0'
gem 'sass-rails', '>= 6'
gem 'webpacker', '~> 5.0'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.7'
gem 'bootsnap', '>= 1.4.4', require: false
group :development, :test do
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
gem 'web-console', '>= 4.1.0'
gem 'rack-mini-profiler', '~> 2.0'
gem 'listen', '~> 3.3'
gem 'spring'
end
group :test do
gem 'capybara', '>= 3.26'
gem 'selenium-webdriver'
gem 'webdrivers'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
gem 'dotenv-rails', '~> 2.7', '>= 2.7.6'
终端输出: 终端
Heroku 构建日志:
-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
!Warning: Multiple default buildpacks reported the ability to handle this app. The first
buildpack in the list below will be used.
Detected buildpacks: Ruby,Node.js
See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
-----> Ruby app detected
-----> Installing bundler 2.2.16
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.0.1
-----> Installing dependencies using bundler 2.2.16
Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle
BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
Your bundle only supports platforms ["x86_64-darwin-17"] but your local platform
is x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
Bundler Output: Your bundle only supports platforms ["x86_64-darwin-17"] but your local
platform
is x86_64-linux. Add the current platform to the lockfile with `bundle lock
--add-platform x86_64-linux` and try again.
!
! Failed to install gems via Bundler.
!
! Push rejected, failed to compile Ruby app.
! Push failed
我的 Ruby 版本是 3.0.1,我使用的是 MacOS High Sierra 10.13.6
请帮我
解决方案
我已经成功地解决了这个问题。问题是平台。所以我运行这两个命令并修复了这个:
bundle lock --add-platform ruby
bundle lock --add-platform x86_64-linux
推荐阅读
- javascript - 为什么从无限while循环内部调用setTimeout时不会被调用
- python - 当前行时间戳的 1 秒内的总和值
- html - 响应式 SVG 视图框
- neo4j - Neo4j LOAD CSV 无法匹配和创建关系
- php - 在codeigniter中按日期时间分组
- python - 如何增加 Sentry 中捕获的 Python 参数的最大长度?
- powerbi - 创建每周过滤器的 6 个月滚动平均值
- excel - 选择 1 个单元格向上的范围 excel powershell
- java - 无法在另一个包中加载 FXML (JavaFX)
- mysql - 关于mysql select和update嵌套有数据报错麻烦