Vim Command-T plugin error: could not load the C extension
RubyVimPluginsRuby Problem Overview
I'm trying to install the Command-T plugin.
I compiled vim following the instructions in this comment: https://stackoverflow.com/questions/3794895/installing-vim-with-ruby-support-ruby/3851435#3851435
So now there's the +ruby flag, but still when I try to use the plugin I get this error:
command-t.vim could not load the C extension
Please see INSTALLATION and TROUBLE-SHOOTING in the help
For more information type: :help command-t
I have ruby on my system:
> ruby -v
> ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
suggestions?
Ruby Solutions
Solution 1 - Ruby
Go to plugin dir and run the following command:
rake make
It compiles the plugin extension you need.
Solution 2 - Ruby
I ran into the same error but after reading the manual a bit more thorough I found the following helpful.
Tagged from the INSTALLATION section in https://github.com/wincent/Command-T
> The C extension must then be built, which can be done from the shell. If you use a typical |'runtimepath'| then the files were installed inside ~/.vim and you can build the extension with:
cd ~/.vim/ruby/command-t/ext/command-t
ruby extconf.rb
make
Solution 3 - Ruby
You must perform the build using the same version of Ruby that Vim itself is linked against.
Are you using RVM or rbenv? Personally, I was using rbenv and MacVim. I had this error because I was trying use ruby 1.8.7 patch 352. I switched back to 1.8.7 patch 249 using rbenv shell system
before running ruby extconf.rb
and make
, then everything worked fine.
Afterwards, you can revert your shell back using rbenv shell --unset
.
Solution 4 - Ruby
On debian squeeze I also had to install the json library for ruby with apt-get install libjson-ruby1.8
Solution 5 - Ruby
Command-T requires a compiled component. The error message suggests you haven't followed the installation instructions for the plugin completely.
Solution 6 - Ruby
Check out the installation instructions on: https://github.com/wincent/Command-T Search on that page for the header "INSTALLATION". You most likely did not follow the instructions from this official README. If you are using RVM make sure to use the system ruby. This is all notated in the docs.
Solution 7 - Ruby
If you are sure you follow the instruction on the github project,maybe you need to restart vim and the terminal. I came across the same problem and when I restarted Vim, it finally worked!
Solution 8 - Ruby
I got similar error and tried rake make
as suggested in one of the answers, which also runs ruby extconf.rb
, I got following error
ā$ rake make
/usr/bin/ruby2.3 extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h
rake aborted!
Command failed with status (1): [/usr/bin/ruby2.3 extconf.rb...]
/home/shreedhan/.vim/bundle/command-t/Rakefile:84:in `block (2 levels) in <top (required)>'
/home/shreedhan/.vim/bundle/command-t/Rakefile:83:in `chdir'
/home/shreedhan/.vim/bundle/command-t/Rakefile:83:in `block in <top (required)>'
Tasks: TOP => make
(See full trace by running task with --trace)
You need to install ruby-devel
or ruby-dev
based on whether you have yum
or apt
on your distro.
yum install ruby-devel
or
$ apt install ruby-dev
Solution 9 - Ruby
Eventually, after some trial and error, I found this command in the command-t FAQ, which deals with a Mac OS issue. I'm running "High Sierra 10.13.4":
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future ruby extconf.rb
This seemed to generate a Makefile that ran the compile successfully. I tried a lot of stuff though, and this solution feels a little cargo-culty.
Solution 10 - Ruby
I solved this by doing the following steps:
- find your ruby folder in your ~/.vim, since mine could not be found in ~/.vim/ruby
find . -name "extconf.rb"
- find the extconf.rb file, which may be located in a command-t folderruby extconf.rb
make
- re-open vim
It may be also useful to read the documentation inside vim (:help command-t
)