#110
May 23, 2008

Gem Dependencies

In Rails 2.1 we now have the ability to set gem dependencies. Now it's easier than ever to specify which ruby gems our rails app relies on.
Download (11.1 MB, 6:33)
alternative download for iPod & Apple TV (7.7 MB, 6:33)

Resources

# config/environment.rb
config.gem "RedCloth", :version => ">= 3.0.4", :source => "http://code.whytheluckystiff.net/"
config.gem 'aws-s3', :lib => 'aws/s3'

# config/environments/test.rb
config.gem 'mocha'
config.gem 'Shoulda'
rake -T gems
rake gems
rake gems:install
rake gems:unpack
rake gems:build
rake gems RAILS_ENV=test

RSS Feed for Episode Comments 36 comments

1. Aditya Sanghi May 23, 2008 at 00:25

Hi Ryan,

Is it still the norm to change environment.rb or should we be doing this in the initializers?

Cheers,
Aditya


2. kino May 23, 2008 at 01:00

very useful stuff. 10nx


3. Henrik N May 23, 2008 at 03:01

Minor thing: you can do RAILS_ENV=test instead of RAILS_ENV='test'.


4. Ryan Bates May 23, 2008 at 07:08

@Aditya, anything that uses "config" I like to keep in the environment.rb. Anything that doesn't (where you can specify it after the config) then move that into an initializer.

@Henrik, yeah, my quote finger was a little twitchy last night it seems. ;)


5. Andrew Chalkley May 23, 2008 at 16:55

Another great rails cast!

Could you do some on ActionMailer?


6. Sebastian May 25, 2008 at 05:16

@Andrew - ActionMailer is good described in Agile Webdevelopment.


7. Jon Buda Jun 04, 2008 at 07:13

Ryan, as always great videos. Loved the 2.1 updates. I've recently been using config.gem and I think I found a problem using it with BlueCloth: http://railsforum.com/viewtopic.php?id=18850

Any idea whats going on here?


8. Faktura Jun 05, 2008 at 14:11

Greta video!


9. Mark Jun 23, 2008 at 08:36

Thanks for another great screencast. I just came across a gem's instructions to use:
 :version => '~> 2.3.2'

What does ~> mean?


10. Mark Jun 23, 2008 at 08:52

Nevermind, there was an explanation:

gem 'mislav-will_paginate', '~>2.1'
# this will load any 2.x version
#(greater or equal to 2.1),
# but not 3.x


11. jan Jul 06, 2008 at 03:16

nice video :) thanks!


12. madan Aug 20, 2008 at 00:59

I am currently using mislav-will_paginate gem.
When I give it in environment.rb, it shows me 'mislav-will_paginate' file not found. I have given the proper version and source. Still it shows me the same error. How can I get rid of this error?


13. Matt Aug 29, 2008 at 11:50

I'd love to see how to make a gem plugin, similar to how you made a normal plugin in episode 33!


14. jhxc Sep 07, 2008 at 09:14

@madan, I had the same problem with a number of gems. It happens when the library module you're going to use is named differently from the gem. For example if you say

  config.gem 'chardet'

=> rake can install the gem, but not unpack it, and rails gives the error

  no such file to load -- chardet

and script/about gives the error

  These gems that this application depends on are missing:
   - chardet

To avoid this, you have to specify the name of the module:

  config.gem 'chardet', :lib=>'UniversalDetector'


15. jhxc Sep 07, 2008 at 09:19

config.gem "mislav-will_paginate", :lib => "will_paginate"

see http://rails.lighthouseapp.com/projects/8994/tickets/293-gem-dependencies-broken-in-2-1-0


16. Scooter Center Oct 16, 2008 at 18:07

@jhxc
thanks for the explanation!

@ryan
you made me smile ;-)


17. Anthony Ettinger Nov 13, 2008 at 18:05

Getting wrong number of arguments error, environment.rb:13


19. Toles Nov 21, 2008 at 23:22

Justs another great screencast. Very helpful - Thanks


21. Jing Nov 29, 2008 at 06:06

Thanks for making this feature clear. The podcast really helps.


22. webdesigner Dec 03, 2008 at 01:28

The rake gems:install command is very useful.

Great screencast again - thank you.


24. John Griffiths Dec 05, 2008 at 13:55

