Question

I'm following this tutorial (railscast carrierwave). I can get the image to show up, like many other threads here, but I have a problem with rmagick being installed.

I've tried to uninstall and reinstall imagemagick and rmagick as suggested here...

After I add rmagick to my gemfile, I can no longer launch my app in development.

Error log as follows

$ rails s
/Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/rmagick-2.13.2/lib/rmagick.rb:11:in `require': cannot load such file -- RMagick2.so (LoadError)
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/rmagick-2.13.2/lib/rmagick.rb:11:in `<top (required)>'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
from /Users/ShiftedRec/tippedmixology/config/application.rb:7:in `<top (required)>'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:74:in `require'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:74:in `block in <top (required)>'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
from /Users/ShiftedRec/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'

my gem file is as follows:

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
     gem 'rails', '4.0.2'
# Use SCSS for stylesheets
     gem 'bootstrap-sass', '~>3.1.1.0'
     gem 'sass-rails', '~> 4.0.0'
     gem 'carrierwave'
# Use this stuff for mail and forms
     gem 'mail_form'
     gem "simple_form", "~> 3.0.0.rc"
     gem 'rmagick'
# Use sqlite3 as the database for Active Record
     gem 'sqlite3'


# Use Uglifier as compressor for JavaScript assets
     gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
     gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
     # gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
      gem 'jquery-rails'
      gem 'execjs'
      gem 'actionpack'
      gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'

    # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks

    # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
    gem 'jbuilder', '~> 1.2'

group :doc do
    # bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
    end
group :development do
   gem 'rails_layout'
   gem 'better_errors'
   gem 'binding_of_caller'
   gem 'pry'

    end

# Use ActiveModel has_secure_password
      # gem 'bcrypt-ruby', '~> 3.1.2'

# Use unicorn as the app server
     # gem 'unicorn'

# Use Capistrano for deployment
      # gem 'capistrano', group: :development

# Use debugger
      # gem 'debugger', group: [:development, :test]

For good measure here is my config for my carrierwave uploader

class ImageUploader < CarrierWave::Uploader::Base



# Include RMagick or MiniMagick support:
  include CarrierWave::RMagick
  # include CarrierWave::MiniMagick

  # Choose what kind of storage to use for this uploader:
  storage :file
  # storage :fog

  # Override the directory where uploaded files will be stored.
  # This is a sensible default for uploaders that are meant to be mounted:
  def store_dir
    "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  end

  # Provide a default URL as a default if there hasn't been a file uploaded:
  # def default_url
  #   # For Rails 3.1+ asset pipeline compatibility:
  #   # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
  #
  #   "/images/fallback/" + [version_name, "default.png"].compact.join('_')
  # end

  # Process files as they are uploaded:
  # process :scale => [200, 300]
  #
  # def scale(width, height)
  #   # do something
  # end

  # Create different versions of your uploaded files:
  version :thumb do
    process :resize_to_limit => [150, 150]
  end

  # Add a white list of extensions which are allowed to be uploaded.
  # For images you might use something like this:
  # def extension_white_list
  #   %w(jpg jpeg gif png)
  # end

  # Override the filename of the uploaded files:
  # Avoid using model.id or version_name here, see uploader/store.rb for details.
  # def filename
  #   "something.jpg" if original_filename
  # end

end

I'm running Mac OSX 10.8.5....

Any help would be appreciated. Thanks in advance!

Was it helpful?

Solution

Try to use mini-magick instead of rmagick :

comment the below line:

include CarrierWave::RMagick

and use the below

include CarrierWave::MiniMagick

Gemfile:

gem 'mini_magick'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top