Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

config.gem github friendly (discussion)

#1932

UPDATE: as commented by Matt Jones, it is more important to rewrite the "config.gem" feature than monkey-patching it (a lot of users are reporting various errors when do gems:install).

More info on Matt's ticket

--

There is a bunch of gems hosted in github, and calling config.gem when you want to use one of them is quite different from the standard config.gem call.

For example, the Cucumber gem lives as a standard gem and as a github-gem, but calling one or another is quite different:


config.gem 'cucumber' # standard gem
config.gem 'aslakhellesoy-cucumber', :lib => 'cucumber', :source => 'http://gems.github.com' # github gem

It would be great to call config.gem with or without github only changing one parameter, something like this:


config.gem 'cucumber', :github => 'aslakhellesoy'
# this would really call config.gem 'aslakhellesoy-cucumber', :lib => 'cucumber', :source => 'http://gems.github.com'

I have a gist : http://gist.github.com/64121, based on this article: http://www.codefluency.com/artic... to illustrate the idea.

Reported by Markús · February 10th, 2009 @ 07:32 PM

State: resolved
Milestone: 2.x
Assigned to: Matt Jones Matt Jones
Importance: Low

Activity

  1. Markús
    Markús
    • Assigned user set to josh

    February 13th, 2009 @ 08:57 PM

  2. josh
    josh
    • Assigned user changed from josh to Rick

    February 13th, 2009 @ 10:29 PM

  3. Rick
    Rick

    I like James Beddington's solution. It makes it more clear what's happening, and doesn't do anything special for github.

    
    config.gem_source :github => 'http://gems.github.com'
    config.gem 'user-foo', :source => :github
    

    Common repos like github could be specified by default.

    February 16th, 2009 @ 05:48 PM

  4. Matt Jones
    Matt Jones

    A few things:

    • I don't think that Rails should have a bunch of github-specific code. The solutions presented help a little, but they use quite a few lines in the framework to save a few characters in environment.rb.

    • the gem_source thing is coming close to replicating some of the functionality of Rubygems.

    • Finally, it's looking more and more like the entire mechanism will need to be rewritten for 3.0; there are a number of edge cases where the existing code breaks badly and solutions are hard to impossible. There's also the problems experienced by some users where gems:install needs to load the environment, but the environment won't load without the gems.

    I'd encourage anybody who reads this and has an interest to comment on #1721 Unify approach to gem dependencies with ideas.

    February 18th, 2009 @ 12:20 AM

  5. Markús
    Markús

    @Matt

    I think you're right. This solution doesn't make any sense if the whole config.gem 'thing' is giving errors to everyone. I've read your ticket and it's much more important than this.

    I sent this ticket while I was trying the new Templates feature, but I didn't use the config.gem command before (I didn't need).

    After trying it, I have to say it doesn't work at all, fails on almost every gem, in both local and remote machines, constantly complains about non-writable directories, tries to download the gems in ~/.gem, etc.

    Well, If I come up with any interesting idea to solve this, I will comment it in your ticket.

    Cheers

    February 18th, 2009 @ 01:10 AM

  6. Matt Jones
    Matt Jones
    • Assigned user changed from Rick to Matt Jones

    @Markus:

    The writable directories noises and the ~/.gem thing are both Rubygems stuff; if you're installing gems from a template you'll most likely need to use

    
    rake "gems:install", :sudo => true
    

    in your template file to install them to your system repository. (Note: it's not presently possible to download a gem directly to vendor/gems - it has to be installed somewhere before it can be unpacked).

    As for the rest, I'm interested to find out what "fails on almost every gem" involves. Can you give any examples? Thanks!

    February 18th, 2009 @ 01:46 AM

  7. Markús
    Markús

    @Matt

    I alrteady tried it with :sudo => true (and with sudo rake gems:install too).

    Well, actually, "almost every gem" means that once one gem fails to install, all others fail as well, they don't install because the code "exists" due to a single exception (which is very irritating, it will be far better to try to install all, and then ouput a report with the problems found if any).

    I've been playing a bit with the "position" of the config.gem command inside the environment configuration to figure out what is the gem or gems are causing the problem. I've just tried this:

    
      config.gem 'mislav-will_paginate', :lib => 'will_paginate',
        :source => 'http://gems.github.com'
      config.gem 'RedCloth', :lib => 'redcloth'
      config.gem 'rubyist-aasm', :lib => 'aasm',
        :source => 'http://gems.github.com'
      config.gem 'aslakhellesoy-cucumber', :lib => 'cucumber',
        :source => 'http://gems.github.com'
      config.gem 'rspec', :lib => 'spec'
      config.gem 'rspec-rails', :lib => 'spec/rails'
    

    All gems were installed except Rspec (in my previous config rspec was the first config.gem, for that reason I said 'almost every gem', it makes all others to fail)

    This is the ouput:

    
    /Users/**sysaccount**/.gem/ruby/1.8/gems/rspec-1.1.12/lib/spec/runner/options.rb:240:in `files_to_load': File or directory not found: gems:install (RuntimeError)
    

    By the way, I already have this gem installed.

    Cheers

    February 18th, 2009 @ 10:36 AM

  8. Markús
    Markús
    • Title changed from config.gem github friendly to config.gem github friendly (discussion)

    I been testing config.gem (manually) a bit more in one of my projects, and I found a very strange error. When I call 'sudo rake gems' (or any other rake gems: task), the script aborts saying "method missing validates_period". This doesn't happen when any other rake task, only with gems related tasks.

    The point is that validates_period is a custom validator method which is loaded in an initializer. The --trace option shown me that the error was thrown in ** Execute environment. I have other initializers defined, and they seems to load correctly. Later, I commented out the line which calls the custom validates_period method and all worked perfectly.

    I loaded the custom validator using various ways, declaring it in environment.rb, through extend, through module_eval, through class_eval... and nothing worked, this method never loaded in environment with rake gems:*

    I have to say that this validator actually works and its tested.

    February 19th, 2009 @ 11:30 PM

  9. Prem Sichanugrist (sikachu)
    Prem Sichanugrist (sikachu)
    • State changed from new to resolved

    I think this has already be fixed by using

    config.gem 'name-my_gem', :lib => 'my_gem', :source => "http://gems.github.com"
    

    Also, gem hosting on Github is deprecated, and config.gem will be deprecated in Rails 3.

    January 22nd, 2010 @ 08:20 AM

  10. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:46 PM

  11. Ryan Bigg
    Ryan Bigg

    Automatic cleanup of spam.

    November 8th, 2010 @ 01:54 AM