【问题标题】:Jekyll site deployment to Netlify - Error gem bundle install (use Bundler 2 or >) / Failing buildJekyll 站点部署到 Netlify - 错误 gem bundle install (use Bundler 2 or >) / Failing build
【发布时间】:2019-07-10 15:54:31
【问题描述】:

我正在使用 Cloud9 和 GitHub(私人存储库)。我已经能够将基本登录页面部署到 Netlify,但是当我尝试部署 任何 Jekyll 站点时,我不断收到相同的错误消息。部署日志的片段:

> Installing gem bundle  
> You must use Bundler 2 or greater with this lockfile.  
> Error during gem install  
> failed during stage 'building site': Build script returned non-zero exit code: 1  
> Error running command: Build script returned non-zero exit code: 1  
> Failing build: Failed to build site

经过多次失败的尝试,我创建了一个新的测试开发环境。根据 Jekyll 文档,我确保我拥有最新的 Ruby、RubyGems、gcc、g++、make 和依赖项。做了通常的配置,然后 Jekyll 新的 test_directory。步骤:

> gem install jekyll bundler  
> gem install bundle  
> gem update --system  
> cd new_directory && bundle install
> ~/new_directory/ bundle update  
> ~/new_directory/ bundle exec jekyll serve  
*** Works perfectly on localhost *** 

此时一切看起来都很好(jekyll 3.8.5 - gem 3.0.2 - ruby​​ 2.5.1p57(2018-03-29 修订版 63029)[x86_64-linux])
重要提示:

> bundler -v  
returns  
> Bundler version 2.0.1

在我推送到全新的 repo 后,我收到与上面相同的错误消息:
“将 Bundler 2 或更高版本用于此锁定文件”

来自锁文件的片段:

> DEPENDENCIES  
> -jekyll (~> 3.8.5)  
> -jekyll-feed (~> 0.6)  
> -minima (~> 2.0)  
> -tzinfo-data  
> RUBY VERSION  
> ruby 2.5.1p57  
> BUNDLED WITH  
> 2.0.1  

我也将此添加到 _config.yml 文件中:

> url: "https://infallible-hodgkin-e15692.netlify.com/"

根据 Netlify 文档,我在根目录中添加了一个 /.ruby-version 文件,其中包含以下行:

> ruby 2.5.1

更新所有内容并使用 git push 后,它仍然无法构建我的网站,但这次我在部署日志上看到了几行新行:

>** WARNING **  
> Using custom ruby version ruby 2.5.1, this will slow down the build.  
> To ensure fast builds, set the RUBY_VERSION environment variable, or .ruby-version file, to an included ruby version.  
> Included versions: 2.3.6 2.4.3 2.2.9

不用说,我尝试切换到每个“包含”的 Ruby -v(rvm 使用 ..*)。经历了安装每个版本的过程,并且每次都重复上述步骤。没有运气。

非常感谢任何有关下一步尝试的建议。抱歉,这篇文章很长,我尽量简洁。如果我遗漏了什么,请告诉我。

【问题讨论】:

    标签: github rubygems jekyll bundler netlify


    【解决方案1】:

    所以问题是我应该一直使用 Bundle 1 而不是 Bundle 2 加上 ruby​​ 2.3.6。确保您使用的是捆绑包版本 1。您可以在此处阅读更多内容:
    https://bundler.io/guides/bundler_2_upgrade.html

    切换到 ruby​​ 2.3.6:

    > rvm use 2.3.6 (it'll give you the prompt to install it)
    

    在项目的根目录上运行此命令,通过运行 bundle version 检查它是否有效

    > gem install bundler -v "~>1.0"  
    

    然后

    > gem install jekyll
    > gem install bundle
    

    这是我在 mi Gemfile.lock 上所做的更改:

    > RUBY VERSION  
    > ruby 2.3.6p384  
    > BUNDLED WITH  
    > 1.17.3
    

    我的 Gemfile 只是在顶部说 ruby​​ “2.3.6”,我还将 /.ruby-version 文件更改为 ruby​​ 2.3.6(无引号)。就是这样。不要忘记捆绑 exec jekyll serve、commit 和 push,应该没问题。

    【讨论】:

      猜你喜欢
      • 2020-02-05
      • 2021-01-10
      • 2017-09-04
      • 2019-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多