[TxMt] Textmate cannot find Ruby gems

Cary Swoveland cary at swoveland.com
Thu Sep 16 03:51:15 UTC 2010

I need help getting Textmate to find gems.  I've spent quite a bit of type
researching the problem, but being new to both OS X (Snow Leopard) and the
use of Ruby gems, I can't seem to figure out what the problems are.  Many
others have had similar problems, but their solutions don't seem to fix my
problems.  (Among other things, I did read Section 8--Shell Commands--of the
Textmate manual.) I expect it largely has to do with the setting of
environmental variables, but that's just a guess.  A secondary--and no doubt
related--problem is that Ruby cannot find the gem active-record when invoked
in a terminal (or in irb), as shown below.

I've tried entering a TM_PATH shell variable in Textmate preferences, but
that hasn't helped. 

Here are some possible clues.  No doubt I have provided some unnecessary
information and have left out important information.  

I recently used RVM (Ruby Version Manager) to reinstall Ruby.  From a
terminal I then ran
gem install xml-simple
gem install sqlite3
gem install activerecord
They all appeared to install OK.

Then I wrote the following short script (test.rb):
# Ruby 1.9.2

require 'rubygems'
print 'Gem.path = '
puts Gem.path
print 'ruby_description = '

require 'xmlsimple'
require 'sqlite3'
require 'active-record'

When I run test.rb in a terminal I get:
MacBook-Pro-2:economics101 cary$ ruby test.rb
Gem.path = /Users/cary/.rvm/gems/ruby-1.9.2-p0
/Users/cary/.rvm/gems/ruby-1.9.2-p0 at global
ruby_description = ruby 1.9.2p0 (2010-08-18 revision 29036)
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load
-- activerecord (LoadError)
	from <internal:lib/rubygems/custom_require>:29:in `require'
	from test.rb:12:in `<main>'

When I run Ruby test.rb from within Textmate (cntrl-r), I get: 
Gem.path = 
/Users/cary/.rvm/gems/ruby-1.9.2-p0 at global
ruby_description = ruby 1.9.2dev (2010-07-02 revision 28524)
LoadError: no such file to load — sqlite3

method require	in test.rb at line 11
method <main>	in test.rb at line 11
copy output
(If I have <require 'active-record'> before <require 'sqlite3'>, I get the
same message, with 'active-record' substituted for 'sqlite3'.)

Notice that xmlsimple was found when running test.rb from a terminal, but
not with cntrl-r in Textmate.  See below (near the end) where I think
Textmate found xmlsimple.

Next I ran irb:
MacBook-Pro-2:~ cary$ irb
/Users/cary/.rvm/rubies/ruby-1.9.2-p0/bin/irb:4: warning: Insecure world
writable dir /Users/cary in PATH, mode 040777

ruby-1.9.2-p0 > RUBY_DESCRIPTION
 => "ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]" 

ruby-1.9.2-p0 > Gem.path
 => ["/Users/cary/.rvm/gems/ruby-1.9.2-p0",
"/Users/cary/.rvm/gems/ruby-1.9.2-p0 at global"] 

ruby-1.9.2-p0 > require 'xmlsimple'
 => true 

ruby-1.9.2-p0 > require 'sqlite3'
 => true 

ruby-1.9.2-p0 > require 'active-record'
LoadError: no such file to load -- active-record
	from <internal:lib/rubygems/custom_require>:29:in `require'
	from <internal:lib/rubygems/custom_require>:29:in `require'
	from (irb):1
	from /Users/cary/.rvm/rubies/ruby-1.9.2-p0/bin/irb:17:in `<main>'

(ibr's message, "warning: Insecure world writable dir /Users/cary in PATH,
mode 040777" is something I should look into as well.)

(It makes no difference if I precede the above with <'require rubygems'>.)

and then back at a terminal:
MacBook-Pro-2:~ cary$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]

MacBook-Pro-2:~ cary$ which ruby

MacBook-Pro-2:~ cary$ echo $PATH
/Users/cary/.rvm/gems/ruby-1.9.2-p0 at global/bin:

MacBook-Pro-2:~ cary$ ls /Users/cary/.rvm/gems/ruby-1.9.2-p0
bin		cache		doc		gems		specifications

MacBook-Pro-2:~ cary$ ls /Users/cary/.rvm/gems/ruby-1.9.2-p0/gems
activerecord-3.0.0	arel-1.0.1		ffi-0.6.3		rake-0.8.7		tzinfo-0.3.23
activesupport-3.0.0	builder-2.1.2		i18n-0.4.1		sqlite3-0.1.1	

MacBook-Pro-2:economics101 cary$ ls
/Users/cary/.rvm/gems/ruby-1.9.2-p0 at global/gems
MacBook-Pro-2:economics101 cary$ 

MacBook-Pro-2:economics101 cary$ ls /usr/local/lib/ruby/gems/1.9.1/gems
libxml-ruby-1.1.4	xml-simple-1.0.12
The last line suggests to me that, from Textmate, Ruby is using an old
version of xlm-simple.

Any help would be greatly appreciated.

View this message in context: http://old.nabble.com/Textmate-cannot-find-Ruby-gems-tp29724886p29724886.html
Sent from the textmate users mailing list archive at Nabble.com.

More information about the textmate mailing list