2016-07-28 122 views
0

尝试使用非ascii字符执行string.encode("UTF-8")时收到以下错误。LoadError enc/trans/single_byte.so

LoadError: dlopen(enc/trans/single_byte.so, 9): image not found - enc/trans/single_byte.so 

不同的答案here,看来这个文件没有在我的红宝石存在安装,或任何其他地方的系统为这一问题上。我运行的是Mac OSX 10.11.5上运行的ruby 2.1.7和bundler 1.10.6。我尝试重新安装红宝石(使用RVM)没有成功。

该文件是否存在,如果有的话,我需要安装什么?

回答

0

我会建议尝试使用chruby + ruby​​-install来安装它。你可以使用ruby-install来安装你想要的任何Ruby版本,而chruby是一个用于在Ruby版本之间切换的小工具。

我见过RVM偶尔会遇到问题,用ruby-install重新安装Ruby似乎可以解决问题。

我对这里的指南:http://ryanbigg.com/2015/06/mac-os-x-ruby-ruby-install-chruby-and-you/

下面是压缩形式的步骤:

# Installs XCode development tools package 
xcode-select --install 
# Installs Homebrew (skip if you've done this already) 
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 
brew install chruby ruby-install 
ruby-install -V # this should show ruby-install: 0.6.0 
ruby-install ruby 2.1.7 

此行添加到~/.bashrc

source /usr/local/opt/chruby/share/chruby/auto.sh 

刷新~/.bashrc

. ~/.bashrc 

运行chruby现在应该会显示ruby-2.1.7并且运行ruby -v也应该显示您的2.1.7。