首页 > 解决方案 > 如何纠正 netlify 部署的错误

问题描述

我在部署到 netlify 时遇到了一些问题。我想用模板cayman创建一个博客

1)在本地主机中,站点可以运行

2)我在github上推送网站文件

3) 我正在将 netlify 连接到 github 存储库

4)但是部署失败


日志 :

8:46:46 AM: Fetching cached dependencies
8:46:46 AM: Failed to fetch cache, continuing with build
8:46:46 AM: Starting to prepare the repo for build
8:46:47 AM: No cached dependencies found. Cloning fresh repo
8:46:47 AM: git clone https://github.com/adrien1212/blog
8:46:47 AM: Preparing Git Reference refs/heads/master
8:46:48 AM: Starting build script
8:46:48 AM: Installing dependencies
8:46:49 AM: Downloading and installing node v8.15.0...
8:46:49 AM: Downloading https://nodejs.org/dist/v8.15.0/node-v8.15.0-linux-x64.tar.xz...
8:46:49 AM:   0.9%
8:46:49 AM: 
#################
8:46:49 AM:                                           24.3%
8:46:49 AM: 
##########################################
8:46:49 AM: #########################       94.2%
######################################################################## 100.0%
8:46:49 AM: Computing checksum with sha256sum
8:46:49 AM: Checksums matched!
8:46:51 AM: Now using node v8.15.0 (npm v6.4.1)
8:46:52 AM: Attempting ruby version 2.3.6, read from environment
8:46:53 AM: Using ruby version 2.3.6
8:46:53 AM: Using PHP version 5.6
8:46:53 AM: Started restoring cached ruby gems
8:46:53 AM: Finished restoring cached ruby gems
8:46:53 AM: Installing gem bundle
8:46:53 AM: You must use Bundler 2 or greater with this lockfile.
8:46:53 AM: Error during gem install
8:46:53 AM: Error running command: Build script returned non-zero exit code: 1
8:46:53 AM: Failing build: Failed to build site
8:46:53 AM: failed during stage 'building site': Build script returned non-zero exit code: 1
8:46:53 AM: Finished processing build request in 7.611237844s

我认为问题将来自这里。

8:46:53 AM: Using ruby version 2.3.6
8:46:53 AM: Using PHP version 5.6

8:46:53 AM: You must use Bundler 2 or greater with this lockfile.

但我不知道如何解决它们。你可以帮助我 ?

标签: web-deploymentnetlify

解决方案


在 Netlify 上更改 ruby​​ 版本的方法:

.ruby-version文件添加到存储库的根目录

.ruby-version(没有最后的换行符)
2.4.3

您可以改为使用 RUBY_VERSION 环境变量,在 Netlify 的 UI 中的构建和部署设置或netlify.toml(根据 Netlify 支持)中设置

注意:您可以从rvm's支持的版本中进行选择。

查看捆绑器的版本

更改 Netlify 上的构建命令以输出捆绑信息:

用于bundle env && <your build command here>构建命令

12:51:50 PM: Executing user command: bundle env && yarn build
12:51:50 PM: ## Environment
12:51:50 PM: ```
12:51:50 PM: Bundler             1.17.1
12:51:50 PM:   Platforms         ruby, x86_64-linux
12:51:50 PM: Ruby                2.4.3p205 (2017-12-14 revision 61247) [x86_64-linux]
12:51:50 PM:   Full Path         /opt/buildhome/.rvm/rubies/ruby-2.4.3/bin/ruby
12:51:50 PM:   Config Dir        /etc
12:51:50 PM: RubyGems            2.6.14
12:51:50 PM:   Gem Home          /opt/buildhome/.rvm/gems/ruby-2.4.3
12:51:50 PM:   Gem Path          /opt/buildhome/.rvm/gems/ruby-2.4.3:/opt/buildhome/.rvm/gems/ruby-2.4.3@global
12:51:50 PM:   User Path         /opt/buildhome/.gem/ruby/2.4.0
12:51:50 PM:   Bin Dir           /opt/buildhome/.rvm/gems/ruby-2.4.3/bin
12:51:50 PM: Tools
12:51:50 PM:   Git               2.19.1
12:51:50 PM:   RVM               1.29.4 (latest)
12:51:50 PM:   rbenv             not installed
12:51:50 PM:   chruby            not installed
12:51:50 PM:   rubygems-bundler  (1.4.5)
12:51:50 PM: ```

推荐阅读