无法转换" \ x89"安装gem时从ASCII-8BIT到UTF-8 xxx

时间:2015-04-27 15:15:10

标签: ruby gem

我目前正在写一个宝石,其原因需要包含WordPress的完整副本(不完全确定是否相关)。 现在,问题;运行gem build可以正常运行,但gem install会为每个二进制文件(.gif,.png等)提供此错误消息,并且在执行了一些错误后,进程将停止。

unable to convert "\x89" from ASCII-8BIT to UTF-8 xxx/xxx.xx

' x89'某些消息的标识符不同。

这是一个示例

unable to convert "\xF2" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/spinner.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/stars-2x.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/stars.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/w-logo-blue.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/w-logo-white.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/wheel.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/wordpress-logo.png, skipping
unable to convert "\xF7" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/wpspin_light-2x.gif, skipping
unable to convert "\xF5" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/wpspin_light.gif, skipping
unable to convert "\xF6" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/xit-2x.gif, skipping
unable to convert "\xF3" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/xit.gif, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-admin/images/yes.png, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-content/plugins/akismet/_inc/img/logo-full-2x.png, skipping
unable to convert "\xE8" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-content/themes/twentyfifteen/genericons/Genericons.eot, skipping
unable to convert "\xFC" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-content/themes/twentyfifteen/genericons/Genericons.woff, skipping
unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-content/themes/twentyfifteen/screenshot.png, skipping
unable to convert "\x80" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-content/themes/twentyfourteen/genericons/Genericons-Regular.otf, skipping

进程停止前我得到的最后一行是

unable to convert "\x89" from ASCII-8BIT to UTF-8 for lib/templates/wordpress/wp-includes/js/mediaelement/bigplay.png, skipping

我在其他地方看到过类似的问题,但在尝试安装它时,它们都是针对特定的宝石。 我问的问题是如何修复我的宝石所以不会产生这个错误?

这是我的gemspec

require File.expand_path(File.dirname(__FILE__)) + '/lib/gemname.rb'

Gem::Specification.new do |s|
  s.name        = 'gemname'
  s.version     = Gemname::VERSION
  s.executables << 'gemname'
  s.licenses    = ['LICENSE']
  s.summary     = "Short description"
  s.description = "Long description"
  s.authors     = ["Sigurd Berg Svela"]
  s.email       = 'sigurdbergsvela@gmail.com'
  s.files       = `git ls-files -- lib/*`.split("\n")
  s.homepage    = 'https://github.com/sigurdsvela/gemname'
  s.required_ruby_version = '>= 2.0.0'

  gemRootDir = File.dirname(File.expand_path(__FILE__))

  # get an array of submodule dirs by executing 'pwd' inside each submodule
  `git submodule --quiet foreach pwd`.split("\n").each do |submodule_path|

    # for each submodule, change working directory to that submodule
    Dir.chdir(submodule_path) do

      # issue git ls-files in submodule's directory
      submodule_files = `git ls-files`.split("\n")

      # prepend the submodule path to create absolute file paths
      submodule_files_fullpaths = submodule_files.map do |filename|
        "#{submodule_path}/#{filename}"
      end

      # remove leading path parts to get paths relative to the gem's root dir
      # (this assumes, that the gemspec resides in the gem's root dir)
      submodule_files_paths = submodule_files_fullpaths.map do |filename|
        filename.gsub "#{gemRootDir}/", ""
      end

      # add relative paths to gem.files
      s.files += submodule_files_paths
    end

  end

  # Hardcode include gitignores submodule
  Dir.chdir(Boot.dir + "/templates/gitignores") do
    submodule_path = Boot.dir + "/templates/gitignores"

    # issue git ls-files in submodule's directory
    submodule_files = `git ls-files`.split("\n")

    # prepend the submodule path to create absolute file paths
    submodule_files_fullpaths = submodule_files.map do |filename|
      "#{submodule_path}/#{filename}"
    end

    # remove leading path parts to get paths relative to the gem's root dir
    # (this assumes, that the gemspec resides in the gem's root dir)
    submodule_files_paths = submodule_files_fullpaths.map do |filename|
      filename.gsub "#{gemRootDir}/", ""
    end

    # add relative paths to gem.files
    s.files += submodule_files_paths
  end

end

1 个答案:

答案 0 :(得分:1)

这似乎是gem安装程序的一个错误。 但是'gem install germane - no-document '可以作为临时解决方案。