0

我一直在尝试在 Windows 上为 Ruby 安装 taglib-ruby,但我不知道如何告诉 gem 安装程序在哪里寻找我的 taglib 副本。安装程序在 /usr/local/ 和其他类似的地方查找,但这是一台 Windows 机器,这些位置不存在,所以我不能只是将 taglib 移动到那里。我在 gem 的 github 页面上看到了这篇文章,它告诉您使用以下格式指定位置:CONFIGURE_ARGS="--with-opt-dir=Path/to/taglib" gem install taglib-ruby,但这在 Windows PowerShell 中不起作用。我也试过这个公式:gem install taglib-ruby -- 'CONFIGURE_ARGS="--with-opt-dir=Path/to/taglib/"'。但它同样不起作用。

我看到的错误信息是:

Temporarily enhancing PATH to include DevKit... Building native
extensions with: '--with-opt-dir=/hi/' This could take a while...
ERROR:  Error installing taglib-ruby:
        ERROR: Failed to build gem native extension.

current directory: C:/XXXXXXX/taglib_base C:/XXXXX/ruby.exe -r ./siteconf20161010-10032-1260rq7.rb extconf.rb --with-opt-dir=/hi/
checking for main() in -lstdc++... yes 
checking for main() in -ltag... no 
You must have taglib installed in order to use taglib-ruby.

Debian/Ubuntu: sudo apt-get install libtag1-dev 
Fedora/RHEL: sudo yum install taglib-devel 
Brew: brew install taglib 
MacPorts: sudo port install taglib

*** 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
    --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=C:/Ruby23-x64/bin/$(RUBY_BASE_NAME)
    --with-tag-dir
    --without-tag-dir
    --with-tag-include
    --without-tag-include=${tag-dir}/include
    --with-tag-lib
    --without-tag-lib=${tag-dir}/lib
    --with-stdc++lib
    --without-stdc++lib
    --with-taglib
    --without-taglib

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

您可以看到 --with-opt-dir 是一个选项,但它没有设置,即使调用显示它是。关于如何使它工作的任何想法?

注意:我也尝试为“with-opt-dir”和“CONFIGURE_ARGS”设置环境变量,但它们也失败了。

4

1 回答 1

0

我遇到了类似的问题,并通过 GitHub 询问了维护者。没错,问题是由于本地扩展构建无法找到您的 TagLib 安装。我可以通过将 TagLib 移动到路径中没有空格的位置(默认为C:\Program Files (x86)\taglib,所以我将其移动到C:\lib\taglib)来修复它,并在通过环境变量设置 with-tag-dir 时省略任何引号。我不确定使用 Ruby 的首选文件夹分隔符是否会有所不同,但我做到了。

在命令行:

> set CONFIGURE_ARGS="--with-tag-dir=C:/lib/taglib-1.9.1"
> echo %CONFIGURE_ARGS%
  "--with-tag-dir=C:/lib/taglib-1.9.1"
> gem install taglib-ruby
于 2016-10-28T05:34:45.987 回答