15
votes

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.

8
Not related with this question but in case someone will have the same problem as me - with versions > 1.0 you should require 'zip' not 'zip/zip'kaczor1984

8 Answers

29
votes

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.

19
votes

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

8
votes

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.
5
votes

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!

5
votes

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

2
votes

I'm use rubyzip2 gem to fix this problem

gem 'rubyzip2'
2
votes

what work for me was to install 2 gems:
gem install rubyzip gem install zip and in the script put
require 'rubygems' require 'zip/zip'

0
votes

In their github page explains what to do.

Rubyzip interface changed!!! No need to do require "zip/zip" and Zip prefix in class names removed.

If you have issues with any third-party gems what required old version of rubyzip you can use next workaround:

gem 'rubyzip', '>= 1.0.0' # will load new rubyzip version
gem 'zip-zip' # will load compatibility for old rubyzip API.