In TextMate 2, Execute and Update ‘# =>’ Markers menu action updates the markers in the following code as if I am running ruby 1.8 even though my TM_RUBY environment variable is set to ~/.rvm/rubies/ruby-1.9.3-p286/bin/ruby:
v = RUBY_VERSION # => "1.8.7"
puts "".singleton_class
puts v
# ~> -:2: undefined method `singleton_class' for "":String (NoMethodError)
Running the same code in TextMate 2, on the other hand, returns the expected command output:
#<Class:#<String:0x007fcf418941b8>>
1.9.3
This is a wonderful feature and it would be a real shame if it is limited to ruby 1.8. I suspect, however, that this may be peculiar to my setup (I have actually seen it work with 1.9 code here: http://ruby-kickstart.com/). Execute and Update ‘# =>’ Markers menu action is defined in the Ruby bundle where it calls xmpfilter from rcodetools:
#!/usr/bin/env bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
export RUBYLIB="$TM_BUNDLE_SUPPORT/vendor/rcodetools/lib${RUBYLIB:+:$RUBYLIB}"
export TM_RUBY=$(which "${TM_RUBY:-ruby}")
"${TM_RUBY}" -r "${TM_SUPPORT_PATH}/lib/ruby1.9/add_1.8_features.rb" -- "$TM_BUNDLE_SUPPORT/vendor/rcodetools/bin/xmpfilter"
The file add_1.8_features.rb only adds a few legacy methods to the String and File classes (e.g. grep and remove). Indeed, this enables it to support ruby 1.9 (see https://github.com/textmate/ruby.tmbundle/blob/master/Support/vendor/rcodetools/CHANGES).
At this point I am not even quite sure where does ruby 1.8 come from in the first place. Even passing the explicit path to the latest ruby instead of "${TM_RUBY}" in the last line above does not change the output.
I would be very grateful for any help that would allow me to use this (or equivalent) menu action in TextMate.