gem install HELL

I spent the better part of my day trying to make some things work in bash, and learned some neat tricks, but I'll leave that for another time.

Since I've started using Ruby for some things, like this blog, I decided to try and make use of Rake to automate some of my tasks.

I was trying to camelcase a string when fellow pyjama coder Neil Lalonde, of FitLogg fame notified me that there was a gem that could handle that.

Note, I'm using Mac OS X and I already had some Ruby related stuff installed from previous attempts at using Rails and Redmine.

Cool, all I have to do is:

"my_string".camelize

Easy enough, let's get to it.

~] gem install activesupport
~] gem list

*** LOCAL GEMS ***

actionmailer (2.3.5, 2.2.2, 1.3.6)
actionpack (2.3.5, 2.2.2, 1.13.6)
actionwebservice (1.2.6)
activerecord (2.3.5, 2.2.2, 1.15.6)
activeresource (2.3.5, 2.2.2)
activesupport (3.1.3, 2.3.5, 2.2.2, 1.4.4)
acts_as_ferret (0.4.3)
...

It seems I've installed activesupport more than once, lol. I told Neil because I thought it was funny. And he suggested to "haha, remove the old ones!". I thought that was a good idea. A mighty fine suggestion. Being the Ruby noob that I am, I type this.

~] gem help uninstall
Usage: gem uninstall GEMNAME [GEMNAME ...] [options]
...
  Defaults:
    --version '>= 0' --no-force --install-dir /Library/Ruby/Gems/1.8
    --user-install

I saw the --version '>= 0' so maybe there's a '<= 3'.

~] gem uninstall activesupport '<= 3'
INFO:  gem "activesupport" is not installed

Weird.

~] gem uninstall activesupport -v='1.4.4'
INFO:  gem "activesupport" is not installed
~] gem list
...
activesupport (3.1.3, 2.3.5, 2.2.2, 1.4.4)
...

I'm confused. Rubygems says it's installed and says it's not installed. Could it be because I might've used sudo to install some gems in the past? Oh well, maybe the gem will still work.

~] irb
>> require "activesupport"
NameError: uninitialized constant ActiveSupport::Dependencies::Mutex
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:55
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support.rb:56
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
  from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/activesupport.rb:1
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:59:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:59:in `require'
  from (irb):2

Nope.

~] sudo gem uninstall activesupport -v=1.4.4
Password:
INFO:  gem "activesupport" is not installed
~] sudo gem list
...
activesupport (3.1.3, 2.3.5, 2.2.2, 1.4.4)
...

What the F#@K.

At this point, I did some googling and found the directory where the gems are installed on OS X. Neil also gave me a hint "sudo gem env might tell you where it is". Seems a lot of people have this problem.

~] sudo gem env
RubyGems Environment:
...
  - GEM PATHS:
     - /Library/Ruby/Gems/1.8
     - /Users/don/.gem/ruby/1.8
     - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
...
~] ls /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems
...
drwxr-xr-x   3 root  wheel   102 18 May  2009 activesupport-1.4.4
drwxr-xr-x   3 root  wheel   102 18 May  2009 activesupport-2.2.2
drwxr-xr-x   3 root  wheel   102 11 Feb  2010 activesupport-2.3.5
...

There they are :D Owned by root, nonetheless. Ah, the days before RVM.

~] gem list -d activesupport

*** LOCAL GEMS ***

activesupport (3.1.3, 2.3.5, 2.2.2, 1.4.4)
    Author: David Heinemeier Hansson
    Homepage: http://www.rubyonrails.org
    Installed at (3.1.3): /Library/Ruby/Gems/1.8
                 (2.3.5): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
                 (2.2.2): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
                 (1.4.4): /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

    A toolkit of support libraries and Ruby core extensions extracted
    from the Rails framework.
~] sudo gem uninstall activesupport -i /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

Select gem to uninstall:
 1. activesupport-1.4.4
 2. activesupport-2.2.2
 3. activesupport-2.3.5
 4. All versions
> 4

You have requested to uninstall the gem:
  activesupport-1.4.4
actionpack-1.13.6 depends on [activesupport (= 1.4.4)]
activerecord-1.15.6 depends on [activesupport (= 1.4.4)]
rails-1.2.6 depends on [activesupport (= 1.4.4)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Successfully uninstalled activesupport-1.4.4

You have requested to uninstall the gem:
  activesupport-2.2.2
actionpack-2.2.2 depends on [activesupport (= 2.2.2)]
activerecord-2.2.2 depends on [activesupport (= 2.2.2)]
activeresource-2.2.2 depends on [activesupport (= 2.2.2)]
rails-2.2.2 depends on [activesupport (= 2.2.2)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Successfully uninstalled activesupport-2.2.2

You have requested to uninstall the gem:
  activesupport-2.3.5
actionpack-2.3.5 depends on [activesupport (= 2.3.5)]
activerecord-2.3.5 depends on [activesupport (= 2.3.5)]
activeresource-2.3.5 depends on [activesupport (= 2.3.5)]
rails-2.3.5 depends on [activesupport (= 2.3.5)]
If you remove this gems, one or more dependencies will not be met.
Continue with Uninstall? [Yn]  Y
Successfully uninstalled activesupport-2.3.5
~] gem list
...
activesupport (3.1.3)
...

Whee, they're gone!

~] irb
>> require "rubygems"
false
>> require "activesupport"
LoadError: no such file to load -- activesupport
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
  from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:36:in `require'
  from (irb):1

Still have another issue...more googling.

~] which ruby
/usr/bin/ruby
~] gem env | grep "RUBY EXECUTABLE"
  - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
~] ls /usr/bin/ruby*
lrwxr-xr-x  1 root  wheel  76  5 Jul  2010 /usr/bin/ruby -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
~] ls /usr/bin/gem*
lrwxr-xr-x  1 root  wheel  71  5 Jul  2010 /usr/bin/gem -> ../../System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem
~] ls ../../System/Library/Frameworks/Ruby.framework/Versions/
total 8
drwxr-xr-x  4 root  wheel  136  5 Jul  2010 .
drwxr-xr-x  6 root  wheel  204 28 Sep  2010 ..
drwxr-xr-x  6 root  wheel  204 28 Sep  2010 1.8
lrwxr-xr-x  1 root  wheel    3  5 Jul  2010 Current -> 1.8

That didn't help.

Oh, found the solution.

~] irb
>> require "active_support"
=> true
>> require "active_support/inflector"
=> true
>> "i_am_a_pyjama_coder".camelize
>> => "IAmAPyjamaCoder"

Silly me, to use activesupport you have to require active_support. This site and this site don't tell you how to use it. Just tells you how to use rubygems to install it. Of course, it makes sense. It's really called Active Support. "activesupport" is only used for everything related to installing and documentation uses ActiveSupport. To top it off, someone decided to make it so you had to require "active_support" in your code, to use it.

Next thing I'll probably do, is uninstall every gem and properly setup RVM with gemsets. I'm soooooooo looking forward to that.

I can finally camelize text. And here's all you gotta do.

gem install activesupport

Edit: I created a follow up post on setting up an rvm environment.

©2018 Donald Chea, Pyjama Coder