Carlo
Carlo

Reputation: 4148

Vim Command-T plugin error: could not load the C extension

I'm trying to install the Command-T plugin.

I compiled vim following the instructions in this comment: Installing vim with ruby support (+ruby)

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?

Upvotes: 61

Views: 15896

Answers (10)

peralmq
peralmq

Reputation: 2328

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

Upvotes: 33

lovelance1
lovelance1

Reputation: 71

I solved this by doing the following steps:

  1. find your ruby folder in your ~/.vim, since mine could not be found in ~/.vim/ruby
  2. find . -name "extconf.rb"- find the extconf.rb file, which may be located in a command-t folder
  3. ruby extconf.rb
  4. make
  5. re-open vim

It may be also useful to read the documentation inside vim (:help command-t)

Upvotes: 0

Tim Nordloh
Tim Nordloh

Reputation: 1

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.

Upvotes: 0

stuckoverflow
stuckoverflow

Reputation: 385

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

Upvotes: 1

Mike K
Mike K

Reputation: 197

On debian squeeze I also had to install the json library for ruby with apt-get install libjson-ruby1.8

Upvotes: 2

northcamel
northcamel

Reputation: 81

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!

Upvotes: 1

Mike
Mike

Reputation: 9842

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.

Upvotes: 4

lucapette
lucapette

Reputation: 20724

Go to plugin dir and run the following command:

rake make

It compiles the plugin extension you need.

Upvotes: 107

weexpectedTHIS
weexpectedTHIS

Reputation: 3376

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.

Upvotes: 1

Randy Morris
Randy Morris

Reputation: 40927

Command-T requires a compiled component. The error message suggests you haven't followed the installation instructions for the plugin completely.

Upvotes: 1

Related Questions