Textmate, Rvm and Tm_Ruby

TextMate, rvm and TM_RUBY

See your other, similar, question Rspec bundle is broken in TextMate and rvm.


To help others chasing this same issue, the solution seems to be at: RVM / Textmate doesnt recognize .rvmrc Options.

Basically you replace the ~/.rvm/bin/textmate_ruby soft link with a file. This is what I did:

  1. cd ~/.rvm/bin
  2. mv textmate_ruby old.textmate_ruby
  3. Create a shell script called textmate_ruby in the same directory to replace the soft-link, using the following contents:

    !/usr/bin/env sh

    source ~/.rvm/scripts/rvm
    cd .
    exec ruby "$@"
  4. chmod +x textmate_ruby

Before doing this change I'd see my system Ruby's version (1.8.7) displayed if I did CMD+R to run the following script in TextMate:

puts RUBY_VERSION

Evaluating the script using CMD+CNTRL+SHIFT+E gave me 1.9.2.

After switching to use that script both point to Ruby 1.9.2, so at least there's some consistency now. I don't see TextMate tracking my currently set RVM Ruby version yet; Instead it's using the default version set in RVM: rvm use 1.9.2 --default. This is still a step forward because I can control which Ruby TextMate uses by adjusting my --default.

If you decide you want to revert later, just rename, or delete, the script and reverse step 2 above.

Textmate + RVM + Rake = Rake not using expected gem environment

I solved my own problem.
Here are the details for anyone else who has this problem...

First, the answer in this question TextMate, rvm and TM_RUBY
is almost perfect.

I had to create a textmate_ruby, and a textmate_rake script, and reference them in the variables in text mate: TM_RUBY, and TM_RAKE.

Second, since I'm using zsh, I had to change the shebang line in the textmate_xxx scripts to use zsh.

Finally, the key that helped me arrive at the correct solution is that I modified my project rakefile to :

task :default do
system "gem env"
system "ruby --version"
system "pwd"
system "printenv"
end

Then when I ran the rake task in textmate, it would dump the current values of my environment, ruby version, current directory, and gem environment. This really helped to see what was going on.

Problem with ri + rvm + Textmate

After a lot of searching (and asking) around, solved it by reinstalling both Textmate (including delete of all customizations), and Ruby 1.9.2 (through RVM).
Afterwards I installed the osx-plist update + some bundles again. Note that the osx-plist update (as detailed here) should be done with system Ruby, not a Ruby 1.9, otherwise other errors occur.
Also in Textmate make sure the PATH variable does not have a custom Ruby before your system Ruby.

With these settings, everything works fine now. Hopefully this is useful to anyone encountering this error in the future...

How do I change the Ruby version Textmate uses?

Using the path that which ruby gave me didnt work. After googling for a while, I found a solution that worked, using the auto-ruby path of rvm as the TM_RUBY variable.
The path is:
/Users/0al0/.rvm/bin/rvm-auto-ruby
This only applies if you are using rvm, of course.

Using RVM with different gemsets in TextMate

I've found the RVM wrappers method to be very buggy, and as you've discovered it doesn't work at all with gemsets unless you do a lot of tedious setup.

I've had some success using the following script as TM_RUBY:

#!/bin/bash

base_dir=${TM_PROJECT_DIRECTORY:-$PWD}
cd $base_dir
exec $MY_RUBY_HOME/bin/ruby $*

As long as you're in a TextMate project and you have a .rvmrc file in the project root it will run your code in the Ruby version and gemset specified in the .rvmrc. The cd makes sure RVM discovers the .rvmrc.

Put the code above into ~/bin/textmate_ruby_wrapper and then go to Preferences > Advanced > Shell Variables and set TM_RUBY to that same path.

Rspec bundle is broken in TextMate and rvm

The best solution I've found is from Jacques Crocker.
http://groups.google.com/group/rubyversionmanager/browse_thread/thread/64b84bbcdf49e9b?fwc=1

It requires replacing the contents of textmate_ruby with the code below and never running rvm wrapper xxx textmate again.

#!/usr/bin/env sh 
source ~/.rvm/scripts/rvm
cd .
exec ruby "$@"

This has also fixed the same issue with the cucumber bundle.

Could not load ruby textmate?

check rvm alias list default or if you have any textmate references in your shell initialization files (~/.bash_profile, ~/.bashrc or similar file)

TextMate's Execute and Update ‘# =’ Markers evaluates with ruby 1.8 instead of 1.9

This is a good reference.

http://cl.ly/23Ylhttp://cl.ly/23Yl/rvm_textmate.png

Make sure you are running all the new versions.

Out of the box, rvm ships with a ruby binary, typically in ~/.rvm/bin (or, in system wide installs, inside of /usr/local/bin), that will perform the following steps before executing ruby:

Load up RVM
Look for any RVMRC files and load them
Execute as a normal ruby

This approach makes it possible to have the ruby switched on a per-project basis without any extra work. With rvm installed, this is a matter of taking the full path to rvm-auto-ruby, found via:

$ which rvm-auto-ruby

And in the advanced section of the textmate preferences, either adding or changing the TM_RUBY variable to point to the given path, like shown in this screenshot with an example installation.

Source: https://rvm.io/integration/textmate/

FWIW: Josh Cheek is great (rubykickstart)



Related Topics



Leave a reply



Submit