ruby-on-rails 安装idn-ruby包时出错

jdgnovmf  于 2023-10-21  发布在  Ruby
关注(0)|答案(7)|浏览(113)

我的应用程序中有twitter-text gem。
当我做一个捆绑安装我得到下面的错误。
必须优先解决。
我也去了github页面https://github.com/twitter/twitter-text/issues/225
但在那里找不到解决办法。
我尝试使用下面的行直接安装,但得到了相同的错误。

gem install idn-ruby -v '0.1.0'

误差

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

提前感谢您

pkmbmrz7

pkmbmrz71#

根据日志ERROR: could not find idn library!中显示的错误。idn库是必需的安装twitter文本.尝试先安装它,然后再安装gem。尝试与

sudo apt-get install libldap2-dev
sudo apt-get install libidn11-dev

希望这能解决你的问题。
对于Mac:

brew install libidn
zaq34kh6

zaq34kh62#

在Mac上,您可以:

$ brew install libidn
ztyzrc3y

ztyzrc3y3#

如果您使用的是Mac OS,那么以下是如何安装libidn

$ brew install libidn
hk8txs48

hk8txs484#

在Centos 7上,我必须通过yum install libidn-devel安装libidn-devel

68bkxrlz

68bkxrlz5#

如果您使用的是Windows并面临同样的错误,然后尝试

Windows使用说明

  • here获取GNU LibIDN库的适当版本
  • 在你喜欢的地方打开它(例如,c:\tmp\libs\libidn
  • 将选项添加到配置BUNDLE_BUILD__IDN-RUBY: "--with-idn-dir=C:/tmp/libs/libidn/"
  • 启动bundler install

至于我,我用libidn-1.33-win64.zip

2ledvvac

2ledvvac6#

您需要事先安装LibIDN,因为gem只是它的ruby绑定。

要求

  • GNU LibIDN库
  • Rake运行测试并生成文档
  • RubyGems生成一个Gem包
  • Ruby 1.9.1或以上欢迎补丁在1.8.7中使用此功能

具体的下载方法取决于你的操作系统,但如果是Ubuntu,请尝试sudo apt-get install libidn

ztigrdn8

ztigrdn87#

在带有HomebrewOS X上:

gem install idn-ruby -- --with-idn-dir=$(brew --prefix libidn)

相关问题