Question

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.

Was it helpful?

Solution

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!

OTHER TIPS

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.

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

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.

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

I'm use rubyzip2 gem to fix this problem

gem 'rubyzip2'

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'

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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top