Macvim: Can't invoke ruby

Created on 4 Nov 2017  路  7Comments  路  Source: macvim-dev/macvim

When I type :ruby puts 'hi'
It comes up with

E370: Could not load library libruby.2.0.dylib
E266: Sorry, this command is disabled, the Ruby library could not be loaded. 

mvim --version reports

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov  4 2017 04:39:11)
macOS version
Included patches: 1-1257
Compiled by [email protected]
Huge version with MacVim GUI.  Features included (+) or not (-):
+acl             +find_in_path    -mouse_sysmouse  -tag_any_white
+arabic          +float           +mouse_urxvt     -tcl
+autocmd         +folding         +mouse_xterm     +termguicolors
+balloon_eval    -footer          +multi_byte      +terminal
+browse          +fork()          +multi_lang      +terminfo
++builtin_terms  +fullscreen      -mzscheme        +termresponse
+byte_offset     -gettext         +netbeans_intg   +textobjects
+channel         -hangul_input    +num64           +timers
+cindent         +iconv           +odbeditor       +title
+clientserver    +insert_expand   +packages        +toolbar
+clipboard       +job             +path_extra      +transparency
+cmdline_compl   +jumplist        +perl/dyn        +user_commands
+cmdline_hist    +keymap          +persistent_undo +vertsplit
+cmdline_info    +lambda          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python/dyn      +viminfo
+cscope          +lispindent      +python3/dyn     +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con_gui  +lua/dyn         +rightleft       +windows
+diff            +menu            +ruby/dyn        +writebackup
+digraphs        +mksession       +scrollbind      -X11
+dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     +xim
+emacs_tags      +mouseshape      +startuptime     -xpm
+eval            +mouse_dec       +statusline      -xsmp
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_clipboard
+extra_search    -mouse_jsbterm   +syntax          -xterm_save
+farsi           +mouse_netterm   +tag_binary      
+file_in_path    +mouse_sgr       +tag_old_static  
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  system gvimrc file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
    system menu file: "$VIMRUNTIME/menu.vim"
  fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe  -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -L/usr/local/lib -L. -L/usr/local/lib  -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon       -lm  -lncurses -liconv -framework AppKit   -fstack-protector  -L/System/Library/Perl/5.16/darwin-thread-multi-2level/CORE 

Does anyone has the same problem ???

Most helpful comment

It's intentional. MacVim binary release supports Ruby 2.4 at this time. Since Homebrew default version has already been Ruby 2.4. One of the easiest solution is brew install ruby.

All 7 comments

Same problem with lua

E370: Could not load library liblua.5.2.dylib
Lua library cannot be loaded.

You need to install Ruby 2.0.x and Lua 5.2.x for the current binary release (The next binary release supports Ruby 2.4.x though.) Also you may need to set rubydll and/or luadll in your .vimrc. something like

set rubydll=/usr/local/lib/libruby.2.0.dylib
set luadll=/usr/local/Cellar/lua52/5.2.1/lib/liblua.dylib

Thanks, it works 馃槝

I also ran into this issue after updating MacVim to the latest version. All prior versions of MacVim I used worked fine without any rubydll or libruby.dylib.

Also I had to reinstall ruby (many ruby installations don't have a shared library by default, see: https://github.com/rbenv/ruby-build/issues/35 for example)

Therefore my question: Is this change (introducing a dependency on a shared ruby lib) intentional? Does anybody know the background?

It's intentional. MacVim binary release supports Ruby 2.4 at this time. Since Homebrew default version has already been Ruby 2.4. One of the easiest solution is brew install ruby.

By the way, MacVim binary release has been requiring libruby dylib if you want to use Ruby interface. Start from snapshot-142, MacVim binary release supports Ruby 2.4.x libruby dylib binary. Before that, MacVim had been depending on Ruby 2.0.x libruby dylib binary which was already there in macOS system. But it was outdated in terms of using Ruby and macOS 10.13 adopted Ruby 2.3 instead. So the best solution is just using the latest stable, Ruby 2.4. just like using Python 3.6.3 for Python interface in MacVim binary release.

The easiest way to use Ruby interface with MacVim binary release is installing https://brew.sh/ and executing brew install ruby. No need to set up rubydll with that.

@splhack Thank you for the explantaion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bdarfler picture bdarfler  路  4Comments

romainl picture romainl  路  5Comments

flaugher picture flaugher  路  4Comments

itsayellow picture itsayellow  路  4Comments

epheien picture epheien  路  4Comments