wincent / command-t

⌨️ Fast file navigation for Neovim and Vim
BSD 2-Clause "Simplified" License
2.74k stars 317 forks source link

Failed to work after vim ruby version update to 2.6.1p33 #350

Closed adamsx97 closed 5 years ago

adamsx97 commented 5 years ago

System Info

Symptom

Commands:

$ cd ~/.vim/bundle/command-t
$ rake make

Output: With a warning

/Users/chengengxiao/.rvm/rubies/ruby-2.6.1/bin/ruby extconf.rb
checking for float.h... yes
checking for ruby.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for fcntl.h... yes
checking for stdint.h... yes
checking for sys/errno.h... yes
checking for sys/socket.h... yes
checking for ruby/st.h... yes
checking for st.h... yes
checking for pthread_create() in -lpthread... yes
creating Makefile
compiling ext.c
compiling heap.c
compiling match.c
compiling matcher.c
compiling watchman.c
watchman.c:546:51: warning: function 'watchman_raise_system_call_error' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
void watchman_raise_system_call_error(int number) {
                                                  ^
1 warning generated.
linking shared-object ext.bundle

Commands:

$ vim
<leader>t

Output from vim:

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
For more information type:    :help command-t
Press ENTER or type command to continue

Other fix method tried: Change ruby version with rvm

Command:

$ cd ~/.vim/bundle/command-t
$ rvm use 2.3.0
$ rake make
$ vim
<leader>t

Command-t compiles with no warning, but vim has different output:

Ignoring executable-hooks-1.3.2 because its extensions are not built. Try: gem pristine executable-hooks --version 1.3.2
Ignoring gem-wrappers-1.2.7 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.2.7
Ignoring io-console-0.4.6 because its extensions are not built. Try: gem pristine io-console --version 0.4.6
Ignoring json-2.0.1 because its extensions are not built. Try: gem pristine json --version 2.0.1
Ignoring psych-2.1.0 because its extensions are not built. Try: gem pristine psych --version 2.1.0
Ignoring redcarpet-3.4.0 because its extensions are not built. Try: gem pristine redcarpet --version 3.4.0
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
Expected version: 2.3.0-p0
For more information type:    :help command-t
adamsx97 commented 5 years ago

Other fix method tried: Remove and reinstall all following: vim, ruby, rvm and command-t plugin

adamsx97 commented 5 years ago

@wincent Would you please help me out? thank you!

wincent commented 5 years ago

You've already done all the things I would have tried, except perhaps for building Vim and Command-T with the system Ruby instead of RVM, which tends to complicate things.

I'm not on Mojave myself but others have reported some success with it; look at #341, for example. Closing this one in any case as we may as well centralize all discussion in that issue.

cfrank commented 5 years ago

Sorry to go grave digging on an issue this old but it is the first one which comes up for this particular issue.

If you have followed all the steps regarding matching ruby versions then this might be an issue with not having watchman installed.

I performed the following to get rid of the watchman compilation issue:

brew update
brew install watchman
/usr/local/opt/ruby/bin/ruby extconf.rb
make clean
make

This resulted in a successful response of:

linking shared-object ext.bundle
adamsx97 commented 5 years ago

@cfrank The problem has already been solved. The problem was that Mac OS has two separate ruby environments. One is under the system OS_ruby and the other is the brew_ruby.

The fixing method is: Step 1: uninstall ruby from brew, and purge all ruby configurations and paths. Step 2: Then install ruby from either rvm, rbenv or any other ruby version controller. Step 3: set brew's ruby path to the OS_ruby you installed. It will fix the problem. (Do not install ruby from brew)

After that re-compile command-t and try it in vim, it should work.

bmulholland commented 4 years ago

I'm running into this issue now because macvim just added a ruby dependency: https://github.com/Homebrew/homebrew-core/pull/45624/files (and so I suspect more people will run into this soon)

I can't figure out what @adamsx97 meant by step 3, and can't find any resources that talk about "brew's ruby path". I've installed macvim, force-removed the brew ruby dependency, and have the vim ruby version installed via rvm and currently used. ruby -v matches the version I expect (in rvm), which ruby points to the binary in the corresponding rvm folder, and the error message in the command-t "could not load" error shows only the vim ruby number (presumably because the expected number matched). Under these circumstances, it doesn't seem like any other ruby installations should be involved...

Can someone point me in the right direction to investigate? What's the root cause of the watchman_raise_system_call_error error with multiple rubies involved? It does seem like brew's opinion is that brew ruby /should/ be installed (see e.g. https://github.com/Homebrew/homebrew-core/issues/22596), and I can't find anything on making brew allow rvm ruby to meet its dependency, so how can this all be made compatible?

bmulholland commented 4 years ago

I have fixed the compilation such that this is now running, though notably the watchman warning continues to show up. The warning may be a red herring?

I've created a PR to add what worked for me to the instructions: https://github.com/wincent/command-t/pull/361

adamsx97 commented 4 years ago

@bmulholland Sorry for all the confusion, I will try to explain it clearly. First and foremost, I am not using macvim, and I am using the original vim installed with brew. Also, this is no longer my latest solution.

About using vim and add ruby support

I assume that you selecting macvim because the original vim did not come with ruby support. In fact, you can add ruby support to vim easily. Although I could not find my original resource of adding ruby support to vim, here is something similar that you can reference from. https://junegunn.kr/2013/09/installing-vim-with-ruby-support

About OS_ruby and brew_ruby:

  1. macOS comes with preinstalled ruby at "$/usr/bin/ruby". This ruby version is managed through the macOS system updates. You can also manage it with tools like rvm or rbenv.
  2. Besides macOS vim, you can also install ruby from brew. The installed location should be "$/usr/local/opt/ruby/bin/". This ruby version you can only manage it through brew services.

Old solution:

For my old solution, I uninstalled the brew_ruby and config brew applications to use system OS_ruby. However, I would have to manually use rvm to update or set global/local ruby version from directory to directory. This method is good if you have multiple ruby dependent processes and need flexibility. However, all my ruby applications can be run on the latest ruby version, so I moved on to my latest solution.

Latest solution:

In short, I moved back to ruby vim and set it as my global supported ruby source, so I no longer have to manually manage my ruby configs and it's version control goes with brew upgrades. Here is the method:

Last but not least

To make our favorite tool command-T work again. Simply recompile the plugin by entering the following codes:

$cd ~/.vim/bundle/command-t
$rake clean && rake make

You can ignore the warnings, and the plugin should be functional now.

bmulholland commented 4 years ago

Thanks for the detail @adamsx97 ! I think your current solution is approximately the same as the one I've used - using brew's ruby for compiling command-t - with the main difference being that your way sets the global ruby path to brew's ruby. I think that's equivalent to using rvm (as I do) and using the "system" ruby with rvm use system.

All that said, while this approach makes command-t work functionally, it does still show the watchman warning while compiling. It's just apparently harmless.

c0achmcguirk commented 4 years ago

I still have the problem with MacVim 8.2 (1-539):

command-t.vim could not load the C extension.
Please see INSTALLATION and TROUBLE-SHOOTING in the help.
Vim Ruby version: 2.7.1-p83
For more information type:    :help command-t

But I'm able to have the watchman.c warning go away by adding this line near the top of the watchman.c file:

// Line 8 of watchman.c, shortly after #include "watchman.h".
void watchman_raise_system_call_error(int) __attribute__((noreturn));

This is a gcc attribute that helps the compiler optimize code for functions that don't return. I use brew install macvim to install my version of vim, so I don't know if it's appropriate to add to watchman.c for everyone.