16

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

Cindy Meister
  • 25,071
  • 21
  • 34
  • 43
Pooja Mokariya
  • 1,970
  • 5
  • 21
  • 46

6 Answers6

32

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
Pardeep Saini
  • 2,084
  • 1
  • 18
  • 29
  • 8
    I'm on Apple silicon and I had to set --with-idn-dir to make this work. `gem install idn-ruby -v '0.1.0' -- --with-idn-dir=$(brew --prefix libidn)` – Ponny Dec 09 '21 at 02:38
21

On a Mac, you can do:

$ brew install libidn
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Kenneth Rosales
  • 231
  • 1
  • 4
6

If you're using Mac OS, then here's how to install libidn:

$ brew install libidn
Huy Vo
  • 2,418
  • 6
  • 22
  • 43
4

On Centos 7 I had to install libidn-devel via yum install libidn-devel

NoahP
  • 111
  • 5
2

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

samokoder
  • 21
  • 2
1

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

Amin Shah Gilani
  • 8,675
  • 5
  • 37
  • 79