"~>1.5.0"...">

Config.gem requires a gem?

I have a command of config.gem statements in my environment.rb file:

config.gem "fastercsv", :version => "~>1.5.0"
  config.gem "parseexcel", :version => "~>0.5.2"
  config.gem "geokit", :version => "~>1.4.1"
  config.gem "facebooker", :version => "~>1.0.50"

      

...

If I do "rake gems: install" then I get this problem: the rake is aborted! no such file to download - fastcsv

Well ... I know not to download such a file because I am trying to install it. I suspect this might come from my location. I have a module in the lib directory:

module SmartContactsImporter

  require 'fastercsv'
  require 'parseexcel'
...

      

I may not like Rails when I need a gem, but it seems silly because there is nothing wrong with your module depending on the gem. Any ideas on how to resolve this issue?

UPDATE It turns out this question also happened with mechanize, geokit and the list goes on. It's a bit odd that config.gem doesn't work pretty easily out of the box. FYI I don't freeze my gems.

+2


source to share


2 answers


If you leave a request in SmartContactsImporter

, this should work ( config.gem "fastercsv"

will fulfill the requirement for you).

You can work around it when you environment.rb

need << 22> with:



begin
  require "rack/cache"
rescue LoadError
  STDERR.puts "not loaded rack/cache: #{$!}"
end

      

It's ugly, but it does the trick.

+2


source


You shouldn't require inside your module, config.gem will require it for you.



There is also a problem with config.gem where it will try to require a dependency gem that has not yet been installed when installing gems, but that is not the case yet.

0


source







All Articles