【问题标题】:Ruby/Jekyll requirement errors when serving服务时出现 Ruby/Jekyll 需求错误
【发布时间】:2019-12-09 06:39:04
【问题描述】:

我最近安装了适用于 Linux 的 Windows 子系统,并且正在我的 Windows 10 计算机上运行 Ubuntu 发行版。我安装了 Python、pip、Ruby 和 Jekyll,当我运行 --version 标志时,它们都被确认安装正确。

我正在尝试在我的计算机上本地运行和修改一个名为 Mediumish 的 Jekyll 主题。按照作者的说明(即运行bundle和运行jekyll serve --watch),我遇到以下错误:

Traceback (most recent call last):
        5: from /usr/local/bin/jekyll:23:in `<main>'
        4: from /usr/local/bin/jekyll:23:in `load'
        3: from /var/lib/gems/2.5.0/gems/jekyll-3.8.6/exe/jekyll:11:in `<top (required)>'
        2: from /var/lib/gems/2.5.0/gems/jekyll-3.8.6/lib/jekyll/plugin_manager.rb:48:in `require_from_bundler'
        1: from /usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
/usr/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require': cannot load such file -- bundler (LoadError)

我尝试向作者的 Github 帐户提交问题,但似乎他已经停止回复(和维护)这个主题几个月了。

我发现了另一个 Stackoverflow 帖子,标题为 Ruby/Jekyll unknown error when running -watch — 这与我的经历非常相似。我已经尝试了这篇文章中推荐的解决方案,即运行jekyll build --watchjekyll serve --watch 命令,但也会出现同样的错误。

几个月前我能够成功运行这个主题,但是在重新格式化我的电脑,从头开始重新安装我所有的应用程序,并从作者的网站克隆一个新的主题副本后,我无法在本地提供网站服务从而阻止我查看我对博客主题所做的任何修改。

【问题讨论】:

  • 也许你需要安装bundler?一种安装方法是运行命令gem install bundler
  • 你可以尝试运行bundle exec jekyll serve --watch吗?
  • @Kin 我按照您的建议运行 gem install bundler 并收到以下消息:Successfully installed bundler-2.0.2 Parsing documentation for bundler-2.0.2 Done installing documentation for bundler after 4 seconds 1 gem installed,但我仍然收到相同的错误。
  • @JayDorsey 运行bundle exec jekyll serve --watch 命令返回以下错误:Traceback (most recent call last): 2: from /usr/local/bin/bundle:23:in `&lt;main&gt;' 1: from /usr/lib/ruby/2.5.0/rubygems.rb:308:in `activate_bin_path' /usr/lib/ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (&gt;= 0.a) with executable bundle (Gem::GemNotFoundException)
  • 我想说这是一个已知问题。我能想到两件事:1) 运行 gem update --system 2) 使用 bundle --version 仔细检查您的捆绑程序版本,并确保它是 2.0.2;它可能默认为旧版本。我认为系统更新会修复它,如果它是我认为的那样

标签: ruby-on-rails ruby jekyll windows-subsystem-for-linux jekyll-theme


【解决方案1】:

我运行了gem update --system 命令,我的 Jekyll 主题几乎在本地提供。

我收到以下错误:

Error: could not read file /mnt/c/Users/muyga/Desktop/mediumish-theme-jekyll/vendor/bundle/gems/jekyll-3.8.5/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb: Invalid date '<%= Time.now.strftime('%Y-%m-%d %H:%M:%S %z') %>': Document 'vendor/bundle/gems/jekyll-3.8.5/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb' does not have a valid date in the YAML front matter. ERROR: YOUR SITE COULD NOT BE BUILT: ------------------------------------ Invalid date '<%= Time.now.strftime('%Y-%m-%d %H:%M:%S %z') %>': Document 'vendor/bundle/gems/jekyll-3.8.5/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb' does not have a valid date in the YAML front matter.

为了修复该错误,我修改了我的config.yml 文件并将vendor 添加到exclude: 类别中以在我的主题文件夹中排除该文件夹。

现在,当我运行 bundle exec jekyll serve --watch 时,主题服务正常。

感谢@JayDorsey 和Jekyll: Error: Site could not be built, wrong date format 的解决方案!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 2022-07-13
    • 1970-01-01
    • 1970-01-01
    • 2023-01-24
    • 2016-07-20
    相关资源
    最近更新 更多