0

Carrierwave を使用して Sinatra で動作する単純な画像アップローダ クラスを取得しようとしています。これとほぼ同じコードを使用し、Gemfile で同じ行を指定しましたが、$bundle install を実行してすべて問題なくインストールした後、次のコードから LoadError が発生します。

Gemfile:

source 'https://rubygems.org'

ruby '1.9.3'

gem 'sinatra'
gem 'sinatra-contrib'
gem 'rack'
gem 'thin'
gem "mongo_mapper"
gem 'bson_ext'

# Image uploading to S3
gem "fog", "~> 1.3.1"
gem 'carrierwave'
gem 'rmagick', '2.13.2', :git=>'http://github.com/rmagick/rmagick.git', :require=>'RMagick'

CarrierWave 構成ファイル:

# Configure Carrierwave Uploads to Amazon S3
CarrierWave.configure do |config|
  config.fog_credentials = {
    :provider               => 'AWS',                        # required
    :aws_access_key_id      => '(never mind about this)',                        # required
    :aws_secret_access_key  => '(or this)'                        # required
    #:region                 => 'eu-west-1',                  # optional, defaults to 'us-east-1'
    #:host                   => 's3.example.com',             # optional, defaults to nil
    #:endpoint               => 'https://s3.example.com:8080' # optional, defaults to nil
  }
  config.fog_directory  = 'penumbra-images'                     # required
  config.fog_attributes = {'Cache-Control'=>'max-age=315576000'}  # optional, defaults to {}

end

ImageUploader クラス定義:

class ImageUploader < CarrierWave::Uploader::Base
  include CarrierWave::RMagick
  process :resize_to_fit => [1024, 1024]
  storage :fog
end

私の結果:

$ ruby app.rb
CarrierWave::Uploader::Base
/Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:124:in `require': cannot load such file -- RMagick (LoadError)
    from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:124:in `require'
    from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/carrierwave-0.9.0/lib/carrierwave/processing/rmagick.rb:67:in `rescue in block in <module:RMagick>'
    from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/carrierwave-0.9.0/lib/carrierwave/processing/rmagick.rb:64:in `block in <module:RMagick>'
    from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.14/lib/active_support/concern.rb:121:in `class_eval'
    from /Users/duncanmalashock/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-3.2.14/lib/active_support/concern.rb:121:in `append_features'
    from /Users/duncanmalashock/Generator/init/uploader.rb:2:in `include'
    from /Users/duncanmalashock/Generator/init/uploader.rb:2:in `<class:ImageUploader>'
    from /Users/duncanmalashock/Generator/init/uploader.rb:1:in `<top (required)>'
    from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:124:in `require'
    from /Users/duncanmalashock/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/site_ruby/1.9.1/rubygems/core_ext/kernel_require.rb:124:in `require'
    from app.rb:7:in `<main>'

誰でも助けることができますか?本当にありがとう。

4

1 に答える 1