GitHub Pages本地Jekyll Serve运行报错求助
解决Ruby 3.4环境下Jekyll启动的csv加载错误与警告
问题重现
执行命令:
bundle exec jekyll serve
出现报错:
C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/jekyll-4.3.4/lib/jekyll.rb:26: warning: logger was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.5.0. You can add logger to your Gemfile or gemspec to silence this warning. C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/jekyll-4.3.4/lib/jekyll.rb:28: warning: csv was loaded from the standard library, but is not part of the default gems starting from Ruby 3.4.0. You can add csv to your Gemfile or gemspec to silence this warning. C:/Ruby34-x64/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require': cannot load such file -- csv (LoadError) from C:/Ruby34-x64/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require' from C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/jekyll-4.3.4/lib/jekyll.rb:28:in '<top (required)>' from C:/Ruby34-x64/lib/ruby/3.4.0/bundled_gems.rb:82:in 'Kernel.require' from C:/Ruby34-x64/lib/ruby/3.4.0/bundled_gems.rb:82:in 'block (2 levels) in Kernel#replace_require' from C:/Ruby34-x64/lib/ruby/gems/3.4.0/gems/jekyll-4.3.4/exe/jekyll:8:in '<top (required)>' from C:/Ruby34-x64/bin/jekyll:36:in 'Kernel#load' from C:/Ruby34-x64/bin/jekyll:36:in '<main>'
解决方案
- 打开项目根目录的
Gemfile,添加以下两行:gem 'csv' gem 'logger' - 执行命令安装依赖:
bundle install - 重新启动Jekyll:
bundle exec jekyll serve
原因说明
- Ruby 3.4版本开始,
csv不再作为默认标准库gem包含,而Jekyll 4.3.4仍依赖该库,因此需要手动在Gemfile中声明引入。 logger的警告是预告Ruby 3.5版本将移除其默认gem状态,提前添加可避免后续版本升级时出现类似错误。
内容的提问来源于stack exchange,提问作者PBI DataVizzle
相关产品推荐
相关产品推荐

