Rmagick initilzation error: cannot load such file -- rvg/rvg

84 Views Asked by At

I am using Ubuntu 20.0.4. Ruby version is:

ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

Gem version is:

gem --version
3.1.4

I have installed imagemagick:

convert --version
Version: ImageMagick 6.9.10-23 Q16 x86_64

Then I installed required packages:

sudo apt-get install libmagickwand-dev

And then I installed Rmagick:

sudo gem install rmagick
Building native extensions. This could take a while...
Successfully installed rmagick-4.2.6
Parsing documentation for rmagick-4.2.6
Done installing documentation for rmagick after 0 seconds
1 gem installed

This shows that rmagick is installed but once I try to run command:

ruby pheno_gram.rb -i phenogram-sample.txt -g human_genome.txt -Y cytoBand-human.txt -c exhaustive -p proximity -f png -p equal -o plot_phenogram -t "New Image"

I get msg:

cannot load such file -- rvg/rvg

Please install RMagick -- See documentation for pheno_gram or http://rmagick.rubyforge.org/install-faq.html 

It seems that I need to install ruby rvg library,so I tried to install it using command:

sudo snap install hello-rvg --candidate

But still getting same error. Secodly, Do I need to add rmagick path somewhere, if yes how can I do that?

I have also tried to install rmagick without sudo but it gives error:

gem install rmagick
Building native extensions. This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

    current directory: /home/super/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rmagick-4.2.6/ext/RMagick
/home/super/.rbenv/versions/2.7.2/bin/ruby -I /home/super/.rbenv/versions/2.7.2/lib/ruby/2.7.0 -r ./siteconf20220827-10097-72cju5.rb extconf.rb
checking for brew... no
checking for pacman... yes
checking for Ruby version >= 2.3.0... yes
checking for pkg-config... yes
checking for outdated ImageMagick version (<= 6.7.7)... no
checking for /home/super/miniconda3/bin/x86_64-conda-linux-gnu-cc... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/super/.rbenv/versions/2.7.2/bin/$(RUBY_BASE_NAME)
/home/super/.rbenv/versions/2.7.2/lib/ruby/2.7.0/mkmf.rb:471:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /home/super/.rbenv/versions/2.7.2/lib/ruby/2.7.0/mkmf.rb:564:in `try_link0'
    from /home/super/.rbenv/versions/2.7.2/lib/ruby/2.7.0/mkmf.rb:582:in `try_link'
    from extconf.rb:79:in `configure_compile_options'
    from extconf.rb:19:in `initialize'
    from extconf.rb:405:in `new'
    from extconf.rb:405:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/super/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/rmagick-4.2.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/super/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/rmagick-4.2.6 for inspection.
Results logged to /home/super/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/rmagick-4.2.6/gem_make.out

Any help will be highly appreciated.

1

There are 1 best solutions below

0
uamin On

It seems your problem is associated with your user role. brute force possible solution: use sudo for running sudo ruby pheno_gram.rb -i phenogram-sample.txt -g human_genome.txt -Y cytoBand-human.txt -c exhaustive -p proximity -f png -p equal -o plot_phenogram -t "New Image"

check these out:

  1. did you install your ruby with sudo user?
  2. did you check what is ruby installation folder ownership? and your user are added to owner group?

with cmd sudo usermod -a -G <GROUP> $USER