twitter / twitter-text

Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform.
https://developer.twitter.com/en/docs/counting-characters
Apache License 2.0
3.07k stars 510 forks source link

JRuby Support #225

Open jeremyhaile opened 6 years ago

jeremyhaile commented 6 years ago

twitter-text 2.x depends on the idn-ruby gem which doesn't currently support JRuby. This means that twitter-text also doesn't work on JRuby.

Was this intentional? Is there any workaround? Can the dependency on idn-ruby be made optional?

iantheparker commented 6 years ago

I second making idn-ruby optional. I'd happily take an error message saying that a domain name in kanji can't be supported over having to deal with idn-ruby ( which looks like a dead gem dependent on some ugly hackery to install libidn )

bartkamphorst commented 6 years ago

This dependency on idn-ruby also breaks JRuby support for gollum. We too would appreciate it if idn-ruby were made optional.

oyeanuj commented 6 years ago

Also, having trouble installing idn-ruby even in a standard Rails-MRI setup. @kaushlakers Any thoughts on what and when solution are you folks considering for this?

zegomesjf commented 6 years ago

brew install libidn

octopusinvitro commented 6 years ago

@zegomesjf is there anything like that for Ubuntu users? I tried sudo apt-get install idn, and the library is installed, but the gem can't find it.

I also tried installing as indicated here: http://www.gnu.org/software/libidn/ but the gem still can't find it

Finally I followed the instructions here: http://www.linuxfromscratch.org/blfs/view/cvs/general/libidn.html the gem still can't find it.

This is the error message I get:

Installing idn-ruby 0.1.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/ubuntu/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/idn-ruby-0.1.0/ext
/home/ubuntu/.rbenv/versions/2.5.0/bin/ruby -r ./siteconf20180301-15079-169teyr.rb extconf.rb
checking for -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/ubuntu/.rbenv/versions/2.5.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/ubuntu/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/idn-ruby-0.1.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/ubuntu/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/idn-ruby-0.1.0 for inspection.
Results logged to /home/ubuntu/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/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
pmokariya commented 6 years ago

I have this same error , help us to resolve it. [ 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-3409-q264pw.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 ](url)

dfutrille commented 6 years ago

Try with this: sudo apt-get install libghc-gnuidn-dev This fix it for me!

tsutsui commented 5 years ago

FYI, @shibafu528 has patches for twitter-text to use simpleidn https://github.com/mmriis/simpleidn instead of idn-ruby https://github.com/shibafu528/twitter-text/commit/80cdb0c76e64a71401c1bd4cb2f58327c82d99ff with some modification https://github.com/shibafu528/simpleidn/commit/69420ce9777a4b2a338dd981b31a3d4fc39dd72b

rburton commented 5 years ago

For mac, do brew install libidn and then you can install gem install idn-ruby -v '0.1.0' --source 'https://rubygems.org/'

xijo commented 3 years ago

I'd like to bump this issue. On apple m1 arm64 architecture libidn does no longer compile, so brew install libidn is no longer valid.

Is there any reason why switching to simpleidn is not a good idea?

teomores commented 3 years ago

For those using the apple m1, you can install it by passing the path to the lib as it does not seem to be able to find it otherwise. Something like:

bew install libidn
gem install idn-ruby -v '0.1.0' -- --with-idn-dir=/opt/homebrew/Cellar/libidn/1.36/
herrowna commented 1 year ago

For those using the apple m1, you can install it by passing the path to the lib as it does not seem to be able to find it otherwise. Something like:

bew install libidn
gem install idn-ruby -v '0.1.0' -- --with-idn-dir=/opt/homebrew/Cellar/libidn/1.36/

This solution worked for me except libidn is now 1.41. Thank you so much!