Loading ...
Sorry, an error occurred while loading the content.

setting GEM_PATH and GEM_HOME can crash vim

Expand Messages
  • Christian H√∂ltje
    This is really a bug in Ruby, I think. How to recreate on OSX: * Compile vim with ruby support, using the system ruby (/usr/bin/ruby, version 1.8.7-p358 in
    Message 1 of 1 , Dec 14, 2012
      This is really a bug in Ruby, I think.

      How to recreate on OSX:

      * Compile vim with ruby support, using the "system" ruby (/usr/bin/ruby, version 1.8.7-p358 in OSX 10.8)
      * Install RVM
      * Install Homebrew
      * brew install mysql
      * rvm install ruby-1.8.7 using the home-brew mysql.
      * rvm use ruby-1.8.7
      * gem install mysql
      * edit a ruby file in vim, and try to use ruby auto-complete.

      Looking at the crash reports, I can see vim is trying to use the /usr/local/ (home-brew) version of mysql.

      Basically, what's going on is that RVM alters the GEM_HOME/GEM_PATH to point at the rvm version of ruby-1.8.7 gems. The rvm mysql .so file is *not* compatible with the system ruby-1.8.7 -- They use different compilers and a different libmysql.so

      This causes vim to segfault.

      This can happen on any UNIX system that uses RVM or any other mechanism that changes the GEM_HOME/GEM_PATH before executing vim. It may work in some cases, but it's a crap shoot.

      The work around I'm using is this in my .zshrc:

      for i in /usr/local/opt/vim/bin/*(N) /usr/local/opt/macvim/bin/*(N); do
      i=$(basename $i)
      alias "${i}"="env -u GEM_PATH -u GEM_HOME command ${i}"

      It just unsets GEM_PATH and GEM_HOME before running vim, view, etc.

      I'm not sure what the "right" solution is. My first guess was just unset GEM_HOME/GEM_PATH internally when vim starts. But I could see cases where someone wants to pass them to vim's ruby.

      Possibly, you could unset these variables by default, but then have a flag to allow them to remain set.

      Ideally, libruby would be able to detect problems like this and just no load the modules, but it can be tricky if different compilers were used, etc. The differences can be subtle and hard to detect.


      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.