Fastercsv, freezing into vendor/gems

I’m using fastercsv such that in my rake file I’m doing this.

require ‘fastercsv’

It works fine on my Mac.

I need to freeze this gem into the app though so my rake tasks work on
the production machine.


I spent about two hours though this weekend trying to get this Gem
“frozen” into the vendor/gems folder. I tried all sorts,

I …

  • added a line to environment.rb
  • used rake:freeze:gems
  • used rake:install:gems
  • used rake:unpack:gems
  • used rake:install:gem gem=‘fastercsv’

Basically used all sorts of variations of the above.

Any tips for gettting this done?

cheers

bb

don’t know if this is still working, but you could give it a try:
http://gemsonrails.rubyforge.org/

Ok, thanks, that does look interesting (a little old).

Thing is though - I thought I’d be able to do it with the rake tasks I
have!

e.g.

  • used rake:freeze:gems
  • used rake:install:gems
  • used rake:unpack:gems
  • used rake:install:gem gem=‘fastercsv’

Any other factors that could be blocking this working?

I made a little progress…
I went to vendor/
mkdir gems
went in there
and unpacked fastercsv…sent it to my webhost…

However on the webhost the line require ‘fastercsv’ still fails.

I read on joyent knoweldeg base running this in environment.rb might do
it…

config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
File.directory?(lib = “#{dir}/lib”) ? lib : dir
end

Will that code above solve the problem, claims to search within
vendor/gems!

bb

well, i just looked at it again. you’re right: “rake gems:unpack”
should provide exactly the functionality you’re looking for. however i
don’t know why it’s failing for you.

and on that snippet of yours: try it and tell us whether it’s working
or not. looks promising.

Who did you configure your gem dependency?
My environment.rb looks like this:
config.gem “resource_controller”, :version => ‘0.5.3’
config.gem “rubyist-aasm”, :version => ‘2.0.4’
config.gem “paperclip”, :version => ‘2.1.2’

I remember that without specifying the version rake gems:unpack would
not
work properly…

On Mon, Feb 9, 2009 at 2:25 PM, bingo bob

well, i just looked at it again. you’re right: “rake gems:unpack”
should provide exactly the functionality you’re looking for. however i
don’t know why it’s failing for you.

and on that snippet of yours: try it and tell us whether it’s working
or not. looks promising.

I put

config.gem “fastercsv”, :version => “1.4.0”

in environment.rb


btw, i tried the code above on my webhost to search and find gems but no
dice - it still errors.

so still not there…

On Feb 9, 11:25 am, bingo bob [email protected]
wrote:

config.load_paths += Dir[“#{RAILS_ROOT}/vendor/gems/**”].map do |dir|
File.directory?(lib = “#{dir}/lib”) ? lib : dir
end

Will that code above solve the problem, claims to search within
vendor/gems!

That code may work, but it will probably confuse the gem loader a
little. The
problem you’re having is that the 2.2 vendor gem handling stuff isn’t
loaded
until the environment is; if your rake task looks like this:

task “do_something” => :environment do

end

Then move the require line inside the task, which should pick up the
unpacked gem.

Hope this helps!

–Matt J.

you nailed it, thanks!

I dropped the previous code and went with your method.

thanks again.