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: [email protected]

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:

On Mar 16, 11:24pm, Manny 777 [email protected] wrote:

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

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

On Mar 17, 10:54am, Manny 777 [email protected] wrote:

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

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…

On Mar 17, 12:29pm, Manny 777 [email protected] wrote:

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

Fred:

I am using Rails in version 3.0.5

Frederick C. 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)

On Mar 17, 2:08pm, Manny 777 [email protected] wrote:

Frederick C. 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

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

Frederick C. 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…

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.

On 17 March 2011 16:28, Manny 777 [email protected] wrote:

Frederick C. 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?

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

Colin

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

On 17 March 2011 17:30, Manny 777 [email protected] wrote:

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…

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

Colin

My Gemfile:

require ‘rubygems’
require ‘mongo’
require ‘RMagick’

source ‘http://rubygems.org
gem ‘rails’, ‘3.0.5’
gem “mongo_mapper”
gem “rails3-generators”

Output from bundle install

Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.5)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.5)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.5)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.5)
Using arel (2.0.9)
Using activerecord (3.0.5)
Using activeresource (3.0.5)
Using bson (1.2.4)
Using bundler (1.0.10)
Using jnunemaker-validatable (1.8.4)
Using mongo (1.2.4)
Using plucky (0.3.7)
Using mongo_mapper (0.8.6)
Using thor (0.14.6)
Using railties (3.0.5)
Using rails (3.0.5)
Using rails3-generators (0.17.4)
Your bundle is complete! Use bundle show [gemname] to see where a
bundled gem is installed.

Gemfile.lock

GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.5)
actionpack (= 3.0.5)
mail (~> 2.2.15)
actionpack (3.0.5)
activemodel (= 3.0.5)
activesupport (= 3.0.5)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.5)
activesupport (= 3.0.5)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.5)
activemodel (= 3.0.5)
activesupport (= 3.0.5)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.5)
activemodel (= 3.0.5)
activesupport (= 3.0.5)
activesupport (3.0.5)
arel (2.0.9)
bson (1.2.4)
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.5.0)
jnunemaker-validatable (1.8.4)
activesupport (>= 2.3.4)
mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mongo (1.2.4)
bson (>= 1.2.4)
mongo_mapper (0.8.6)
activesupport (>= 2.3.4)
jnunemaker-validatable (~> 1.8.4)
plucky (~> 0.3.6)
plucky (0.3.7)
mongo (~> 1.1)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.5)
actionmailer (= 3.0.5)
actionpack (= 3.0.5)
activerecord (= 3.0.5)
activeresource (= 3.0.5)
activesupport (= 3.0.5)
bundler (~> 1.0)
railties (= 3.0.5)
rails3-generators (0.17.4)
railties (>= 3.0.0)
railties (3.0.5)
actionpack (= 3.0.5)
activesupport (= 3.0.5)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)

PLATFORMS
ruby

DEPENDENCIES
mongo_mapper
rails (= 3.0.5)
rails3-generators

On 17 March 2011 17:51, Manny 777 [email protected] wrote:

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

On Mar 17, 6:51pm, Manny 777 [email protected] wrote:

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

On 17 March 2011 18:51, Manny 777 [email protected] wrote:

But I am getting still the error “uninitialized constant Files::Magick”

I presume you restarted the server.

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

Using rake (0.8.7)
Using abstract (1.0.0)
Using activesupport (3.0.5)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.5)
Using erubis (2.6.6)
Using rack (1.2.1)
Using rack-mount (0.6.13)
Using rack-test (0.5.7)
Using tzinfo (0.3.24)
Using actionpack (3.0.5)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.15)
Using actionmailer (3.0.5)
Using arel (2.0.9)
Using activerecord (3.0.5)
Using activeresource (3.0.5)
Using bson (1.2.4)
Using bundler (1.0.10)
Using jnunemaker-validatable (1.8.4)
Using mongo (1.2.4)
Using plucky (0.3.7)
Using mongo_mapper (0.8.6)
Using thor (0.14.6)
Using railties (3.0.5)
Using rails (3.0.5)
Using rails3-generators (0.17.4)
Using rmagick (2.13.1)
Your bundle is complete! Use bundle show [gemname] to see where a
bundled gem is installed.

And Gemfile.lock

GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.5)
actionpack (= 3.0.5)
mail (~> 2.2.15)
actionpack (3.0.5)
activemodel (= 3.0.5)
activesupport (= 3.0.5)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.5)
activesupport (= 3.0.5)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.5)
activemodel (= 3.0.5)
activesupport (= 3.0.5)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.5)
activemodel (= 3.0.5)
activesupport (= 3.0.5)
activesupport (3.0.5)
arel (2.0.9)
bson (1.2.4)
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.5.0)
jnunemaker-validatable (1.8.4)
activesupport (>= 2.3.4)
mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mongo (1.2.4)
bson (>= 1.2.4)
mongo_mapper (0.8.6)
activesupport (>= 2.3.4)
jnunemaker-validatable (~> 1.8.4)
plucky (~> 0.3.6)
plucky (0.3.7)
mongo (~> 1.1)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.5)
actionmailer (= 3.0.5)
actionpack (= 3.0.5)
activerecord (= 3.0.5)
activeresource (= 3.0.5)
activesupport (= 3.0.5)
bundler (~> 1.0)
railties (= 3.0.5)
rails3-generators (0.17.4)
railties (>= 3.0.0)
railties (3.0.5)
actionpack (= 3.0.5)
activesupport (= 3.0.5)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
rmagick (2.13.1)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)

PLATFORMS
ruby

DEPENDENCIES
mongo_mapper
rails (= 3.0.5)
rails3-generators
rmagick

But I am getting still the error “uninitialized constant Files::Magick”
in the class:

class Files
def self.save(upload)

img = Magick::Image.read(‘public/data/nature6.jpg’).first
thumb = img.resize(width, height)

end
end

I’m sorry for these simple questions, but I am fighting with that the
second day already and still without succes…

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