excellent stuff, helped out my cms setup.

love the capistrano stuff, will simplify things greatly ;-)


24. gwhf Dec 10, 2008 at 05:31

<a href="http://www.cerkezkoynakliyat.com/" title="evden eve nakliyat">evden eve nakliyat</a>
<a href=" http://izmir.ankara-nakliyat-firmalari.com/" alt="evden eve nakliyat"> evden eve nakliyat</a>
<a href="http://www.evdenevenakliyatt.biz/" class="menu" target="_blank"><font color="#FFFFFF">evden eve nakliyat</font></a>


26. Dimas Priyanto Jan 11, 2009 at 03:59

Hi all..
How do we know where is the :lib option for gem is located? I've tried to catch it from gem documentation, i've gotten for some gems and the others aren't provide it..


27. Ethan - Iphone Jan 12, 2009 at 03:34

hello! thanx to everyone. you provide and always give a very useful information.. for me it's clear now what the functioning of the rails applications..


29. türkei urlaub Jan 23, 2009 at 16:43

very interesting video


30. türkei urlaub Feb 08, 2009 at 12:27

I have downloaded 2.1 version and it worked very vell. thanks a lot


33. oki Apr 07, 2009 at 00:45

<li>最強<a href="http://love-single.net">出会い系</a>サイト!新しい<a href="http://www.2bconnected.com/">メル友</a>との<a href="http://mailcental.com/">出会い</a>をあなたへ!</li><li>夢のような<a href="http://adultforeplay.com/">出会い系</a>サイト!確実に<a href="http://www.grandtetonmountainbiking.com/">メル友</a>と<a href="http://www.sm-castle.com/">出会い</a>たい人は必見です!</li><li>かわいい<a href="http://www.bargains4baby.com/m/">メル友</a>!かっこいい<a href="http://www.mstcor.com/">メル友</a>!<a href="http://meetcho.com">出会い系</a>サイトでも素敵な<a href="http://www.deai-navi.mobi/">出会い</a>はあるんです!</li>


34. Brian Armstrong Apr 11, 2009 at 14:18

If anyone is having trouble uninstalling a gem from your home directory ~/.gem please check out this link:

http://blog.floehopper.org/articles/2009/02/16/uninstalling-gems-from-gem-directory

This was frustrating for me and I had to do this to fix it:
gem uninstall <gem-name> --install-dir=~/.gem/ruby/1.8/

and then run "sudo rake gems:install"


36. Diyet Listeleri Apr 29, 2009 at 07:43

thank you so much
it is great....


37. Harbest Jun 11, 2009 at 00:55

<h1><font size="2" color="#CC0066">夏に向けてのメル友探しはココからっ!!</font></h1><p><strong><h2><font size="2" color="#009999">優良メル友サイト</font></h2><font color="#009999">Gril Friend☆゚+.<a href="http://funlovemoney.com/gril_friend/">メル友</a>サイト゚+.☆<br />You&Me<a href="http://www.wetwetweb.com/you&me/">メル友</a><br />Survivor【<a href="http://njlyme.com/survivor/">メル友</a>サイト】<br /><a href="http://www.rankedhigh.com/lost_man/">メル友</a>サイト-LOST MAN-<br /><a href="http://deai-k.net/supernova/">メル友</a>サイト【Supernova】</font>

<font color="#FF6600"><strong>激熱☆一押し携帯さいと~ヾ(´ー`)ノ</strong></font><br /><font color="#CC0066">無料<a href="http://www.thewoodtrader.com/">出会い</a>サイト-恋人探し-</font>


38. Jason Coffin Jun 16, 2009 at 09:07

Anyone know if there is a way to send build options to 'rake gems:build'? I need to set the '--with-mysql-dir=/usr/local/mysql' for the mysql gem.


39. turquie voyage Jun 17, 2009 at 15:13

very good article


40. tiffanys Jun 30, 2009 at 22:59

thanks
http://www.edhardyshop.us


41. mortgage rates Jun 30, 2009 at 23:17

COOL


42. ed hardy Jun 30, 2009 at 23:18

ok


43. abercrombie Jun 30, 2009 at 23:21

Just soso

Add your comment:

(SKIP THIS ONE)

(required)

(not shown)


(use pastie or gist for code)

sponsored by:
if you want to help:
required:
Get Quicktime Player