I'm trying to install OpenGraph gem in ruby - ruby-on-rails

I've searched entire web looking for a way to get over this error. But it won't budge. I installed all the libraries and dependencies according to my knowledge even uninstalled ruby and nokogiri and reinstalled again. But this error remains here.
Gem files will remain installed in /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/nokogiri-1.4.7 for inspection.
Results logged to /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/nokogiri-1.4.7/gem_make.out
This is from the gem_make.out log file from this location -> /.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/extensions/x86_64-linux/2.4.0-static/nokogiri-1.4.7/gem_make.out
ERROR: Error installing opengraph:
ERROR: Failed to build gem native extension.
current directory: /home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/nokogiri-1.4.7/ext/nokogiri
/home/$User/.rbenv/versions/2.4.2/bin/ruby -r ./siteconf20171125-15877-nibcps.rb extconf.rb --with-nokogiri-dir=/home/$User/.rbenv/versions/2.4.2/lib/ruby/gems/2.4.0/gems/
*** 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/$User/.rbenv/versions/2.4.2/bin/$(RUBY_BASE_NAME)
extconf.rb:10:in `<main>': uninitialized constant Config (NameError)
Did you mean? RbConfig
CONFIG
extconf failed, exit code 1
I'd be very thankful to you if you could tell me what's wrong with it. Is it a bug in OpenGraph.
P.S: I'm not using opengraph_parser because it has a fallback method. I need opengraph gem because I need to catch the exception.

It's not opengraph, but rather nokogiri.
Nokogiri is a dependency for opengraph.
https://rubygems.org/gems/opengraph/versions/0.0.4
So, it must be related on your machine not having the dependencies needed to support nokogiri (libxml2).
Install these dependencies on your machine (assuming your on Debian/Ubuntu):
sudo apt-get install build-essential patch ruby-dev zlib1g-dev liblzma-dev
Fedora/Red Hat/CentOS:
sudo yum install -y gcc ruby-devel zlib-devel
sudo yum install -y rubygem-nokogiri (alternative)
Then try installing nokogiri by gem install nokogiri
For other variants, or OS:
http://www.nokogiri.org/tutorials/installing_nokogiri.html
For Fedora 26:
Until further notice, install nokogiri version < 1.8

Related

Can't install RMagick 4.2.3

I'm running Debian WSL 2 and I cannot install any version of RMagick.
I installed imagemagick#6 via homebrew and after installation I saw following:
imagemagick#6 is keg-only, which means it was not symlinked into /home/linuxbrew/.linuxbrew,
because this is an alternate version of another formula.
If you need to have imagemagick#6 first in your PATH, run:
echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/imagemagick#6/bin:$PATH"' >> ~/.zshrc
For compilers to find imagemagick#6 you may need to set:
export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/imagemagick#6/lib"
export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/imagemagick#6/include"
For pkg-config to find imagemagick#6 you may need to set:
export PKG_CONFIG_PATH="/home/linuxbrew/.linuxbrew/opt/imagemagick#6/lib/pkgconfig"
I followed all the instructions above
then I tried to install RMagick via gem install rmagick -v '4.1.2' --source 'https://rubygems.org/'
and got output:
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
current directory: /home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/rmagick-4.1.2/ext/RMagick
/home/ketch/.asdf/installs/ruby/2.7.1/bin/ruby -I /home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0 -r ./siteconf20211106-21975-1odkmjc.rb extconf.rb
checking for brew... yes
checking for Ruby version >= 2.3.0... yes
checking for pkg-config... yes
ERROR: Can't install RMagick 4.1.2. Can't find ImageMagick with pkg-config
*** 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/ketch/.asdf/installs/ruby/2.7.1/bin/$(RUBY_BASE_NAME)
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/rmagick-4.1.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/rmagick-4.1.2 for inspection.
Results logged to /home/ketch/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/extensions/x86_64-linux/2.7.0/rmagick-4.1.2/gem_make.out
I tried to install rmagick on my WSL debian, WSL ubuntu, and on Manjaro through virtual machine, everytime the same error

How to install ruby-odbc gem on M1 Mac

I am trying to get a rails project running on an M1 mac.
I have to use ruby 2.6.2 and rails 5.2.3
I am using rbenv 1.1.2 and homebrew 3.0
When I run bundle install, I get this error
An error occurred while installing ruby-odbc (0.99999), and Bundler cannot continue.
Make sure that `gem install ruby-odbc -v '0.99999'` succeeds before bundling.
So then I run gem install ruby-odbc -v '0.99999'
This leads to another error
ERROR: Error installing ruby-odbc:
ERROR: Failed to build gem native extension.
current directory: /Users/david.lee/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/ruby-
odbc-0.99999/ext
/Users/david.lee/.rbenv/versions/2.6.2/bin/ruby -I
/Users/david.lee/.rbenv/versions/2.6.2/lib/ruby/2.6.0 -r ./siteconf20210208-46271-1tguvxe.rb
extconf.rb
checking for version.h... no
checking for sql.h... no
*** 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=/Users/david.lee/.rbenv/versions/2.6.2/bin/$(RUBY_BASE_NAME)
--with-odbc-dir
--without-odbc-dir
--with-odbc-include
--without-odbc-include=${odbc-dir}/include
--with-odbc-lib
--without-odbc-lib=${odbc-dir}/lib
ERROR: sql.h not found
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Users/david.lee/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/extensions/-darwin-20/2.6.0/ruby-odbc-0.99999/mkmf.log
When I stackoverflow this error, I get this post which tells me to brew install unixodbc, so I do that and try to bundle install again, which gives me the same error.
All the stackoverflow posts related to sql.h files not being installed do not solve my issue.
HOW DO I INSTALL THIS GEM?
Thanks to a co-worker, I got this resolved.
You need to install the gem while pointing it to the unixodbc directory
This was the line that installed it for me
gem install ruby-odbc -- --with-odbc-dir=/opt/homebrew/Cellar/unixodbc/2.3.9
To find your unixodbc path, run brew info unixodbc
That will give you the path and your version number of unixodbc. Then you put the path and version number in the appropriate spot
gem install ruby-odbc -- --with-odbc-dir=put your path and version number of unixodbc here
None of the above solutions worked for me when I had this error. This is what worked for me:
bundle config set build.ruby-odbc --with-odbc-dir=/opt/homebrew/Cellar/unixodbc/2.3.11
Per this StackOverflow post
If you need this to work while running the bundle command, do the following:
bundle config build.odbc --with-odbc-dir=$(brew --prefix unixodbc)

Error while bundle install for idn-ruby

I have twitter-text gem in my application.
When I do a bundle install I am getting the below error.
Need to solve it on high priority.
I also went to the github page https://github.com/twitter/twitter-text/issues/225
but could not find a solution there.
I tried to install directly using the line below but got the same error.
gem install idn-ruby -v '0.1.0'
Error
Fetching idn-ruby 0.1.0
Installing idn-ruby 0.1.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/inuscg/.rvm/gems/ruby-2.3.0#idt-two/gems/idn-ruby-0.1.0/ext
/home/inuscg/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20180427-13217-1wpq9sy.rb extconf.rb
checking for main() in -lidn... no
ERROR: could not find idn library!
Please install the GNU IDN library or alternatively specify at least one
of the following options if the library can only be found in a non-standard
location:
--with-idn-dir=/path/to/non/standard/location
or
--with-idn-lib=/path/to/non/standard/location/lib
--with-idn-include=/path/to/non/standard/location/include
*** 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/inuscg/.rvm/rubies/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
--with-idn-dir
--without-idn-dir
--with-idn-include
--without-idn-include=${idn-dir}/include
--with-idn-lib
--without-idn-lib=${idn-dir}/lib
--with-idnlib
--without-idnlib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/home/inuscg/.rvm/gems/ruby-2.3.0#idt-two/extensions/x86_64-linux/2.3.0/idn-ruby-0.1.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /home/inuscg/.rvm/gems/ruby-2.3.0#idt-two/gems/idn-ruby-0.1.0 for inspection.
Results logged to /home/inuscg/.rvm/gems/ruby-2.3.0#idt-two/extensions/x86_64-linux/2.3.0/idn-ruby-0.1.0/gem_make.out
An error occurred while installing idn-ruby (0.1.0), and Bundler cannot continue.
Make sure that `gem install idn-ruby -v '0.1.0'` succeeds before bundling.
In Gemfile:
twitter-text was resolved to 2.1.0, which depends on
idn-ruby
Thank you in advance
As per the error show in logs
ERROR: could not find idn library!. idn library is required to install twitter text. Try to install that first and then install the gem. Try with
sudo apt-get install libldap2-dev
sudo apt-get install libidn11-dev
Hope this solves your problem.
For mac:
brew install libidn
On a Mac, you can do:
$ brew install libidn
If you're using Mac OS, then here's how to install libidn:
$ brew install libidn
On Centos 7 I had to install libidn-devel via yum install libidn-devel
If you are using Windows and facing same error, then try
Instruction for Windows
Get the appropriate build of GNU LibIDN Library from here
Unpack it where you prefer (e.g. c:\tmp\libs\libidn)
Add option to bundler config
BUNDLE_BUILD__IDN-RUBY: "--with-idn-dir=C:/tmp/libs/libidn/"
Launch bundler install
As for me I used libidn-1.33-win64.zip package
You're required to install LibIDN beforehand, since the gem is just ruby bindings for it.
Requirements
GNU LibIDN Library
Rake to run the tests and generate the documentation
RubyGems to produce a Gem package
Ruby 1.9.1 or above. Patches welcome to make this work in 1.8.7
The specific download method would depend on your OS, but if it's Ubuntu, try sudo apt-get install libidn

Nokogiri error on installation due to missing native extension

I have been trying to install Ruby on Rails based on these instructions. However, I am getting the following error upon running gem install rails -v 4.2.4:
Fetching: rack-1.6.4.gem (100%)
Successfully installed rack-1.6.4
Building native extensions. This could take a while...
ERROR: Error installing rails:
ERROR: Failed to build gem native extension.
/home/falak/.rvm/rubies/ruby-2.2.3/bin/ruby -r ./siteconf20150909-22683-172bl7d.rb extconf.rb
checking if the C compiler accepts ... *** 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/falak/.rvm/rubies/ruby-2.2.3/bin/$(RUBY_BASE_NAME)
--help
--clean
/home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:571:in `block in try_compile'
from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:522:in `with_werror'
from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:571:in `try_compile'
from extconf.rb:80:in `nokogiri_try_compile'
from extconf.rb:87:in `block in add_cflags'
from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:619:in `with_cflags'
from extconf.rb:86:in `add_cflags'
from extconf.rb:337:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /home/falak/.rvm/gems/ruby-2.2.3/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /home/falak/.rvm/gems/ruby-2.2.3/extensions/x86_64-linux/2.2.0/nokogiri-1.6.6.2/gem_make.out
I tried installing nokogiri using system libraries by running gem install nokogiri -v 1.6.2.1 -- --use-system-libraries, but I got the following error:
Building native extensions with: '--use-system-libraries'
This could take a while...
Building nokogiri using system libraries.
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/home/falak/.rvm/rubies/ruby-2.2.3/bin/ruby -r ./siteconf20150909-23169-twqmu6.rb extconf.rb --use-system-libraries
Building nokogiri using system libraries.
*** 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/falak/.rvm/rubies/ruby-2.2.3/bin/$(RUBY_BASE_NAME)
--help
--clean
--use-system-libraries
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-libxml-2.0-config
--without-libxml-2.0-config
--with-pkg-config
--without-pkg-config
/home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:541:in `try_link0'
from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:556:in `try_link'
from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:637:in `try_ldflags'
from /home/falak/.rvm/rubies/ruby-2.2.3/lib/ruby/2.2.0/mkmf.rb:1780:in `pkg_config'
from extconf.rb:338:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /home/falak/.rvm/gems/ruby-2.2.3/gems/nokogiri-1.6.2.1 for inspection.
Results logged to /home/falak/.rvm/gems/ruby-2.2.3/extensions/x86_64-linux/2.2.0/nokogiri-1.6.2.1/gem_make.out
Try installing the libgmp-dev library
apt-get install libgmp-dev
Using RVM to install rails in ruby 2.2.3 has been a major problem among other users as well. For now, you can still get rails 4.2.4 in ruby 2.2.2.
Try:
rvm install 2.2.2
rvm --default use 2.2.2
gem install rails
this should still work. RVM for some reason does not install the right headers in 2.2.3 for you to build the gems.
For OS X users: remember update the Xcode command line developer tools, this is the problem for the 99% OS X users. xcode-select --install
You can try this amazing solution for this
The solution is:
sudo apt-get install ruby-dev
Or, if that doesn't work, depending on your ruby version, run something like:
sudo apt-get install ruby1.9.1-dev
Should fix your problem.
Still not working? Try the following after installing ruby-dev:
sudo apt-get install make
This solution is for nokogiri error:
sudo apt-get install ruby-dev
As the error says check in the mkmf.log file. There you'll find the missing header files.
In my case I was missing zlib.h. The error was:
The #include file "zlib.h" is not found
So to fix it:
sudo apt-get install zlib1g-dev
To find required dev packages, one can use apt-file
$ apt-file search zlib.h
zlib1g-dev: /usr/include/zlib.h

