[Ruby FAQs] undefined method `seek' for @buffer: ""...0 bytes:Aliyun::OSS::HTTP::StreamWriter in carrierwave and carrierwave-aliyun

undefined method `seek’ for @buffer: “”…0 bytes:Aliyun::OSS::HTTP::StreamWriter

1
2
3
4
5
6
7
8
9
# UncaughtThrowError (uncaught throw #<NoMethodError: undefined method `seek' for @buffer: ""...0 bytes:Aliyun::OSS::HTTP::StreamWriter>):

/Users/cloudolife/.rvm/gems/ruby-2.6.1@jk-api/gems/rest-client-2.1.0/lib/restclient/payload.rb:75:in `to_s'
...
/Users/cloudolife/.rvm/gems/ruby-2.6.1@jk-api/gems/aliyun-sdk-0.7.3/lib/aliyun/oss/http.rb:270:in `do_request'
...
/Users/cloudolife/.rvm/gems/ruby-2.6.1@jk-api/gems/carrierwave-aliyun-1.2.3/lib/carrierwave/aliyun/bucket.rb:67:in `put'....
/Users/cloudolife/.rvm/gems/ruby-2.6.1@jk-api/gems/carrierwave-2.2.2/lib/carrierwave/uploader/cache.rb:145:in `block in cache!'
...

After analyzing the modification records of Gemfile and Gemfile.lock, it was found that the unlocked version of carrierwave and carrierwave-aliyun caused the automatic upgrade.

Solution

Downgrade and lock the carrierwave and carrierwave-aliyun version.

1
2
3
4
# Gemfile

gem 'carrierwave', '1.3.1'
gem 'carrierwave-aliyun', '0.9.0'

Then, run bundle update to update Gemfile.lock

1
$ bundle update

References

[1] GitHub - carrierwaveuploader/carrierwave: Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks - https://github.com/carrierwaveuploader/carrierwave

[2] carrierwave | RubyGems.org | your community gem host - https://rubygems.org/gems/carrierwave/versions/1.3.1

[3] GitHub - huacnlee/carrierwave-aliyun: 阿里云 OSS Ruby 上传组件,基于 Carrierwave - https://github.com/huacnlee/carrierwave-aliyun

[4] carrierwave-aliyun | RubyGems.org | your community gem host - https://rubygems.org/gems/carrierwave-aliyun/versions/0.9.0