Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails 3 - LoadError (cannot load such file -- zip/zip)

I'm using rubyzip to zip a csv file so uses can download it. This works perfectly in development mode. But when I tried zipping the file on the production server (rackspace) I received the error: LoadError (cannot load such file -- zip/zip). Is it a path issue? Anyone know a fix?

The error is being called in my code on this line: require 'zip/zip'

I've tried the solution from here, but it didn't help.

like image 294
ggrillone Avatar asked Aug 22 '12 18:08

ggrillone


6 Answers

I fixed this problem by specifying gem version 0.9.9 in Gemfile:

gem 'rubyzip',  "~> 0.9.9"

Using rubyzip (1.0.0) caused an error.

like image 161
eagor Avatar answered Oct 24 '22 20:10

eagor


When upgrading rubyzip to 1.0.0 change require 'zip/zip' to require 'zip'.

like image 38
mmell Avatar answered Oct 24 '22 22:10

mmell


I had this problem after adding roo to a Rails project.

Roo needed the new interface, something else (some other gem) was using the old interface - so most of these answers didn't work (couldn't lower the version of rubyzip, rubyzip2 is deprecated, didn't have require zip/zip in my project).

What worked for me was cassio-s-cabral's answer referring to the rubyzip github page.

gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.
like image 25
rob.g Avatar answered Oct 24 '22 22:10

rob.g


I had the same problem: error thrown on "require 'zip/zip'" code, and the solution from this post also did not help.

After a long research I found that the problem was that my "require 'zip/zip'" statement was done in a separate

lib/exporters/package_exporter.rb

file, and for some reason "require" statements are not handled in "lib" folder in production by default.

When I moved "require 'zip/zip'" to the beginning of my

app/controllers/packages_controller.rb

the problem was solved!

like image 26
Bulat Avatar answered Oct 24 '22 20:10

Bulat


I had a similar issue with active_support, just added the 'zip' gem to my Gemfile and it worked fine

like image 35
PedroSena Avatar answered Oct 24 '22 21:10

PedroSena


I'm use rubyzip2 gem to fix this problem

gem 'rubyzip2'
like image 2
Mr.LamYahoo Avatar answered Oct 24 '22 20:10

Mr.LamYahoo