Uninitialized constant Files::Magick -still around

Hi there,
I'm solving the problem about the plugin Magick. In my app in Gemfile
I've follwoing:

require 'rubygems'
require 'mongo'
require 'RMagick'

include Magick

and in a model Files:

class Files
  def self.save(upload)
     ...
  img = Magick::Image.read('public/data/nature6.jpg').first
  end
end

And I still getting error in subject of this post. I tried to move
require 'mongo'
require 'RMagick'

into the method self.save, but without succes...

But if I try to test, that the plugin is installed fine (test.rb):

require 'rubygems'
require 'RMagick'

puts Magick::Long_version

I will get following output:

This is RMagick 2.13.1 ($Date: 2009/12/20 02:33:33 $) Copyright (C) 2009
by Timothy P. Hunter
Built with ImageMagick 6.6.7-8 2011-03-16 Q8 http://www.imagemagick.org
Built for ruby 1.8.7
Web page: http://rmagick.rubyforge.org
Email: rmagick@rubyforge.org

So I guess this plugin is installed right... And I have a problem, that
I don't know why this plugin doesn't works in RoR application...

Thanks a lot for every hint advance! :slight_smile:

That looks like an odd to thing to have in your Gemfile. Your gemfile
should contain stuff like

gem 'mongo'
gem 'RMagick'

etc. not actual require statements

Fred

Hi Fred,
thank you for your reply. I tried to edit Gemfile by your hint, but
unfortunatelly, without successful...

But I found one interesting thing -- if I will to delete content of
Gemfile, my app work normally (but of course, the problem with RMagick
is here still), as if there the content was (in that Gemfile)... it's
really weird...

Hi Fred,
thank you for your reply. I tried to edit Gemfile by your hint, but
unfortunatelly, without successful...

But I found one interesting thing -- if I will to delete content of
Gemfile, my app work normally (but of course, the problem with RMagick
is here still), as if there the content was (in that Gemfile)... it's
really weird...

Is your app actually using the gemfile at all? If you're using rails
2.3 there some messing around you need to do in order to get bundler
to work (it's all on the bundler home page)

Fred

Fred:

I am using Rails in version 3.0.5

Fred:

I am using Rails in version 3.0.5

Weird. I think you need to get bundler working properly in your app
first. Does bundle show think rmagick is part of your bundle ?

Fred

Frederick Cheung wrote in post #987919:

Weird. I think you need to get bundler working properly in your app
first. Does bundle show think rmagick is part of your bundle ?

Fred

How can I do that? If I see to my list of plugins in Gem, I think there
is everything...

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.5, 3.0.0, 2.3.5, 1.3.6)
actionpack (3.0.5, 3.0.0, 2.3.5, 1.13.6)
actionwebservice (1.2.6)
activemodel (3.0.5, 3.0.0)
activerecord (3.0.5, 3.0.0, 2.3.5, 1.15.6)
activeresource (3.0.5, 3.0.0, 2.3.5)
activesupport (3.0.5, 3.0.0, 2.3.5, 1.4.4)
acts_as_ferret (0.4.3)
arel (2.0.9, 1.0.1)
bson (1.2.4, 1.2.2)
bson_ext (1.2.4, 1.2.2)
builder (2.1.2)
bundler (1.0.10)
capistrano (2.5.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
dnssd (0.6.0)
erubis (2.6.6)
fastthread (1.0.1)
fcgi (0.8.7)
ferret (0.11.6)
gem_plugin (0.2.3)
highline (1.5.0)
hpricot (0.6.164)
i18n (0.5.0, 0.4.2)
jnunemaker-validatable (1.8.4)
libxml-ruby (1.1.2)
mail (2.2.15)
mime-types (1.16)
mongo (1.2.4, 1.2.2)
mongo_mapper (0.8.6)
mongrel (1.1.5)
mysql (2.8.1)
mysql2 (0.2.6)
needle (1.3.0)
net-scp (1.0.1)
net-sftp (2.0.1, 1.1.1)
net-ssh (2.0.4, 1.1.4)
net-ssh-gateway (1.0.0)
plucky (0.3.7)
polyglot (0.3.1)
rack (1.2.1, 1.0.1)
rack-mount (0.6.13)
rack-test (0.5.7)
rails (3.0.5, 3.0.0, 2.3.5, 1.2.6)
rails3-generators (0.17.4)
railties (3.0.5, 3.0.0)
rake (0.8.7, 0.8.3)
RedCloth (4.1.1)
rmagick (2.13.1)
ruby-openid (2.1.2)
ruby-yadis (0.3.4)
rubygems-update (1.5.2)
rubynode (0.1.5)
sqlite3-ruby (1.2.4)
termios (0.9.4)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.24)
xmpp4r (0.4)

