Using rubyzip error - no such file to load — zip/zip

后端 未结 7 1807
梦谈多话
梦谈多话 2020-12-06 09:37

I know there is another thread on this subject but I still face this problem even after using all solutions. Is there any other way to generate zip files? Can i use Ubuntu s

相关标签:
7条回答
  • 2020-12-06 09:51

    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. There's a note about this on rubyzip gihub:

    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 rubyzip you can use next temporary fix:

    # Place this line before your library or on the head of your Gemfile
    gem 'rubyzip', '< 1.0.0'
    
    0 讨论(0)
  • 2020-12-06 09:52

    Building on @eagor's answer, if you'd like to use rubyzip >= 1.0 but need backwards compatibility add this to your Gemfile:

    gem 'zip-zip'
    

    Saves updating legacy code.

    0 讨论(0)
  • 2020-12-06 09:54

    After spending lot of time, I finally figured out the missing part. When using the rubyzip gem, I also had to require zip/zip.

    Add this to your Gemfile

    gem 'rubyzip', :require => 'zip/zip'

    Just adding gem 'rubyzip did not work for me.

    0 讨论(0)
  • 2020-12-06 09:54

    In my case I was needed to change from

    Zip::File.open(...)
    

    to

    Zip::ZipFile.open(...)
    

    of course I need to also add this to Gemfile:

    gem 'rubyzip', :require => 'zip/zip'
    
    0 讨论(0)
  • 2020-12-06 09:55

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

    https://stackoverflow.com/a/19506372/567399

    0 讨论(0)
  • 2020-12-06 10:00

    For anyone else who has problems with rubyzip and comes across this thread: remember that you can always shell out to an external command-line zip utility. There are a number of free command-line utilities which you can find through Google. Once you install your command-line zip program of choice and make sure it is on the system path, just use backticks to drive it from within Ruby. Of course, this won't work for web applications which are running on Heroku, etc.

    0 讨论(0)
提交回复
热议问题