`find_spec_for_exe’: can’t find gem compass (>= 0.a) with executable compass (Gem::GemNotFoundException)

作者

find_spec_for_exe: can't find gem compass (>= 0.a) with executable compass (Gem::GemNotFoundException) 今天我遇到了这个问题,尝试了很多方法,都没有解决。最后我删除了~/.gem 文件夹,问题便解决了。

可能的原因是版本的问题,我的系统是centos8, 先使用 yum 安装了 ruby, 然后使用 gem install compass, 后来我删除了 ruby yum remove gem , 重新使用源代码的编译ruby, 之后所有使用 gem 安装的程序,都遇到了这个问题。比如下面 compass

 compass
Traceback (most recent call last):
        2: from /usr/local/bin/compass:23:in `<main>'
        1: from /usr/local/ruby/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
/usr/local/ruby/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': can't find gem compass (>= 0.a) with executable compass (Gem::GemNotFoundException)

解决的方法, 重新安装

rm ~/.gem/ -fr
gem install compass

正常的执行

compass -v
Compass 1.0.3 (Polaris)
Copyright (c) 2008-2020 Chris Eppstein
Released under the MIT License.
Compass is charityware.
Please make a tax deductable donation for a worthy cause: http://umdf.org/compass