Frederick Cheung wrote in post #987919:

> Weird. I think you need to get bundler working properly in your app
> first. Does bundle show think rmagick is part of your bundle ?

> Fred

How can I do that? If I see to my list of plugins in Gem, I think there
is everything...

run bundle show from the root of your app

Fred

Frederick Cheung wrote in post #987929:

run bundle show from the root of your app

Fred

Thanks Fred for hint, here is list of plugins in my app... But how can I
add RMagick to my app?

Gems included by the bundle:
  * abstract (1.0.0)
  * actionmailer (3.0.5)
  * actionpack (3.0.5)
  * activemodel (3.0.5)
  * activerecord (3.0.5)
  * activeresource (3.0.5)
  * activesupport (3.0.5)
  * arel (2.0.9)
  * bson (1.2.4)
  * builder (2.1.2)
  * bundler (1.0.10)
  * erubis (2.6.6)
  * i18n (0.5.0)
  * jnunemaker-validatable (1.8.4)
  * mail (2.2.15)
  * mime-types (1.16)
  * mongo (1.2.4)
  * mongo_mapper (0.8.6)
  * plucky (0.3.7)
  * polyglot (0.3.1)
  * rack (1.2.1)
  * rack-mount (0.6.13)
  * rack-test (0.5.7)
  * rails (3.0.5)
  * rails3-generators (0.17.4)
  * railties (3.0.5)
  * rake (0.8.7)
  * thor (0.14.6)
  * treetop (1.4.9)
  * tzinfo (0.3.24)

If I started with RoR, I was excited from it... but the problems with
plugins I really don't like... And the problems really comes again, when
I will to try to upload my app on hosting and there will not installed
all of plugins in my app...

Add it to your Gemfile (as Fred's post earlier) and run
bundle install
(did you remember to run bundle install previously?)

Colin

You can "freeze" all of the gems into your site, so you don't have to rely on your host's version of anything. Have a look on the bundler site for the incantation. These frozen Gems get partially compiled (at least that's how it appears to me) so there may even be some advantage to running them this way.

Walter

Manny 777 wrote in post #987883:

Hi Fred,
thank you for your reply. I tried to edit Gemfile by your hint, but
unfortunatelly, without successful...

But I found one interesting thing -- if I will to delete content of
Gemfile, my app work normally (but of course, the problem with RMagick
is here still), as if there the content was (in that Gemfile)... it's
really weird...

I think you need to read up on how bundle works, and where it writes
information.

Edit your gemfile to your heart's delight. If you don't run "bundle
install", then those changes aren't seen/processed.

Why weren't you successful with editing your gemfile? (your second post
in this thread)

It seems a relatively simple thing, and if you edited that file, and did
a "bundle install", and that process reported issues, then you should
resolve those.

Thank you for your replies guys. I made "bundle install" in my root of
app... but if I see then on plugins, I didn't see RMagick... The output
from "bundle show" is the same, as I posted here (9th post)...

Where can be the error? What could be wrong yet...

One more time, thanks

Post your Gemfile, the output from bundle install and the resulting gemfile.lock

Colin

My Gemfile:

My Gemfile:

require 'rubygems'
require 'mongo'
require 'RMagick'

Look back at Fred's first post (as I suggested) where he explained
that is not the correct syntax for Gemfile. I suggest you do some
research on how to use bundler.

Colin

Ok, I'm editing my Gemfile and looks this:

source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem "mongo_mapper"
gem "rails3-generators"
gem 'rmagick', :require => 'RMagick'

My output from bundle install

class Files
def self.save(upload)
....
img = Magick::Image.read('public/data/nature6.jpg').first
thumb = img.resize(width, height)
...
end
end

I suppose you could try ::Magick although that wouldn't make much
sense unless something was confusing the constant lookup stuff

Fred

I presume you restarted the server.

Colin

I forgot restart the server... uhh, thank you guys, this was really
demanding...