16

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.

Community
  • 1
  • 1
ggrillone
  • 526
  • 1
  • 6
  • 20
  • 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 Dec 11 '15 at 12:07

8 Answers8

31

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.

eagor
  • 9,150
  • 8
  • 47
  • 50
20

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

mmell
  • 2,448
  • 1
  • 24
  • 16
8

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.
rob.g
  • 81
  • 2
  • 3
5

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!

Community
  • 1
  • 1
Bulat
  • 262
  • 5
  • 8
5

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

PedroSena
  • 645
  • 6
  • 14
2

I'm use rubyzip2 gem to fix this problem

gem 'rubyzip2'
Mr.LamYahoo
  • 1,536
  • 13
  • 28
2

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'

roxdurazo
  • 745
  • 10
  • 21
0

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.
Cassio Cabral
  • 2,652
  • 3
  • 23
  • 37