ruby-on-rails - 服务时出现 Ruby/Jekyll 要求错误
问题描述
我最近安装了适用于 Linux 的 Windows 子系统,并且正在我的 Windows 10 计算机上运行 Ubuntu 发行版。我安装了 Python、pip、Ruby 和 Jekyll,当我运行 --version 标志时,它们都被确认安装正确。
我正在尝试在我的计算机上本地运行和修改一个名为Mediumish的 Jekyll 主题。按照作者的说明(即 runbundle
和 run 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 在运行 -watch 时出现未知错误——这与我遇到的情况非常相似。我已经尝试了这篇文章中推荐的解决方案,这些解决方案是运行jekyll build --watch
andjekyll serve --watch
命令,但是会出现同样的错误。
几个月前我能够成功运行这个主题,但是在重新格式化我的电脑,从头开始重新安装我所有的应用程序,并从作者的网站克隆一个新的主题副本后,我无法在本地服务该网站,从而阻碍了我查看我对博客主题所做的任何修改。
解决方案
我运行了这个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:错误:无法建立站点, 解决方案的日期格式错误!
推荐阅读
- php - 在 erb 视图中从 onclick 运行 bash 脚本
- qt - QML WindowApplication 在设置窗口工具栏时使用 SplitView 进行奇怪的大小调整行为
- netsuite - DocuSign API:将 NetSuite 文档上传到信封
- javascript - Chart.js 堆叠折线图,具有不同样式的部分
- c# - 表单关闭后 C# 进程未恢复到任务栏
- python - 为什么python“导入平台”模块会导致重复/重复打印?
- python - 打破循环并获得单一结果
- graphql - gatsby.js - 高级入门 - 实现 2 个 url 前缀(站点的 2 个不同部分)?
- html - 背景图像和边框
- spring-cloud-dataflow - Spring Cloud 数据流