#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 48 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. Henrik N May 23, 2008 at 03:01

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


3. 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. ;)


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

Another great rails cast!

Could you do some on ActionMailer?


5. 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?


6. 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?


7. 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


8. jan Jul 06, 2008 at 03:16

nice video :) thanks!


9. 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?


10. 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!


11. 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'


12. 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


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

@jhxc
thanks for the explanation!

@ryan
you made me smile ;-)


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

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


15. Toles Nov 21, 2008 at 23:22

Justs another great screencast. Very helpful - Thanks


16. Jing Nov 29, 2008 at 06:06

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


17. webdesigner Dec 03, 2008 at 01:28

The rake gems:install command is very useful.

Great screencast again - thank you.


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

excellent stuff, helped out my cms setup.

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


19. 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..


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

very interesting video


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

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


22. 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"


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

thank you so much
it is great....


24. 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.


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

very good article


26. ptlue Aug 25, 2009 at 00:45

come here is my hornor


27. bölgesel zayıflama Sep 02, 2009 at 06:09

I will use Gem Dependencies download


28. Facebook video izle Nov 26, 2009 at 01:29

i download it. nice


29. i like online ugg boots Dec 06, 2009 at 17:32

you article is very good,thnx.


30. zayıflama Feb 07, 2010 at 02:41

good


31. tyf Feb 21, 2010 at 14:09

good videos<a href="http://videojen.net/" title="video izle" target="_blank">video izle</a>
<a href="http://www.pornoizlesex.com/" title="video izle" target="_blank">sikiş</a>
<a href="http://www.pornoizle69.tk/" title="video izle" target="_blank">sikiş</a>


32. tyd Feb 21, 2010 at 14:10

dfsdfsdagfgaga


33. yatakta sevişme Mar 22, 2010 at 10:32

popular, which makes it easy for colleges and universities has straight hair. So you can always have a beautiful flowing straight hair, the use of imported PTC heating elements


34. kapadokya otelleri Mar 22, 2010 at 10:33

makes it easy for colleges and universities has straight hair. So you can always


35. erotizm Mar 22, 2010 at 10:34

How do we know where is the


36. Jay Mar 25, 2010 at 12:33

Ryan,

Do you know if there is a way to override the location of where the gems:unpack will go rather than having them go under vendor/gems? This is a case where multiple rails applications use the same version of a gem and we want to only store one copy of it in source control. Also is there a way to tell rake to look in a directory for gems and when you run gems:unpack so they are grabbed from the shared directory? Thanks in advance.


37. Dollarkurs Apr 07, 2010 at 05:27

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


38. dalaman rent a car Apr 12, 2010 at 10:59

Thanks you admin, I have read this now.


39. arac kiralama May 11, 2010 at 06:50

kapadokyas arac kiralama


40. Statistics Tutor May 14, 2010 at 23:01

Great post!


41. MBT NFL JARDON AIR MAX GHD Jun 01, 2010 at 01:52

It's great to see an article like this. www.mbtselling.com www.jerseystown.com www.dunkjordan.com www.airmaxsupplier.com www.ghdbeautyhair.com


42. Gary Jun 27, 2010 at 19:14

Through my 27 years of infinite wisdom (my parents always said I was a smart-ass), I've learned a few things. Women, yea I consider myself an expert in the female area if you know what I mean (wink) - and the most important thing I've learned is to stay away from a woman on her PMS days. In fact, I've put together a few acronyms (abbreviations) based on my experience with the syndrome.


43. cool electronic gadgets Jul 20, 2010 at 23:59

Good article,also welcome to visit http://www.eleczilla.com/


44. jordans shoes Jul 25, 2010 at 23:02

 Very good article. Thank you for sharing. Good luck


45. asics shose Jul 28, 2010 at 00:19

Thanks you admin, I have read this now.


46. handed Jul 30, 2010 at 00:39

<a href="http://zayiflama-bilgileri.blogspot.com/">Zayıflama</a></div>


47. timberlandbootsuk Aug 02, 2010 at 02:05

we provide our buyers with an efficient and manageable procurement process covering every phase of the international supply chain and

streamlining trade channels. Also welcome wholesaling, feedback now!


48. Start Sharing Not Selling Aug 02, 2010 at 04:52

Just saying thanks will not just be sufficient, for the wonderful clarity in your writing. I will instantly grab your rss feed to stay informed of any updates.


49. Wholesale Accessories Aug 03, 2010 at 02:05

Greet,Thanks you admin, I have read this now.


50. UGG Classic Argyle Knit Aug 03, 2010 at 22:52

  This is all very new to me and this article really opened my eyes.Thanks for sharing with us your wisdom.


51. Cheap Classic Crochet Uggs 5833 Aug 03, 2010 at 22:53

  Amazing stuff,Thanks so much for this!This is very useful post for me. This will absolutely going to help me in my projects .


52. jannazdl Aug 05, 2010 at 02:45

good post as the products like in http://www.eleczilla.com


53. free directory list Aug 11, 2010 at 22:27

I really appreciate what you post.


54. nike air max 2009 Aug 19, 2010 at 20:23

i agree with your point it very useful articles


55. Air Jordan Retro Aug 19, 2010 at 20:54

Great post! I will instantly grab your rss feed to stay informed of any updates.


56. jordan 1 Aug 23, 2010 at 23:54

that's really great news

i never heard it before

nice post

look forward your new posts
welcome to


57. black strappy sandals Aug 25, 2010 at 00:45

it's a good application. Thanks


58. louis vuitton shoes Aug 26, 2010 at 20:57

Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it. My readers have about the same interets


59. Wholesale Electronics Aug 27, 2010 at 00:56

Discount Wholesale Electronics, Wholesale Cell Phones, Electronic Gadgets and More from the Best Dropship Wholesaler


60. nike air max 2009 Aug 28, 2010 at 05:00

i agree with your point it very useful articles


61. mbt shoe uk Aug 30, 2010 at 01:33

 I love your post, thank you for sharing.


62. snow boots Aug 31, 2010 at 00:20

Justs another great screencast. Very helpful - Thanks


63. qwrrttyt Sep 01, 2010 at 10:47

Nice site


64. levis belts Sep 01, 2010 at 21:02

Good article! Thank you so much for sharing this post.Your views truly open my mind.

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
Give Back to Open Source