输出错误:#<LoadError:无法加载此类文件-enc / trans / single_byte>

时间:2019-06-05 19:49:08

标签: ruby-on-rails ruby ruby-on-rails-5

我已经用rbenv将ruby重新安装到版本2.4.2,安装后我想运行rails控制台,但是我执行的任何使用我代码中定义的模块的操作都会导致此错误:

(pry) output error: #<LoadError: cannot load such file -- enc/trans/single_byte>

还有一段很长的轨迹,像这样:

/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb:93:in `encode'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb:93:in `encode_with_encoding'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb:57:in `normalize'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb:132:in `initialize'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/coderay-1.1.2/lib/coderay/encoders/encoder.rb:72:in `new'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/coderay-1.1.2/lib/coderay/encoders/encoder.rb:72:in `encode'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/coderay-1.1.2/lib/coderay.rb:197:in `encode'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/coderay-1.1.2/lib/coderay/tokens_proxy.rb:23:in `encode'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/coderay-1.1.2/lib/coderay/tokens_proxy.rb:32:in `method_missing'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/pry-0.11.0/lib/pry/color_printer.rb:29:in `text'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/2.4.0/pp.rb:315:in `pretty_print'
(...)
/Users/user/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/spring-2.0.2/lib/spring/application/boot.rb:19:in `<top (required)>'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/Users/user/.rbenv/versions/2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
-e:1:in `<main>'

我已经找到了答案https://stackoverflow.com/a/13400402/3663124,是的,我有yml文件带有非ASCII字符,但是以前从来都不是问题。

这是rbenv安装日志:

$ rbenv install 2.4.2
ruby-build: use openssl from homebrew
Downloading ruby-2.4.2.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.2.tar.bz2
Installing ruby-2.4.2...
ruby-build: use readline from homebrew
Installed ruby-2.4.2 to /Users/user/.rbenv/versions/2.4.2

1 个答案:

答案 0 :(得分:0)

使用rbenv到版本2.5.1的ruby我也遇到了同样的问题。用rbenv重新安装ruby以使readline使用libreadline之后。

(pry) output error: #<LoadError: cannot load such file -- enc/trans/single_byte>

它是堆栈跟踪

/Users/user-name/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb:93:in `encode'
/Users/user-name/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb:93:in `encode_with_encoding'
/Users/user-name/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb:57:in `normalize'
/Users/user-name/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/coderay-1.1.2/lib/coderay/scanners/scanner.rb:132:in `initialize'
/Users/user-name/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/coderay-1.1.2/lib/coderay/encoders/encoder.rb:72:in `new'
/Users/user-name/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/coderay-1.1.2/lib/coderay/encoders/encoder.rb:72:in `encode'

就我而言,重新启动pc是解决方案。通常,重新启动Shell是反映更改的方法,但是那时候我需要重新启动pc。