RBENV managed Rubies: VIM upgrade forcing homebrew to install Ruby

by Meltemi   Last Updated October 17, 2018 00:12 AM

I've recently switched from RVM to RBENV as my Ruby manager under MacOS Sierra.

$ rbenv version
2.3.1 (set by /Users/meltemi/.rbenv/version)
$ which ruby
/Users/meltemi/.rbenv/shims/ruby

I've used Homebrew to install packages like vim for years and never had Ruby version be installed via Homebrew.

Now when I brew upgrade vim I get a forced dependency install of Ruby.

==> Upgrading vim
==> Installing dependencies for vim: ruby
==> Installing vim dependency: ruby
==> Downloading https://homebrew.bintray.com/bottles/ruby-2.3.1_2.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ruby-2.3.1_2.sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/rake
Target /usr/local/bin/rake
already exists. You may want to remove it:
  rm '/usr/local/bin/rake'

To force the link and overwrite all conflicting files:
  brew link --overwrite ruby

To list all files that would be deleted:
  brew link --overwrite --dry-run ruby

Possible conflicting files are:
/usr/local/bin/rake
/usr/local/bin/rdoc
/usr/local/bin/ri
==> Caveats
Emacs Lisp files have been installed to:
  /usr/local/share/emacs/site-lisp/ruby
==> Summary
🍺  /usr/local/Cellar/ruby/2.3.1_2: 1,261 files, 18.8M

How can I get Homebrew (read: vim) to use the rbenv version of Ruby?



Answers 1


Ruby is a dependency for building vim with Homebrew according to the package details:

ianc.local
> brew info vim
vim: stable 8.0.0019 (bottled), HEAD
Vi "workalike" with many additional features
http://www.vim.org/
Conflicts with: ex-vi
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/vim.rb
==> Dependencies
Optional: lua ✘, luajit ✘
==> Requirements
Required: ruby >= 1.8 ✔, perl >= 5.3 ✔
Recommended: python ✔
Optional: python3 ✔
==> Options
--with-client-server
    Enable client/server mode
--with-custom-perl
    Build with a custom Perl instead of the Homebrew version.
--with-custom-python
    Build with a custom Python 2 instead of the Homebrew version.
--with-custom-ruby
    Build with a custom Ruby instead of the Homebrew version.
--with-lua
    Build vim with lua support
--with-luajit
    Build with luajit support
--with-mzscheme
    Build vim with mzscheme support
--with-override-system-vi
    Override system vi
--with-python3
    Build vim with python3 instead of python[2] support
--with-tcl
    Build vim with tcl support
--without-nls
    Build vim without National Language Support (translated messages, keymaps)
--without-perl
    Build vim without perl support
--without-python
    Build vim without python support
--without-ruby
    Build vim without ruby support
--HEAD
    Install HEAD version

But as you can see, it only requires ruby 1.8. It's installing a ruby because rbenv likely isn't returning an installed ruby when the ruby shim is called by the build package.

Given vim will dynamically link to your Ruby installation, I highly recommend you just switch to system ruby before you brew install or upgrade vim. Something like:

brew uninstall vim ruby
brew cleanup
rbenv global system
brew install --build-from-source vim --with-custom-ruby

The installer will happily use system ruby on the Mac, which has a high enough version, during installation and the resulting binaries created won't segfault if you happen to remove the specific ruby version they were built against, which is a real problem if you use a rbenv-controlled ruby at build time.

Alternatively you can build without ruby support:

brew install vim --without-ruby

But that's probably not what you want.

Ian C.
Ian C.
October 04, 2016 21:13 PM

Related Questions



install gpg with homebrew

Updated April 17, 2017 11:12 AM

Error when trying to "brew install rbenv"

Updated June 21, 2016 08:05 AM

Homebrew refuses to work on macOS Sierra

Updated October 07, 2016 09:05 AM