Unsure how to deal with Ruby RVM version mismatch (Homebrew-installed VIM) #228

Closed
ecbrodie opened this Issue Jun 20, 2016 · 11 comments

Comments

Projects
None yet
4 participants
@ecbrodie

ecbrodie commented Jun 20, 2016

I just heard about command-t and I'm attempting to give it a try on my machine. However, I'm running into some sort of Ruby version mismatch hell and I'm unsure what to do.

For background, I am using MacOS 10.11.5 (meaning a system-provided Ruby version 2.0). I develop Rails applications actively, so I use RVM as my Ruby version manager. My project is currently using Ruby version 2.1.6, so that is the Ruby version that I have installed globally. I have VIM installed via Homebrew and command-t installed via Vundle (through my .vimrc file).

Now the fun part begins. I run these commands, as advised through the command-t documentation, to complete the installation of the C extensions:

cd ~/.vim/bundle/command-t/ruby/command-t
ruby extconf.rb
make

Now I go into my project's home directory and execute vim .. I execute the Command-T command via <Leader>t and the following output is printed:

command-t.vim could not load the C extension
Please see INSTALLATION and TROUBLE-SHOOTING in the help
Vim Ruby version: 2.0.0-p648
Expected version: 2.1.6-p336
For more information type: :help command-t

The way I read this is that the VIM-linked Ruby version is my system version, but Command-T expects to use the Ruby version currently on my PATH (I configure my Ruby version via RVM using the .ruby-version file). I can confirm this by running the print-Ruby-version command suggested in the Command-T documentation

:ruby puts "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
--> 2.0.0-p648

What I need to do next is very unclear to me. I've tried multiple things already, including executing rvm use 2.1.6 and rvm use default before executing make for the C extension building, reinstalling Homebrew VIM as-is, reinstalling Homebrew VIM using brew install vim --without-ruby (suggested by Homebrew/legacy-homebrew#17313), and using the rvm-vim extension (commands wouldn't work due to some sort of PATH issue). None seem to get my VIM installation to recognize my RVM Ruby version.

Please let me know what I may be missing in order to get Command-T working on my machine. Any more troubleshooting steps that need to be done? All help greatly appreciated, thank you.

@wincent

This comment has been minimized.

Show comment
Hide comment
@wincent

wincent Jun 20, 2016

Owner

The way I read this is that the VIM-linked Ruby version is my system version, but Command-T expects to use the Ruby version currently on my PATH

Kind of. The Vim-linked Ruby likely is your system version, but just to be clear: Command-T doesn't care which Ruby is currently in the PATH when you run Vim, it only cares about the Ruby that was current at build time. You want that to be the same as the one Vim links to.

So, your try to using rvm use default sounds like the right thing to do. Did you run make clean before doing that? You really want to throw it all away and build using the exact same version that Vim links against.

