61

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?

Community
  • 1
  • 1
Carlo
  • 4,016
  • 7
  • 44
  • 65
  • 4
    You might want to have a look at [ctrlp.vim](https://github.com/kien/ctrlp.vim) which is basically the same as [Command-T](https://github.com/wincent/Command-T) but written in pure Vimscript. This means it neither requires Ruby support enabled in Vim nor does it require the compilation of some Ruby extension implemented in C. – datentyp Jan 11 '12 at 15:59
  • Ctrl+P is nice as well, but it doesn't handle huge projects as good as Command+T – alex Mar 09 '18 at 15:43

10 Answers10

107

Go to plugin dir and run the following command:

rake make

It compiles the plugin extension you need.

lucapette
  • 20,564
  • 6
  • 65
  • 59
  • @CoreyRothwell make that 2 days. Jeez, sometimes I need to google before going through documentation over and over again. – shriek Oct 04 '14 at 00:12
  • RVM users make sure you're using the exact ruby version that Vim says it's using in the error message – Joe Sak Dec 02 '15 at 14:32
32

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
Asocia
  • 5,935
  • 2
  • 21
  • 46
peralmq
  • 2,160
  • 1
  • 22
  • 20
  • 4
    The comment above suggesting `rake make` didn't work for me. I installed CommandT with vundle and there is no Makefile. To add to this answer, I had to go to ~/.vim/bundle/Command-T/ruby/command-t and run the commands suggested here. For my system this also involved installing the ruby-dev package. Thanks peralmq! – jonthalpy Nov 13 '14 at 01:02
  • 3
    Now the correct directory for extconf.rb is: "/command-t/ruby/command-t/ext/command-t/". If it changes again, you can search for 'extconf.rb' at https://github.com/wincent/command-t/find/master. – phinz Jul 01 '17 at 08:23
  • Run ruby command "ruby extconf.rb" using the same ruby version that vim is using. This should not be by using rvm or other ruby. It should be the ruby that is installed on your system. – Deepak Jul 24 '20 at 12:31
4

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.

Mike
  • 9,692
  • 6
  • 44
  • 61
2

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

Mike K
  • 197
  • 1
  • 8
1

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!

Cornelius
  • 830
  • 11
  • 31
northcamel
  • 81
  • 1
  • 4
1

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
Shrestha
  • 385
  • 1
  • 2
  • 11
1

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

Randy Morris
  • 39,631
  • 8
  • 69
  • 76
1

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.

weexpectedTHIS
  • 3,358
  • 1
  • 25
  • 30
0

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.

0

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)

lovelance1
  • 71
  • 1
  • 3