GMA
GMA

Reputation: 6096

Undefined method Zip::ZipOutputStream.write_buffer on Heroku

I'm making a basic Sinatra app to play around with the Passbook gem.

My app runs fine on localhost, but when I try and run it on Heroku I get this error message:

/app/vendor/bundle/ruby/2.0.0/gems/passbook-0.2.1/lib/passbook/pkpass.rb:122:in `outputZip'
/app/vendor/bundle/ruby/2.0.0/gems/passbook-0.2.1/lib/passbook/pkpass.rb:60:in `stream'
/app/vendor/bundle/ruby/2.0.0/gems/sinatra-1.4.4/lib/sinatra/base.rb:1593:in `call'
NoMethodError - undefined method `write_buffer' for Zip::ZipOutputStream:Class:

This happens when I call the line passbook.stream.string in my app file.

I don't think Passbook is the problem here - it seems that the class method write_buffer exists in the version of Zip::ZipOutputStream on my local machine but isn't there on Heroku. Why is this? How can I get around it?

I've tried including both zip and rubyzip in my Gemfile, individually and at the same time, and neither of them solve the issue.

Upvotes: 1

Views: 1125

Answers (2)

GMA
GMA

Reputation: 6096

Finally figured it out.

When I ran ruby app.rb, things worked locally, but when I ran bundle exec ruby app.rb, I got the same error as I did on heroku.

I upgraded to the latest version of passbook (which was just updated today to handle the latest changes to rubyzip), but things still didn't work.

Turns out I needed to remove gem 'zip' from my Gemfile and just include gem 'rubyzip' - previously I had both.

Upvotes: 0

Jon Mountjoy
Jon Mountjoy

Reputation: 4526

Whenever I see something like this, I always ask myself Do you have Dev/Prod parity?.

So:

  • What Ruby version do you use locally, and does it differ from what you're using on Heroku?
  • Do you specify a Ruby version in your Gemfile?
  • How do you run locally? Do you use bundle exec to ensure you run in the same way, with the same gems?

Upvotes: 1

Related Questions