Can't install RMagick 2.13.1. Can't find Magick-config

$ gem install rmagick
Building native extensions. This could take a while...
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/Users/XXXXXXX/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no
Can't install RMagick 2.13.1. Can't find Magick-config in /Users/XXXXXXX/.rvm/gems/ruby-1.9.2-p180/bin:/Users/XXXXXXX/.rvm/gems/ruby-1.9.2-p180#global/bin:/Users/XXXXXXX/.rvm/rubies/ruby-1.9.2-p180/bin:/Users/XXXXXXX/.rvm/bin:/Users/XXXXXXX/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin
*** 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=/Users/XXXXXXX/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
Gem files will remain installed in /Users/XXXXXXX/.rvm/gems/ruby-1.9.2-p180/gems/rmagick-2.13.1 for inspection.
Results logged to /Users/XXXXXXX/.rvm/gems/ruby-1.9.2-p180/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
But when I do this:
$ locate Magick-config
/opt/local/bin/Magick-config
/opt/local/share/man/man1/Magick-config.1.gz
/opt/local/var/macports/software/ImageMagick/6.6.4-9_0+q16/opt/local/bin/Magick-config
/opt/local/var/macports/software/ImageMagick/6.6.4-9_0+q16/opt/local/share/man/man1/Magick-config.1.gz
/opt/local/var/macports/software/ImageMagick/6.6.5-0_0+q16/opt/local/bin/Magick-config
/opt/local/var/macports/software/ImageMagick/6.6.5-0_0+q16/opt/local/share/man/man1/Magick-config.1.gz
Any ideas?
command: sudo apt-get install libmagickwand-dev
It isn't quite the answer to the question, but the recommended way of installing Imagemagick and Rmagick on Mac is through homebrew. It's the only way I could get Imagemagick and Rmagick playing nicely together on Mac.
For Ubuntu (11.10+) try installing the libmagick++-dev package.
For other Linux distributions, try installing the libmagick-dev package.
For my case, I am installing it on Ubuntu/Linaro 4.5.2-8ubuntu3, got same error, tried to installed the following two package suites and it worked, maybe either one of them:
sudo apt-get install graphicsmagick-libmagick-dev-compat
sudo apt-get install libmagickwand-dev
On mac, after
brew install imagemagick
Don't forget to link dylibs with:
brew link imagemagick
I had to transfer an old application to a debian stretch server.
The used ruby version was 2.0.x.
imagemagick was installed including libmagickwand-dev.
Trying to install rmagick 2.13.2 failed.
I had to upgrade the rmagick verion (patched my Gemfile.lock) to use rmagick 2.16.0, the last version supporting ruby 2.0.

Resources