Macos Catalina更新后出现错误:无法运行colorls

Var*_*eja 4 macos rubygems zsh macos-catalina colorls

更新到macOS Catalina在打开终端时出现错误

ERROR:  Can't find Ruby library file or shared library colorls
usage: dirname path
/Users/varunsukheja/.zshrc:source:91: no such file or directory: /tab_complete.sh
Run Code Online (Sandbox Code Playgroud)

当我检查第91行的.zshrc文件时,发现以下行

source $(dirname $(gem which colorls))/tab_complete.sh
Run Code Online (Sandbox Code Playgroud)

并检查gem which colorls我得到以下错误

ERROR:  Can't find Ruby library file or shared library colorls
Run Code Online (Sandbox Code Playgroud)

但是当我检查时,which colorls我走到了下面

/usr/local/bin/colorls
Run Code Online (Sandbox Code Playgroud)

我也尝试使用gem重新安装colorls

Building native extensions. This could take a while...
ERROR:  Error installing colorls:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/clocale-0.0.4/ext/clocale
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /Library/Ruby/Site/2.6.0 -r ./siteconf20191009-43313-16ndnb.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/clocale-0.0.4 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/clocale-0.0.4/gem_make.out
Run Code Online (Sandbox Code Playgroud)

请帮助如何使其工作。

Var*_*eja 5

这是我解决的方法,

  1. sudo xcode-select-安装
  2. 用以下命令安装rbenv brew install rbenv
  3. 添加eval "$(rbenv init -)"~/.zshrc或的末尾~/.bash_profile
  4. 安装红宝石版本 rbenv install 2.6.0
  5. 选择rbenv的红宝石版本 rbenv global 2.6.0
  6. 打开一个新的终端窗口
  7. 验证正确的gem文件夹是否与gem env home一起使用(应在用户文件夹中报告某些内容,而不是系统范围内的内容)

之后,我再次使用安装了colorls sudo gem install colorls

如果出现错误:

ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.
Run Code Online (Sandbox Code Playgroud)

尝试使用cmd安装colorl:

sudo gem install colorls -n /usr/local/bin
Run Code Online (Sandbox Code Playgroud)

之后,您会看到成功安装了colorls,并且新终端正常运行。


小智 5

This worked for me:

xcode-select --install sudo gem install colorls -n /usr/local/bin