【发布时间】:2018-02-15 02:11:43
【问题描述】:
我使用 'fluent-logger' gem 来登录我们的项目,它需要 'msgpack'。如果我运行 bundle install,它会拉入 msgpack-1.1.0-x86-mingw32,这会在 Windows 上要求它时引发异常。
kernel_require.rb:55:in `require': cannot load such file -- msgpack/msgpack (LoadError)
但是有一个解决该问题的方法,只需使用 --platform=ruby 重新安装 gem,如下所示:
gem uninstall msgpack
gem install msgpack --platform=ruby
我尝试将此要求放入 Gemfile 中,如其他地方所示(找不到链接 atm),但它没有做任何事情(像以前一样安装 msgpack-1.1.0-x86-mingw32):
gem 'msgpack', :platforms=>:ruby
我在 Windows 7 上使用 Ruby 1.9.3p551(和 bundler v 1.14.6),以防万一。
编辑
为了让每个想要的人,自己尝试一下,我给出了一个示例源。
宝石文件:
source 'http://rubygems.org'
ruby '1.9.3'
gem 'fluent-logger'
gem 'msgpack', :platforms=>:ruby_19
#for windows local dev msgpack needs to be installed with --platform=ruby
foo.rb
require 'fluent-logger'
logger= Fluent::Logger::FluentLogger.new
#logger.post('idx',{message:'it works'})
puts 'worked'
记录器不会创建有效的连接,但如果它通过了,那就太好了
(这里唯一重要的是 Gemfile 没有引入正确版本的 msgpack(在我的情况下是 1.1.0-x86-mingw32 而不是 1.1.0))
【问题讨论】: