English 中文(简体)
Ruby gems repository
原标题:

I m trying to set a gem repository on one of our local servers. Here are the steps I m running, that I ve followed from several guides.

1) I create the BASEDIR folder /var/www/html/gems
2) sudo cp -r /usr/lib/ruby/gems/1.8/gems/someGem /var/www/html/gems
3) sudo gem generate_index -d /var/www/html/gems

However, when I run this, I get the following output:

Loading 0 gems from /var/www/html/gems

Loaded all gems
Generating quick index gemspecs for 0 gems

Complete
Generating specs index
Generating latest specs index
Generating quick index
Generating latest index
Generating Marshal master index
Generating YAML master index for 0 gems (this may take a while)

Complete
Compressing indicies

It s not loading the gem for some reason. I did see a guide that recommended making the BASEDIR as /var/www/html/rubygems/ and then further make a gems/ directory within the BASEDIR and copy the desired gems to this gems/ directory. I also tried this, but was getting the same results.

Our server had the unfortunate luck of having the same configuration as mentioned in this post (RHEL5, ruby 1.8.5, /var and /tmp on separate partitions), but we upgraded as suggested to ruby 1.8.6, but it still won t load the gem.

Has anyone come across this? Found a solution?

最佳回答

I stumbled upon my old post and realized I d actually solved this some time ago, so I figured I d post my answer.

The problem was my step 2: copy gems action.

In the OP, I had tried

2) sudo cp -r /usr/lib/ruby/gems/1.8/gems/someGem /var/www/html/gems

What I found was that I needed to copy the actual .gem files, which lived at .../gems/1.8/gems/cache . So what I really needed to do for step 2 is:

sudo cp .../gems/1.8/gems/cache/*.gem /var/www/html/gems

After copying the gems correctly, the indexing worked as expected, and we could then use our server by adding it as a gem source on various machines. Installing our custom gems then worked smoothly.

问题回答

We internally use Artifactory for managing our in-house rubygems - some of them are proprietary and some are publicly released. we can enforce security between our different groups (dev, qa - prerelease, release, ...)

Also, rubygems.org is proxied and cached locally, which helps us gain better performance and avoid remote downtimes.

Eventually, developers are using a single source url, aggregating both remote and local repositories transparently.

You should generate the index not on the gems subdirectory. But on the basedir one.

sudo gem generate_index -d /var/www/html

It ll take automatically the gems in the "gems" subdirectory.
And generate the index at in the basedir.

The same thing happened to me so I started to browse the code for Gem::Indexer and wrote a few lines of code to do the indexing from irb launched from my host destination (the one above ./gems):

require  rubygems 
require  rubygems/indexer 

i=Gem::Indexer.new  . 
i.generate_index

And if you want to update the index later:

require  rubygems 
require  rubygems/indexer 

i=Gem::Indexer.new  . 
i.update_index

I suspect the issue with the gem command must exist somewhere higher at the command parsing level but I have not looked into it (I just wanted to create my repository and move on).





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签