(Not immediate relief, but in the long plan, my intention is to run Command-T in a separate process, which will make this kind of compilation mismatch a thing of the past. See #220 for that.)

Owner

wincent commented Jun 20, 2016

The way I read this is that the VIM-linked Ruby version is my system version, but Command-T expects to use the Ruby version currently on my PATH

Kind of. The Vim-linked Ruby likely is your system version, but just to be clear: Command-T doesn't care which Ruby is currently in the PATH when you run Vim, it only cares about the Ruby that was current at build time. You want that to be the same as the one Vim links to.

So, your try to using rvm use default sounds like the right thing to do. Did you run make clean before doing that? You really want to throw it all away and build using the exact same version that Vim links against.

(Not immediate relief, but in the long plan, my intention is to run Command-T in a separate process, which will make this kind of compilation mismatch a thing of the past. See #220 for that.)

@ecbrodie

This comment has been minimized.

Show comment
Hide comment
@ecbrodie

ecbrodie Jun 20, 2016

I just tried the following:

$ make clean
$ rvm use default
Using /REDACTED/.rvm/gems/ruby-2.1.6
$ make
compiling ext.c
compiling heap.c
compiling match.c
compiling matcher.c
compiling watchman.c
linking shared-object ext.bundle
ld: warning: directory not found for option '-L/Users/haven/.sm/pkg/active/lib'

However, it still does not appear to work. After I invoke Command-T in VIM, I get the following error:

command-t.vim could not load the C extension
Please see INSTALLATION and TROUBLE-SHOOTING in the help
Vim Ruby version: 2.0.0-p648
Expected version: 2.1.6-p336
For more information type: :help command-t

I can confirm that Ruby is pointed to the correct version before I ran make by running:

$ ruby --version
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-darwin14.0]

Maybe you want me to run make clean on VIM itself, since the Ruby version is linked at VIM build time? That would be a challenge since it was installed by Homebrew, but I'll give it a try (going to refer to online articles like http://greyblake.com/blog/2012/07/15/how-to-build-vim-against-specific-ruby-version/ and http://apple.stackexchange.com/questions/115127/change-compile-configuration-of-package-installation-in-brew).

I just tried the following:

$ make clean
$ rvm use default
Using /REDACTED/.rvm/gems/ruby-2.1.6
$ make
compiling ext.c
compiling heap.c
compiling match.c
compiling matcher.c
compiling watchman.c
linking shared-object ext.bundle
ld: warning: directory not found for option '-L/Users/haven/.sm/pkg/active/lib'

However, it still does not appear to work. After I invoke Command-T in VIM, I get the following error:

command-t.vim could not load the C extension
Please see INSTALLATION and TROUBLE-SHOOTING in the help
Vim Ruby version: 2.0.0-p648
Expected version: 2.1.6-p336
For more information type: :help command-t

I can confirm that Ruby is pointed to the correct version before I ran make by running:

$ ruby --version
ruby 2.1.6p336 (2015-04-13 revision 50298) [x86_64-darwin14.0]

Maybe you want me to run make clean on VIM itself, since the Ruby version is linked at VIM build time? That would be a challenge since it was installed by Homebrew, but I'll give it a try (going to refer to online articles like http://greyblake.com/blog/2012/07/15/how-to-build-vim-against-specific-ruby-version/ and http://apple.stackexchange.com/questions/115127/change-compile-configuration-of-package-installation-in-brew).

@wincent

This comment has been minimized.

Show comment
Hide comment
@wincent

wincent Jun 20, 2016

Owner
Vim Ruby version: 2.0.0-p648
Expected version: 2.1.6-p336

What this is saying that Vim is linked against 2.0.0, and Command-T is linked against 2.1.6, so that is not the correct version. Perhaps what you want is rvm use system (to select 2.0.0) and not rvm use default (which appears to be selecting 2.1.6). I haven't used RVM for a long time now, so sorry if my earlier comment that rvm use default looked correct has led you astray.

Owner

wincent commented Jun 20, 2016

Vim Ruby version: 2.0.0-p648
Expected version: 2.1.6-p336

What this is saying that Vim is linked against 2.0.0, and Command-T is linked against 2.1.6, so that is not the correct version. Perhaps what you want is rvm use system (to select 2.0.0) and not rvm use default (which appears to be selecting 2.1.6). I haven't used RVM for a long time now, so sorry if my earlier comment that rvm use default looked correct has led you astray.

@ecbrodie

This comment has been minimized.

Show comment
Hide comment
@ecbrodie

ecbrodie Jun 20, 2016

Okay, good point with rvm use system. This tip actually led to me solving the issue and getting Command-T to work! I tried just doing a make clean and then switching the RVM Ruby version to system before make, but that didn't work. However, rerunning ruby extconf.rb before the make commands worked! Now, I could go into my project's home directory (using a later Ruby version than system) and everything works great.

I would consider the original problem solved, but I do highly encourage Command-T to get that work to run the plugin in a separate process merged in soon, as it will greatly reduce the complexity of the installation and thus hopefully increase adoption of it. In the meanwhile, I will create a Pull Request to improve the documentation for RVM users like me. I think that linking the Pull Request to this issue is natural, so should we keep it open until the Pull Request is merged in?

Okay, good point with rvm use system. This tip actually led to me solving the issue and getting Command-T to work! I tried just doing a make clean and then switching the RVM Ruby version to system before make, but that didn't work. However, rerunning ruby extconf.rb before the make commands worked! Now, I could go into my project's home directory (using a later Ruby version than system) and everything works great.

I would consider the original problem solved, but I do highly encourage Command-T to get that work to run the plugin in a separate process merged in soon, as it will greatly reduce the complexity of the installation and thus hopefully increase adoption of it. In the meanwhile, I will create a Pull Request to improve the documentation for RVM users like me. I think that linking the Pull Request to this issue is natural, so should we keep it open until the Pull Request is merged in?

@ecbrodie

This comment has been minimized.

Show comment
Hide comment
@ecbrodie

ecbrodie Jun 20, 2016

Actually, upon further review of the documentation, it does look like make clean and RVM users switching version before ruby extconf.rb are indeed mentioned. Forget about the Pull Request. I will close the Issue.

Actually, upon further review of the documentation, it does look like make clean and RVM users switching version before ruby extconf.rb are indeed mentioned. Forget about the Pull Request. I will close the Issue.

@ecbrodie ecbrodie closed this Jun 20, 2016

@wincent

This comment has been minimized.

Show comment
Hide comment
@wincent

wincent Jun 20, 2016

Owner

Yeah, sorry. I should have mentioned ruby extconf.rb. Agreed that getting #220 out there will be huge. Given that I only work on Command-T on the side, it will be a while before it's all done, and also to get the full benefit from it you'll need a very recent version of Vim, but even so, it will still be a win.

Owner

wincent commented Jun 20, 2016

Yeah, sorry. I should have mentioned ruby extconf.rb. Agreed that getting #220 out there will be huge. Given that I only work on Command-T on the side, it will be a while before it's all done, and also to get the full benefit from it you'll need a very recent version of Vim, but even so, it will still be a win.

@asronihidayat

This comment has been minimized.

Show comment
Hide comment
@asronihidayat

asronihidayat Nov 4, 2017

@wincent i get running well on my vim, but in macvim still error like this,

command-t.vim could not load the C extension.
Please see INSTALLATION and TROUBLE-SHOOTING in the help.
Vim Ruby version: 2.0.0-p648
Expected version: 2.4.2-p198 

i followed command-t-compile instruction again and again, but still not work on mac vim. Hmm

@wincent i get running well on my vim, but in macvim still error like this,

command-t.vim could not load the C extension.
Please see INSTALLATION and TROUBLE-SHOOTING in the help.
Vim Ruby version: 2.0.0-p648
Expected version: 2.4.2-p198 

i followed command-t-compile instruction again and again, but still not work on mac vim. Hmm

@H1D

This comment has been minimized.

Show comment
Hide comment
@H1D

H1D Nov 7, 2017

I got the opposite on macvim:

command-t.vim could not load the C extension.
Please see INSTALLATION and TROUBLE-SHOOTING in the help.
Vim Ruby version: 2.4.2-p198
Expected version: 2.0.0-p648
For more information type:    :help command-t

H1D commented Nov 7, 2017

I got the opposite on macvim:

command-t.vim could not load the C extension.
Please see INSTALLATION and TROUBLE-SHOOTING in the help.
Vim Ruby version: 2.4.2-p198
Expected version: 2.0.0-p648
For more information type:    :help command-t

@wincent

This comment has been minimized.

Show comment
Hide comment
@wincent

wincent Nov 7, 2017

Owner

@asronihidayat, @H1D, would need some more information to troubleshoot further, like what OS version you are on, what version of Vim (and how you built it), how those different versions of Ruby got there. The output of the Vim and/or Command-T builds would help, as does vim --version.

In general, downloaded releases of MacVim links against the system Ruby, so you should be building Command-T using the system Ruby. If MacVim is using some other version of Ruby, I expect that you probably got it via some other way, like Homebrew. Either way, the solution is to build Vim and/or Command-T using matching versions (may require you to clean and rebuild if there is any confusion about what those versions should be).

Owner

wincent commented Nov 7, 2017

@asronihidayat, @H1D, would need some more information to troubleshoot further, like what OS version you are on, what version of Vim (and how you built it), how those different versions of Ruby got there. The output of the Vim and/or Command-T builds would help, as does vim --version.

In general, downloaded releases of MacVim links against the system Ruby, so you should be building Command-T using the system Ruby. If MacVim is using some other version of Ruby, I expect that you probably got it via some other way, like Homebrew. Either way, the solution is to build Vim and/or Command-T using matching versions (may require you to clean and rebuild if there is any confusion about what those versions should be).

@H1D

This comment has been minimized.

Show comment
Hide comment
@H1D

H1D Nov 7, 2017

@wincent thanks for your answer! I'll investigate further soon

H1D commented Nov 7, 2017

@wincent thanks for your answer! I'll investigate further soon

@H1D

This comment has been minimized.

Show comment
Hide comment
@H1D

H1D Nov 10, 2017

Well... I've updated macOS, XCode and reinstalled macvim. Now it's working

H1D commented Nov 10, 2017

Well... I've updated macOS, XCode and reinstalled macvim. Now it's working

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment