vim - 在 OsX mojave 中安装 CommandT 。我收到错误 Vim Command-T 插件错误:无法加载 C 扩展
问题描述
嗨,我已经尝试了所有方法,但仍然无法正常工作
错误说
command-t.vim could not load the C extension.
Please see INSTALLATION and TROUBLE-SHOOTING in the help.
Vim Ruby version: 2.6.1-p33
正如文档所说,我必须使用 make,这是我尝试
cd ~/.vim/bundle/command-t/ruby/command-t/ext/command-t
ruby extconf.rb && make
我有另一个错误
checking for float.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/$(RUBY_BASE_NAME)
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:571:in `block in try_compile'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:524:in `with_werror'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:571:in `try_compile'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:1144:in `block in find_header'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:942:in `block in checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in `block (2 levels) in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:350:in `block in postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:320:in `open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:346:in `postpone'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:941:in `checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/mkmf.rb:1143:in `find_header'
from extconf.rb:18:in `header'
from extconf.rb:25:in `<main>'
在我收到这个错误之后,我在 stackoverflow 中尝试了很多方法,但现在我的 ruby 版本 ruby 2.3.7p456 仍然无法正常工作,但在我的 vim ruby 版本 = 2.6
我尝试通过 sudo find / -name mkmf.log 和我在 CommandT 中的 mkmf.log 找到错误
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
6: }
/* end */
我花了 5 小时 + 来研究这个但仍然无法修复 =]
我正在使用 mac Mojave 最新版本
解决方案
我brew upgrade
今天做了之后也遇到了这个问题。我通过以下步骤修复了它:
- 更新命令-t 拳头。
cd ~/.vim/bundle/command-t/
git pull
git submodule update --remote --merge
- 更新红宝石
brew reinstall ruby
- 将红宝石添加到 PATH 中。
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
- 检查 ruby 版本是否更新到 2.6
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
- 再次构建commant-t
cd ~/.vim/bundle/command-t/
rake make
希望这些步骤可以解决您的问题。