每当我尝试在 Netlify 上部署我的网站时,它总是在
Initializing
阶段失败。我尝试在计算机上重新安装 Ruby,重新安装所有 gem,然后将更新推送到我的 Github 存储库,但仍然出现以下错误。如何更新 Jekyll 项目中的 Ruby,以便将其部署到 Netlify 上?
3:25:44 PM: Starting to install dependencies
3:25:45 PM: Python version set to 3.8
3:25:45 PM: Attempting Ruby version 2.7.2, read from environment
3:25:46 PM: Using Ruby version 2.7.2
3:25:46 PM: Using Bundler version 2.5.10 from Gemfile.lock
3:25:58 PM: ERROR: Error installing bundler:
3:25:58 PM: There are no versions of bundler (= 2.5.10) compatible with your Ruby & RubyGems
3:25:58 PM: bundler requires Ruby version >= 3.0.0. The current ruby version is 2.7.2.137.
3:25:59 PM: Error installing Bundler
3:25:59 PM: Failing build: Failed to install dependencies
3:25:59 PM: Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code: 1
我通过在项目根目录中创建一个
.ruby-version
文件并指定 ruby 版本解决了这个问题。
在我的 .ruby-version 文件中,我将其放在
.ruby version
文件的第一行:
3.2.0
然后推送更改,网站就能够在 Netlify 上成功初始化并构建。