Is there an easy way to install RMagick? - ruby-on-rails

I am trying to install RMagick on my slicehost(Linux Hardy)
instead of compile from source, here is what I did:
$ sudo aptitude install -y imagemagick
$ sudo aptitude install -y libmagick9-dev
$ sudo gem install rmagick
After installed, it reads GIF with no problem, however for JPEG and PNG, I keep getting this error:
Magick::ImageMagickError: no decode delegate for this image format
I know it is probably because I don't have libpng and libjpg libraries, but i didn't find guide on how to install these. I compiled libpng and libjpg from source, with no luck, the files are in the /usr/lib, but i still getting the error.

I found this to be very help: how to install rmagick on linux

Try Installing ImageMagick from Source

You definitely want to follow the recommendation here:
http://rmagick.rubyforge.org/install-faq.html#delegate
It's probably more likely that everything is fine, but you need to reconfigure your image magick install after adding the jpeg delegate.

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

Imagemagick 6.8.10 on mountain lion using rails issues

My code is here: https://github.com/pavankat/to_do_app
I used this tutorial: http://guides.railsgirls.com/thumbnails/
After running through the tutorial for a bit I got this error when trying to edit idea 1's picture (pretty much reupload the picture) so the thumbnail would appear:
Picture Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: MiniMagick::Invalid
I thought it was happening because I didn't restart the server, but I did that and it still happened.
I followed the instructions here: Rails and OS X: How to install rmagick? (question by TaianSu and chad bidwell), but no luck.
Then I followed this: Why is this RMagick call generating a segmentation fault? (Ash Berlin's response)
$ brew uninstall imagemagick && brew install imagemagick --disable-openmp
Uninstalling /usr/local/Cellar/imagemagick/6.8.0-10...
Error: You must `brew link jpeg' before imagemagick can be installed
so I did this:
$ brew rm jpeg
and then
$ brew install imagemagick --disable-openmp
then I restarted the server
I still get the error when making an idea or editing an idea's picture: Picture Failed to manipulate with MiniMagick, maybe it is not an image? Original Error: MiniMagick::Invalid
I did this:
$ sudo chmod 777 /usr/local
but no luck
Tried this based on carrierwave + mini_magick gems = not an image error (B. Ruschill's response):
$ brew uninstall imagemagick
$ brew cleanup --force -s
$ brew rm jpeg
$ brew install imagemagick
but then it gave me an error that it couldn't link jpeg.
so I tried brew link jpeg. That didn't work.
so I tried brew link jpeg issues (David Riccitelli's response)
and I tried brew link jpeg again. That didn't work.

`require': no such file to load -- mkmf (LoadError)

I was trying to install rails on Ubuntu Natty Narwhal 11.04, using ruby1.9.1.
I installed ruby using apt-get install ruby1.9.1-full which contains the dev package. I googled the error and all have suggested I install the 1.9.1-dev which I already have.
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.8 extconf.rb
extconf.rb:36:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:36
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
After some search for a solution it turns out the -dev package is needed, not just ruby1.8. So if you have ruby1.9.1 doing
sudo apt-get install ruby1.9.1-dev
or to install generic ruby version, use (as per #lamplightdev comment):
sudo apt-get install ruby-dev
should fix it.
Try locate mkmf to see if the file is actually there.
This is the answer that worked for me. Was in the comments above, but deserves its rightful place as answer for ubuntu 12.04 ruby 1.8.7
sudo apt-get install ruby-dev
# if above doesnt work make sure you have build essential
sudo apt-get install build-essential
I also needed build-essential installed:
sudo apt-get install build-essential
The problem is still is recursive on Ubuntu 13/04/13.10/14.04
and
sudo apt-get install ruby1.9.1-dev
worked out for me okay. So If you are using Ubuntu 13.04/13.10/14.04 then using this will really come in handy.
This works even if ruby version is 1.9.3. This is because there is no ruby1.9.3-dev available in the Repository...
Have you tried:
sudo apt-get install ruby1.8-dev
I got the similar error when install bundle
sudo apt-get install ruby-dev
Works great for me and solve the problem
Mint 16 ruby1.9.3
I think is a little late but
sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel
worked for me on fedora.
http://nokogiri.org/tutorials/installing_nokogiri.html
You've Ruby 1.8 so you need to upgrade to at least 1.9 to make it working.
If so, then check How to install a specific version of a ruby gem?
If this won't help, then reinstalling ruby-dev again.
You can use RVM(Ruby version manager) which helps in managing all versions of ruby on your machine , which is very helpful for you development (when migrating to unstable release to stable release )
or for Linux (ubuntu) go for
sudo apt-get install ruby1.8-dev
then sudo gem install rails to verify it do rails -v it will show version on rails
after that you can install bundles (required gems for development)
Ruby version: 2.7.1
gem version: 3.1.3
You need to check the extension that could not be installed, and find the reasons.
Read the mkmf.log file showed at the installation error under "To see why this extension failed to compile, please check the mkmf.log which can be found here" , perhaps there is a missing lib ( sometimes iconv ), and you must install it.
You can search the extension with your package manager(apt, yum, pacman...) too.
(Personal case) Arch Linux->nokogiri
gem install rails
Showed me:
To see why this extension failed to compile, please check the mkmf.log
which can be found here:
/home/user/.gem/ruby/2.7.0/extensions/x86_64-linux/2.7.0/nokogiri-1.10.9/mkmf.log
Go to: https://aur.archlinux.org/packages/ruby-nokogiri/
Make sure you have all dependencies installed
Make sure you have make installed
git clone the package
cd to package
makepkg the package
Hope to help!

Error when trying to run gem install

I'm trying to get rails up and running on my development server. It's a fedora14 box. I installed rvm, ruby 1.8.7, and rubygems 1.6.2. When I try to install rails via gem, gem install rails, i get the following error:
ERROR: Loading command: install (LoadError)
no such file to load -- zlib
ERROR: While executing gem ... (NameError)
uninitialized constant Gem::Commands::InstallCommand
Any ideas as to what is going on. I'm 100% new to ruby/rubygems/rails and I know enough about Linux to be dangerous so any help/suggestions would be greatly appreciated.
Thanks in advance
Run rvm notes and install whatever it tells you (zlib-devel will probably be one of the packages you'll need to install via yum). The output you'll see will be similar to this:
# For Ruby (MRI & Ree) you should install the following OS dependencies:
ruby: yum install -y gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel ;
yum install -y make bzip2 ;
yum install -y iconv-devel # NOTE: For centos 5.4 final iconv-devel might not be available :(
You need to install the zlib libraries. A gem is trying to use it with a C extension but it is not found. http://fr.rpmfind.net/linux/rpm2html/search.php?query=zlib-devel&system=&arch= Install zlib-devel.
What this error means is that zlib library is missing. This is a common problem and if you google for it, you'd find loads of information on the same. In ubuntu (where I work) installing the package zlib1g-dev and zlib1g fixes it. I am not sure what the equivalent package in Fedora is, but you should be able to search / find that.

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

Resources