Creating your own RubyGem mirror
In case you want to create your own RubyGem mirror here’s how I did mine.
From now on, let’s pretend we will store the mirrored gems in : /data/rubygems.mirror
First you need to create a config file (YAML format) specifying the source and destination for your mirror (put it in /data/gemmirror.config for example) :
---
- from: http://gems.rubyforge.org
to: /data/rubygems.mirror
- from is the master mirror you will pull from
- to is the directory where your mirror files will be stored
Then all you have to do is to add this commands as a cron task :
/usr/bin/gem mirror --config-file=/data/gemmirror.config && /usr/bin/gem generate_index -d /data/rubygems.mirror
/usr/bin/gem mirror —config-file=/data/rubygemmirror : will mirror the gems using informations in /data/rubygemmirror
file
/usr/bin/gem generate_index -d /data/rubygems.mirror : will generate an optimized index to reduce the datas transfered on index update
Here’s what you asked for Nick !
Fri, 23 May 2008 22:06 Posted in Ruby
8 comments »
-
By Steve 02/06/2008 at 06h57
-
By Jonathan Tron 14/06/2008 at 15h48
Try rewriting the config file as :
--- from: http://gems.rubyforge.org to: /temp/gems
thus not enclosing the hash ({:from => …, :to => …}) in an array.
-
By Nick 16/10/2008 at 20h04
Thanks.
I suppose then I set up a web server to provide that directory, and use that address as the source?
Also, how much space will it take?
Thanks again.
-
By Jonathan Tron 16/10/2008 at 23h24
Currently my mirror uses 3.6GB.
-
By newbie 31/01/2011 at 08h27
it has error
undefined method `has_key?’ for [“from”, “http://gems.rubyforge.org”]:Arrayhow can i fix this??
-
By linux 20/04/2011 at 10h03
I am not sure where you are getting your information, but great topic
-
By Renato Isidio 28/06/2011 at 16h52
Hi Jonathan,
I know this post is too old, but im facing a problem with directory with too many gems. Its 129000 gems. I know this can cause a problem reading/writing into it, but we cant index a directory with hash, like /a/amanda.gem /b/bush.gem. And theres also a problem on mirroing it. It will mirror all gems inside one directory. Is there another way doing it? Could you help me?
Thank you very muhc in advance.Best Regards.
Renato Isidio
Rio de Janeiro – Brazil -
By carlos castillo 28/04/2012 at 02h16
Renato,
why kind of OS are you using? I just setup a mirror using CENTOS and I did not have any issues with the number of files.
Hi there, no matter what I do I get an error as follows:
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/config_file.rb:98:in `initialize’: undefined method `key?’ for [{"from"=>"http://gems.rubyforge.org", “to”=>"/temp/gems"}]:Array (NoMethodError)
It looks like my config file is begin parsed correctly. It looks like this:
Any ideas? I’m at my wits end!