Rails 4 , ImageMagick and PaperClip - ruby-on-rails

When i want to upload image i get this error:
1 error prohibited this movie from being saved:
Image Could not run the `identify` command. Please install ImageMagick.
I have this in Gemfile:
gem 'imagemagick-identify', '~> 0.0.1'
gem 'paperclip', '~> 4.2.1'
I ran from my console: gem install imagemagick-identify

imagemagick-identify is just a wrapper for imagemagick's identify program. You will need to install imagemagick separately from the gem.
If you are using debian/ubuntu you can do sudo apt-get install imagemagick.
If you are on a Mac, you may find this helpful.
If you are on Windows, you can find binaries to install here.
Looks like there are binaries for other platforms available at the last link as well.
If you have installed imagemagick and still get that error, make sure it is in your PATH.

if you are using cloud 9 ... there may be times just running
sudo apt-get install imagemagick --fix-missing
wont work. If that is your case, do
sudo apt-get update
first then install imagemagick after that

Related

Rails 6 Active Storage image_processing gem issue

Using Rails 6.0 and 'image_processing', '~> 1.9.3'
When trying to show a cropped variant of an image with:
url_for(user.avatar.variant(crop: crop_geometry)&.processed)
I get an error:
You must have ImageMagick or GraphicsMagick installed
I thought that image_processing gem included any dependencies relatives to this. Should I install some missing dependencies or what? Thanks
It's in the docs, first step, you need to instal dependencies:
https://github.com/janko/image_processing
1. Install ImageMagick and/or libvips:
> $ brew install imagemagick vips
I highly recommend using vips, it's much faster.
You have to install library first.
For Mac user:
brew install imagemagick vips
For debian/ubuntu user:
sudo apt update
sudo apt install imagemagick libvips

Rtesseract throws error after installing rtesseract gem

I need to user rtessract gem for my ruby on rails project for OCR. I have installed the gem rtesseract using
gem install rtesseract
but when i try to use that gem in my console it throws rtesseract not found error
Can any one have any solution for that. I have also placed the same in gem file and ran bundle but it doesnt work
For RTesseract gem to work you need to install some dependencies like ImageMagick Leptonica and some gems like rmagick. you can install them using
sudo apt-get install imagemagick leptonica
and rmagick gem using
gem install rmagick
or by placing the same in your gem file
You need to have tessdata folder in the
/usr/local/share/tessdata
if you dont have the tessdata you need to download tessdata from tesseract repositry and copy them to the above path

Rails ImageMagic and rmagic

I am following the tutorial http://railscasts.com/episodes/253-carrierwave-file-uploads?view=comments by ryan but he state that we must install imagemagic. so what i have done to install it his has follow
gem "carrierwave"
gem "mini_magick"
gem "rmagick"
in the gemfile. But this still fails when i do bundle. What would be the best way to install it. I am using linux ubuntu and fairly new to it.
You need to install imagemagick on ubuntu then install the rmagick gem.
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
run on linux -
sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
sudo gem install rmagick

RMagick complains it was configured with a different version of ImageMagick

I am getting following error while running local script/server of my Rails project:
This installation of RMagick was configured with ImageMagick 6.6.1 but ImageMagick 6.4.5 is in use. (RuntimeError)
Running identify --version shows the following:
Version: ImageMagick 6.6.1-10 2010-05-21 Q8 http://www.imagemagick.org
So, my question is how and where should I make changes to work it fine; I have already reinstalled ImageMagick but that didn't work.
the same thing happened to me but the solution was a bit simpler than uninstalling imageMagick. It sounds like Rmagick's config file isn't updated to use your updated imagemagick so try
sudo gem uninstall rmagick
sudo gem install rmagick
restart your server.
I took a closer look and noticed you had Rmagick configured for a newer imageMagick but using an older imageMagick. So I would assume that my solution would still work but you would not be using the newer ImageMagick.
If using bundler:
bundle exec gem uninstall rmagick
bundle install (will reinstall rmagick as part of the bundle)
I would remove any previous installation and start again by following this page.
First of all open a shell and launch:
identify -version
which will give you the IM version installed on your system.
Depending on how You installed IM, find the way to remove It completely from the system. For instance if you used apt-get, try:
sudo apt-get remove ImageMagick
If you installed IM from sources, go to where you have them stored (I mean the sources path/folder) and type:
make uninstall
You can then reinstall ImageMagick, compiling it from the sources:
cd
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar zxf ImageMagick.tar.gz
cd ImageMagick-*/
./configure --prefix=$HOME --without-perl
make
make install
Then you have to add $HOME/bin to the beginning of your $PATH
cd
echo "export PATH=$HOME/bin:\$PATH" >> .bash_profile
source .bash_profile
Now it's time to gem install RMagick:
export LD_LIBRARY_PATH=$HOME/lib
gem install rmagick
RMAGICK_BYPASS_VERSION_TEST = true
Thats a global flag set before requiring rmagick.
from
https://bugs.launchpad.net/ubuntu/+source/librmagick-ruby/+bug/565461/comments/2
Worked and tested ok for me.
I made it work by uninstalling and then deleting the file listed in the error message (before reinstalling). It seems that uninstalling doesn't always clean up some of the old ".so" files.
I had the same issue, and eventually concluded that my installation of libmagick9-dev
(sudo apt-get install libmagick9-dev ruby1.8-dev) was installing ImageMagick APIs for the lower version. My solution was to uninstall the later versions and go with the Ubuntu packaged versions of ImageMagick and the other libraries.
I bumped into this on a Rails app. I tried Scott Montgomerie's answer, but I couldn't get bundle exec gem to work (not sure why, no time to find out).
What worked for me was a simple bundle update rmagick.
bundle update rmagick worked for me

