gpt4 book ai didi

ruby - ubuntu 上的 `gem install` 给出无效的字节序列错误

转载 作者:太空宇宙 更新时间:2023-11-03 16:02:10 26 4
gpt4 key购买 nike

我使用 RVM 在 Ubuntu (Debian) 上安装 Ruby。我可以使用 irb 并运行 ruby​​ 脚本。

但是,当我尝试安装任何 gem 时,出现此错误:

ERROR:  While executing gem ... (ArgumentError)
invalid byte sequence in UTF-8

当我为 gem 使用任何值时也会发生这种情况,例如,gem install garbage

Ruby 1.9.3 和 2.0 都会发生这种情况。

这是命令 locale 报告的内容:

LANG=en_US.UTF-8
LANGUAGE=en_SG:en
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=en_US.UTF-8

这是痕迹:

ERROR:  While executing gem ... (ArgumentError)
invalid byte sequence in UTF-8
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:862:in `sub!'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:862:in `block (2 levels) in parse_resolv_conf'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:861:in `each'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:861:in `block in parse_resolv_conf'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:860:in `open'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:860:in `parse_resolv_conf'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:892:in `default_config_hash'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:913:in `block in lazy_initialize'
<internal:prelude>:10:in `synchronize'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:906:in `lazy_initialize'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:342:in `block in lazy_initialize'
<internal:prelude>:10:in `synchronize'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:340:in `lazy_initialize'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:494:in `each_resource'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb:475:in `getresource'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/remote_fetcher.rb:88:in `api_endpoint'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/source.rb:42:in `api_uri'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/source.rb:170:in `load_specs'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:266:in `tuples_for'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:226:in `block in available_specs'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/source_list.rb:97:in `each'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/source_list.rb:97:in `each_source'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:222:in `available_specs'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/spec_fetcher.rb:102:in `search_for_dependency'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:216:in `find_gems_with_sources'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:292:in `find_spec_by_name_and_version'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:166:in `available_set_for'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:418:in `resolve_dependencies'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/dependency_installer.rb:371:in `install'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:219:in `install_gem'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:263:in `block in install_gems'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:259:in `each'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:259:in `install_gems'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/commands/install_command.rb:171:in `execute'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/command.rb:305:in `invoke_with_build_args'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:167:in `process_args'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/command_manager.rb:137:in `run'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/site_ruby/1.9.1/rubygems/gem_runner.rb:54:in `run'
/home/crazybob/.rvm/rubies/ruby-1.9.3-p484/bin/gem:21:in `<main>'

最佳答案

~/.gemrc 中启用回溯:

---
backtrace: true

安装并提供跟踪日志。

根据跟踪日志,似乎在安装 ruby​​ 时发生了一些无效的事情。需要自己调试。只需打开文件。 /home/crazybob/.rvm/rubies/ruby-1.9.3-p484/lib/ruby/1.9.1/resolv.rb 在 862 行,在它之前插入行: puts str.encodingputs str.inspect 或类似的东西,以查看引发错误的 String

同时尝试重新安装 ,或使用 安装最新版本.

关于ruby - ubuntu 上的 `gem install` 给出无效的字节序列错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21983630/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com