Ruby on Rails Avatar Paperclip::CommandNotFoundError - ruby-on-rails

I've been trying to work with Paperclip. I've installed ImageMagick. I've added the line
Paperclip.options[:command_path] = "/usr/local/bin" in config/initializers/paperclip.rb.
But i'm still getting the error "Avatar Paperclip::CommandNotFoundError".
How can i possibly solve this?

First, make sure you have the rmagick gem in your Gemfile
gem 'rmagick', :require => 'RMagick'
Next, open a rails console from the command line.
$ rails c
type:
`which convert`
You should see something like
=> "/usr/bin/convert\n"
If you do, then take the path, in this case /usr/bin, and set Paperclip.options[:command_path] to that path. If you don't, you need to make sure that ImageMagick is installed. For OSX use Homebrew (http://mxcl.github.com/homebrew/) or MacPorts. For Debian systems you'll need two packages:
imagemagick
libmagick9-dev
For Redhat/rpm-based systems, you can try their packages, but they are pretty old and you'll probably be better off compiling from source.
If you've got ImageMagick already installed then you'll need to make sure the convert command is in your path.
As a side note, if the rmagick gem installs, then you should have ImageMagick already installed, you just need to figure out where it is on your system.

have you tried installing/using rMagic?

I installed ImageMagick using the Binary from Macports for Snow Leopard. The install went fine, but Paperclip wasn't finding ImageMagick and I was getting the same errors.
I added the following to config/environments/development.rb:
Paperclip.options[:command_path] = "/opt/local/bin"
I restarted the server and everything works perfectly.

Related

RMagick/ImageMagick installation

I am trying to install the rmagick gem. When I run "gem install rmagick" it gives me the following error:
In file included from rmagick.c:13:
./rmagick.h:1210:51: error: unknown type name 'MagickPixelPacket'
extern void Color_to_MagickPixelPacket(Image *, MagickPixelPacket *, VALUE);
followed by a few similar complaints about missing methods and incorrect parameters(I can post the rest if they seem helpful).
To me, this seems like a version problem, which makes sense because I had ImageMagick 6 installed as well as version 7, so I uninstalled version 6 but the problem persists.
I also had to symlink the following for rmagick to find the required .h files, in case that's significant:
ln -s /usr/local/include/ImageMagick-7/MagickCore /usr/local/include/magick
ln -s /usr/local/include/ImageMagick-7/MagickWand /usr/local/include/wand
I'm on a Macbook, installing things with brew. My current ImageMagick version is 7, but I'm suspicious of some leftover version 6 things causing problems.
Any thoughts? I'm happy to give more information if necessary, but I can't think of anything else at the moment.
Each distribution manages the Ruby gems it's own way, ex :
Debian requires the installation of libmagickwand-dev for this gem
What you whant to look for is see if the gem requires additionnal dependencies or not on Mac ( had similar problems with bundle on Debian )
Thanks to Brad and Matthieu for your suggestions! MiniMagick does seem like a good solution, and Matthieu is definitely right about there being different dependencies from system to system; in my case I ended up giving up on trying to use ImageMagick 7 with RMagick, but I did get it to work with ImageMagick 6. Here's what worked for me:
brew remove imagemagick
PKG_CONFIG_PATH=/usr/local/opt/imagemagick#6/lib/pkgconfig
brew install imagemagick#6
gem install rmagick
Many thanks to this SE post: https://stackoverflow.com/a/41788501/5054505
For the record, I am on OSX Yosemite
Also, see this RMagick issue: https://github.com/rmagick/rmagick/issues/256.
Hopefully this will be fixed soon, but for now it seems like reverting to version 6 is the popular approach.

Rails initialization checksum error

