无法在Windows 10上安装tiny_tds

3
当我运行以下代码时:
gem install tiny_tds

输出告诉我需要安装FreeTDS。接下来,它显示给我一些配置选项,我可能需要一个选项。这些选项如下:

    --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=C:/Ruby31-x64/bin/$(RUBY_BASE_NAME)
    --help
    --with-freetds-dir
    --without-freetds-dir
    --with-freetds-include
    --without-freetds-include=${freetds-dir}/include
    --with-freetds-lib
    --without-freetds-lib=${freetds-dir}/lib
    --with-sybdb-dir
    --without-sybdb-dir
    --with-sybdb-include
    --without-sybdb-include=${sybdb-dir}/include
    --with-sybdb-lib
    --without-sybdb-lib=${sybdb-dir}/lib
    --with-sybdblib
    --without-sybdblib
    --with-sybdblib
    --without-sybdblib

问题在于没有一个选项是可行的。以下是一个例子,展示了发生了什么:
C:\RailsApps>gem install tiny_tds -- --with-freetds-dir
Temporarily enhancing PATH for MSYS/MINGW...
Using msys2 packages: mingw-w64-ucrt-x86_64-freetds
Building native extensions with: '--with-freetds-dir'
This could take a while...
ERROR:  Error installing tiny_tds:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tiny_tds-2.1.5/ext/tiny_tds
    C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 -r ./siteconf20220308-11104- 
    42q9r4.rb extconf.rb --with-freetds-dir
*** 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=C:/Ruby31-x64/bin/$(RUBY_BASE_NAME)
        --help
        --with-freetds-dir
C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1807:in `dir_config': undefined method `split' for true:TrueClass (NoMethodError)

      defaults = Array === dir ? dir : dir.split(File::PATH_SEPARATOR)
                                          ^^^^^^
        from extconf.rb:56:in `<main>'
looking for freetds headers in the following directories:
 - /opt/local/include
 - /opt/local/include/freetds
 - /usr/local/include
 - /usr/local/include/freetds
looking for freetds library in the following directories:
 - /opt/local/lib
 - /opt/local/lib/freetds
 - /usr/local/lib
 - /usr/local/lib/freetds

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/tiny_tds-2.1.5 for inspection.
Results logged to C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/tiny_tds-2.1.5/gem_make.out

我下载了FreeTDS二进制文件,准备尝试在Windows上手动安装,但我不知道要把它们放在哪里或如何使用它们。


2
仅凭错误信息(in dir_config),我猜测 --with-freetds-dir 可能需要一个参数。是的,我认为是这样的。请参考文档中的示例。 - Jared Beck
没意识到这一点。我添加了下载FreeTDS二进制文件的路径,并且顺利完成了安装!谢谢! - Matías Leandro
2个回答

5

感谢之前的帖子,我通过查看freetds windows zipfile和已安装的pacman包来解决了问题。

可能是在C:\Ruby31-x64\msys64\ucrt64\include寻找include文件夹头文件, 但实际上它们在C:\Ruby31-x64\msys64\ucrt64\include\freetds。 有趣的是.exe文件位于C:\ Ruby31-x64 \ msys64 \ ucrt64 \ bin,并且可以找到。

 gem install tiny_tds -- --with-freetds-include=C:\Ruby31-x64\msys64\ucrt64\include\freetds

也可参见:Tiny TDS GitHub Issue 503

2
感谢Jared Beck的帮助,我终于成功编译了FreeTDS二进制文件。以前使用Ruby on Rails时从未遇到过这种情况,所以我不熟悉语法。我认为运行命令gem install tiny_tds就包括了FreeTDS安装。然后我注意到配置选项,并尝试运行gem install tiny_tds -- --with-freetds-dir,但不知道该命令需要目录作为参数。
最后,我从https://sourceforge.net/projects/freetdswindows/下载了FreeTDS Windows二进制文件,将其提取到C:中,并运行以下命令:
gem install tiny_tds -- --with-freetds-dir=C:\freetds-1.00

Matías Leandro 写道:gem install tiny_tds -- --with-freetds-dir=C:\freetds-1.00。这对我来说很好用,gem 已经安装成功了。在安装 gem 后,C:\freetds-1.00 文件夹是否还需要保留?或者它只是在构建过程中需要?是否有任何 *.exe 文件被创建?我问这个问题是因为在 ruby/gem/folder/tiny_tds 中找不到任何文件。 - ped

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接