更新到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
当我检查第91行的.zshrc文件时,发现位于行以下
source $(dirname $(gem which colorls))/tab_complete.sh
然后在检查gem which colorls
时出现以下错误
ERROR: Can't find Ruby library file or shared library colorls
但是当我检查which colorls
时,我会到达路径以下
/usr/local/bin/colorls
我也尝试使用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
请帮助其工作。
答案 0 :(得分:5)
这是我解决的方式,
brew install rbenv
eval "$(rbenv init -)"
或~/.zshrc
的末尾添加~/.bash_profile
rbenv install 2.6.0
rbenv global 2.6.0
选择红宝石版本此后,我再次使用sudo gem install colorls
如果出现错误:
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
尝试使用cmd安装colorls:
sudo gem install colorls -n /usr/local/bin
此后,您将看到成功安装了colorls,并且新终端可以正常工作。
答案 1 :(得分:5)
这对我有用:
xcode-select --install
sudo gem install colorls -n /usr/local/bin
答案 2 :(得分:2)
这对我来说是固定的:
$ sudo gem update
$ sudo gem install colorls
Catalina现在随附Ruby 2.6,而不是2.3。我的猜测是,随着升级,所有自定义安装的gem都被新的Ruby / Gem软件包系统“跟踪”。这样,gem update
就不会更新colorls
。
确保重新安装XCode命令行工具,更新/升级brew,npm等。
答案 3 :(得分:0)
为我解决的是:
由于某种原因,没有选择命令行工具,因此这给我带来了问题。我下载了Xcode的Beta版,但更新为最新版本时未选择任何版本。
答案 4 :(得分:0)
错误:安装cocoapods时,gem本机扩展错误
答案:请按照以下3个步骤操作。
步骤1: 打开XCode转到下面的路径
XCode>首选项>位置>命令行工具(select-Xcode)
步骤2: 打开终端-粘贴以下命令
卷曲-L https://get.rvm.io bash -s稳定
重新打开终端-粘贴以下命令
注意:这将需要3-5分钟
rvm install ruby-2.6
rvm使用ruby-2.6.3
rvm-默认使用2.6.3
Step3:
打开终端-在命令下方键入
sudo gem install cocoapods
现在安装cocoapods时,gem本机扩展错误不会出现
问题已解决。