You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows环境下数据库连接问题:安装tiny_tds后Rails控制台报错

解决tiny_tds gem加载失败问题

错误信息

下午1:09
WARNING: could not load hiredis extension, using (slower) pure Ruby implementation.
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require': cannot load such file -- tiny_tds/tiny_tds (LoadError)
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tiny_tds-0.7.0-x64-mingw32/lib/tiny_tds.rb:23:in `rescue in <main>'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tiny_tds-0.7.0-x64-mingw32/lib/tiny_tds.rb:22:in `<main>'
...
C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require': cannot load such file -- tiny_tds/3.0/tiny_tds (LoadError)
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
from C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/tiny_tds-0.7.0-x64-mingw32/lib/tiny_tds.rb:21:in `<main>'
...

解决步骤

  • 升级tiny_tds版本:当前使用的tiny_tds 0.7.0对Ruby 3.x支持有限,安装适配版本:
    gem uninstall tiny_tds
    gem install tiny_tds -v 2.1.5
    # 或在Gemfile中指定版本后执行
    bundle install
    
  • 匹配架构重新安装:Windows下确保gem架构与Ruby一致(x64):
    gem install tiny_tds --platform=x64-mingw32
    
  • 清理bundler缓存:移除缓存的旧依赖文件后重新安装:
    bundle clean --force
    bundle install
    
  • 检查FreeTDS依赖:tiny_tds需要FreeTDS库支持,下载对应x64版本的FreeTDS,将其bin目录添加到系统PATH,再重新安装tiny_tds。
  • 临时禁用bootsnap:注释掉config/boot.rb中bootsnap的加载代码,测试是否为缓存导致的文件查找失败,若有效则更新bootsnap版本或调整配置。

内容的提问来源于stack exchange,提问作者Satendra Khangar

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 14:23:09