I'm trying to initialize a new rails app on windows, and running rails new <appname> generates everything up to vendor/assets/stylesheets/.keep, but when bundle install is run, rails generates this error:
Checksum of /versions does not match the checksum provided by server! Something is wrong.
I'm not sure what's causing this, as I've done nothing to rails itself. Any help is appreciated.
Edit: If it's an error caused by windows being finicky, I have the option of moving to Linux, but I'd like to know what's wrong first.
I had the same issue using windows, and was able to solve it by uninstalling bundler and installing an older version.
rails new <appname>
gem uninstall bundler
gem install bundler -v 1.9
cd <appname>
bundle install
That did it for me!
In my case there was a *.pre.1 version and I chose to uninstall that particular version and then "bundle install" worked.
Try removing your ruby cache folder and then try again. So for example if you are on Linux machine and you are using rbenv and say ruby 2.1.5 folder. Your path would be similar to something like (Not sure where on windows ruby is stored):
~/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/cache/
Removing this folder and trying bundle install again should resolve the issue.
It will be great, if you move to a Linux machine.
On windows it's a hell to pay in my 5 years of experience what i have learned is not to mess with (ror) or (rs) in windows. here's a cheeky thing you can do an easy way. I believe you are using github as repo, as a editor you are using sublime if thats is a case open your gemfile you will see check the image or
try to clear cache on your server or update the gems.
I had this same exact error and solved it the following way. I think you are missing the ruby DevKit being installed.
Go here http://rubyinstaller.org/downloads/ and download/install the latest 32-bit Ruby version (as of writing this 2.2.4, you will need it for the web-console gem)
Make sure to add your ruby\bin folder to your environmental path variable
The trick is hidden near the bottom-left of the same page under the "Development Kit" section. You need to download and extract the right one into a permanent location (as of writing this for 32-bit - DevKit-mingw64-32-4.7.2-20130224-1151-sfx.exe)
After extracting the files, go into the main directory and run "ruby dk.rb init" followed by "ruby dk.rb install" (More information can be found here
That fixed it for me and i can now fully install with no checksum issues
This problem began when i tried to run my app. I wrote rails s and the console said me Could not find sdoc-0.4.1 in any of the sources Run bundle install to install missing gems. Then i wrote bundle install and the message that appeared was Checksum of /versions does not match the checksum provided by server! Something is wrong.
I solve this problem following this steps:
Wrote bundle install
The console said me Could not find sdoc-0.4.1 in any of the sources
Then i reinstalled this gem with gem install sdoc -v 0.4.1
I tried again to write rails s and it's was solved.
`

How to fix this ruby gem installation error?

on a Windows 7 environment,
i installed ruby 2.2 and and the ruby development kit and want to install a gem now, which throws this error:
error: unknown type name 'BOOL'
for the command
gem install av_capture -v '1.0.1'
on multiple .h files. The av_capture gem is part of a 'bundle install' i want to do for another gem.
I also get one
fatal error: AVFoundation/AVFoundation.h: No such file or directory
So i doubt that av_capture gem can be installed at all (?)
Google tells me to use g++ instead of gcc to fix the bool type error, i dont think that i can adjust this for the ruby devkit though.
The DevKit itself seems to work fine, the example json part of the devkit wiki installation site works.
Just looked up this gem, as it says everywhere on their site:
Wraps up AVCapture and exposes it to Ruby. This gem only works on OS X.
So I doubt you're going to get this to work. AVFoundation is an IOS Specific thing.

no such file to load -- rails/cli under Ruby Enterprise Edition 1.8.7

On a VPS I tried to install Ruby. Because of memory exhaustion problems, we were unable to compile ruby 1.9.2 , and we decided to give Ruby Enterprise Edition a try. This compiled without complaining about memory problems.
Next, we install rubygems, and to test that it's working, I installed haml. It worked.
The next step was to install rails, via gem install rails. The version it downloaded was the latest, 3.0.5. Installation went ok. However, when I try to create a new project, I receive:
no such file to load -- rails/cli
Looking around on the internet, people said this is a problem related to older versions of rails, and some of them suggested to do a gem clean. I didn't have any other version of ruby before, therefore, no other version of rails. But, just to be sure, I did a gem clean and then reinstalled rails. The problem persists.
How can I fix this?
Make sure your running the gem binary that Ruby Enterprise Edition installed. So rather than:
gem install rails
it would be something like:
sudo /opt/ruby-enterprise-X.X.X/bin/gem install rails
To save having to type the whole path each time, you can symlink the REE binaries with something like:
sudo ln -sf /opt/ruby-enterprise-X.X.X/bin/* /usr/bin/.

Heroku: Running imagemagick with paperclip

I have installed image magick on my mac os x computer and now I want to deploy it to heroku. I've installed the the paperclip plugin on heroku but I get this error when uploading an image:
Paperclip::CommandNotFoundError
I had this error before when I didn't have imagemagick instaledl on my computer before but now that I want to deploy it, how do I get image magick to work on heroku?
Do you have the RMagick gem included in your app on Heroku? It's necessary for interfacing between your Ruby code and ImageMagick.
ImageMagick is part of the Heroku platform by default, but you have to specify that you need the RMagick gem for your app. I'm guessing you have this installed locally so it works there, but it's missing from your Gemfile or gems manifest (depending on Heroku stack version).
Try to remove the Paperclip.options[:command_path] = "/path/to/" when deploying to heroku.
This solved the issue for me.
Add the following to your gemfile...
gem 'rmagick'

Resources