Why can't I install the SQLite gem?

I'm try to install the SQLite gem on a Fedora 9 Linux box with Ruby 1.8.6, Rails 2.2.2, gem 1.3, and sqlite-3.5.9. Here's the command I'm running and its results:
sudo gem install sqlite3-ruby
Building native extensions. This could take a while...
ERROR: Error installing sqlite3-ruby:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb install sqlite3-ruby
can't find header files for ruby.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/sqlite3-ruby-1.2.4/ext/sqlite3_api/gem_make.out
gem_make.out just repeats what was already sent to the console. How can I install this gem?
The SQLite RubyGem isn't actually a RubyGem, it's a "CGem", IOW it's written in C. This means it has to be compiled and linked to the Ruby interpreter when you install it and in order to do that it needs the C header files for the Ruby interpreter.
If you compile Ruby yourself, those header files will be installed automatically, however, in RedHat-ish systems, such header files are usually packaged in a seperate package, called <whatever>-dev. So, in this case you will need to install the ruby-dev package and possibly the libsqlite3-dev (Ubuntu) or sqlite-devel (Fedora) package as well.
However, you might be better off just installing your Operating System's pre-packaged libsqlite3-ruby package, that way all the dependencies are automatically satisfied.
(Note: all package names pulled out of thin air, might be different on your system.)
You probably need the ruby dev package. For Ubuntu you have to install ruby1.8-dev which includes the ruby header files. A quick google says that the yum package is ruby-devel. so run this:
sudo yum install ruby-devel
I faced problem installing sqlite3-ruby gem on my fedora 13 box.
It was fixed after sudo yum install sqlite-devel
When I had that problem:
gem install sqlite3 -v '1.3.9'
Building native extensions. This could take a while...
ERROR: Error installing sqlite3:
ERROR: Failed to build gem native extension.
For me worked, installing the "libsqlite3-dev" with:
apt-get install libsqlite3-dev
sudo apt-get install ruby-dev
Fixed it for me.
On Ubuntu 9 and 10 try:
sudo apt-get install ruby-dev
sudo apt-get install sqlite3-dev
Then run
gem install sqlite3
Run the following for Fedora OS:
yum install rubygem-sqlite3
On alpine, you need to install the sqlite-dev package.
I also faced this same issue, the problem is that your Linux installation requires the development libraries for SQLite3 to be installed in order to build the gem.
Here's how I fixed the issue
Open your terminal and run the following commands
sudo apt-get install sqlite3
sudo apt-get install libsqlite3-dev
And then try installing Sqlite3 gem again using this command
gem install sqlite3
That's all.
I hope this helps
Do you have all the source code required to build sqlite3-ruby? Gem is trying to compile some C code and cannot find the headers. You can probably use a fedora rpm for sqlite3-ruby (I don't use fedora, but I'm sure one exists) if you prefer to forgo compiling. Personally for ruby stuff, I prefer to use gem rather than a distro's packaging system.
I'm not really familiar with Fedora, but in Ubuntu when you are installing packages you have apt-get, and you have to install the build-essentials which includes gcc and other compilation tools for C. I would say that could be your issue, and you make look into how that can be install either using RPM or apt-get on Fedora.
I fixed the problem on my OLPC (Fedora 9) by installing 'gcc' oddly enough. It seems like it should have been one of those dev packages, but no.
Also, regarding the other packages, the suffix is "-devel", not "-dev", so make sure you get those ending right: "ruby-devel", "sqlite-devel"...
Once you get that installed, if you get errors about your gems being too old "< 1.3.1" when you try to run various rails scripts, eg: script/server or script/console, google "upgrade_rubygems" to fix that problem...
HTH...
Run "sudo yum install sqlite-devel" and then "gem install sqlite3". Had the same problem on my Fedora 15.
I had this same exact issue...instead of gem'ing the missing pieces I used synaptic on unbuntu.
The key package for me was libsqlite-ruby1.9.1 ... I documented my experience (for reference) with this error at :
Sqlite3-gem-error-during-bundle-install
I encountered this error while running bundle install after generating a react-rails app on Fedora 29. I was able to identify a suitable development package by running dnf search sqlite3, then installed it dnf install libsqlite3x-devel. This fixed it for me.

Resources