GBK中的无效字节序列。捆绑器无法继续

时间:2018-11-06 03:10:14

标签: ruby jekyll

在我的jekyll项目中,有一个文件名为中文。当我在终端中运行bundle exec jekyll serve --drafts时,它报告一个错误:

C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler.rb:511:in `rescue in eval_gemspec':  (Bundler::Dsl::DSLError)
[!] There was an error parsing `Gemfile`:
[!] There was an error while loading `jekyll-theme-so-simple.gemspec`: invalid byte sequence in GBK. Bundler cannot continue.

 #  from E:/Github/shangchihh.github.io/jekyll-theme-so-simple.gemspec:14
 #  -------------------------------------------
 #    spec.add_development_dependency "rake", "~> 10.0"
 >  end
 #  # coding: utf-8
 #  -------------------------------------------
. Bundler cannot continue.

 #  from E:/Github/shangchihh.github.io/Gemfile:2
 #  -------------------------------------------
 #  source "https://rubygems.org"
 >  gemspec #  source "https://rubygems.org"
 #  -------------------------------------------
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler.rb:502:in `eval_gemspec'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler.rb:440:in `block in load_gemspec_uncached'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/shared_helpers.rb:65:in `chdir'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/shared_helpers.rb:65:in `block in chdir'
        from C:/Ruby25-x64/lib/ruby/2.5.0/monitor.rb:226:in `mon_synchronize'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/shared_helpers.rb:64:in `chdir'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler.rb:439:in `load_gemspec_uncached'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler.rb:425:in `load_gemspec'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/dsl.rb:66:in `block in gemspec'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/dsl.rb:66:in `map'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/dsl.rb:66:in `gemspec'
        from E:/Github/shangchihh.github.io/Gemfile:2:in `eval_gemfile'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/dsl.rb:47:in `instance_eval'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/dsl.rb:47:in `eval_gemfile'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/dsl.rb:12:in `evaluate'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/definition.rb:35:in `build'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler.rb:135:in `definition'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler.rb:101:in `setup'
        from C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/bundler-1.16.3/lib/bundler/setup.rb:20:in `<top (required)>'
        from C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'
        from C:/Ruby25-x64/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:59:in `require'

gemspec文件的第14行是:

spec.files                   = `git ls-files -z`.split("\x0").select do |f|

此错误是由Ruby无法处理GBK字符集引起的吗?我该如何解决这个问题?

0 个答案:

没有答案