Ruby/Rake,并继承了使用ruby & rake构建/部署的一组C#项目。
由于一颗旧宝石,这款产品上周停工了。在将所有gems更新到最新版本的过程中,我遇到了这个未初始化的常量问题。
没有涉及到代码更改,我尝试在setup.rb中添加"require‘logging“。
我一直在假设问题在我们的rake文件中,但在对此进行了几个小时的打击之后,我不太确定。我还没有在代码中找到任何使用常量的地方。
对任何建议或帮助表示感谢。
Windows 2008与Ruby 2.0.0。
创业板列表输出:
*** LOCAL GEMS ***
akami (1.2.1)
albacore (0.3.6)
aws-sdk (1.38.0)
bigdecimal (1.2.0)
builder (3.2.2)
bundler (1.6.0)
ffi (1.9.3 x86-mingw32)
gssapi (1.0.3)
gyoku (1.1.1)
httpclient (2.3.4.1)
httpi (0.9.7)
io-console (0.4.2)
json (1.8.1, 1.7.7)
little-plugger (1.1.3)
logging (1.8.2)
mini_portile (0.5.3)
minitest (4.3.2)
multi_json (1.9.2)
nokogiri (1.6.1 x86-mingw32)
nori (1.1.5)
psych (2.0.0)
rack (1.5.2)
rake (0.9.6)
rdoc (4.0.0)
rubyntlm (0.1.1)
rubyzip (0.9.9)
savon (0.9.5)
test-unit (2.0.0.0)
uuidtools (2.1.4)
wasabi (1.0.0)
win32-service (0.8.4)
winrm (1.1.3)而耙的输出:
rake aborted!
uninitialized constant Logging::Logger::INFO
C:/Ruby200/lib/ruby/2.0.0/rake/ext/module.rb:36:in `const_missing'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/albacore-0.3.6/lib/albacore/support/logging.rb:7:in `initialize'
C:/Ruby200/lib/ruby/gems/2.0.0/gems/albacore-0.3.6/lib/albacore/support/failure.rb:7:in `initialize'
C:/Ruby200/lib/ruby/2.0.0/psych/visitors/to_ruby.rb:13:in `initialize'
C:/Ruby200/lib/ruby/2.0.0/psych/nodes/node.rb:35:in `new'
C:/Ruby200/lib/ruby/2.0.0/psych/nodes/node.rb:35:in `to_ruby'
C:/Ruby200/lib/ruby/2.0.0/psych.rb:130:in `load'
C:/build-dir/MV-MB-JOB1/deploy/setup.rb:5:in `block in <top (required)>'
C:/build-dir/MV-MB-JOB1/deploy/setup.rb:5:in `open'
C:/build-dir/MV-MB-JOB1/deploy/setup.rb:5:in `<top (required)>'
C:/build-dir/MV-MB-JOB1/deploy/rakefile.rb:15:in `require_relative'
C:/build-dir/MV-MB-JOB1/deploy/rakefile.rb:15:in `<top (required)>'
C:/Ruby200/lib/ruby/2.0.0/rake/rake_module.rb:25:in `load'
C:/Ruby200/lib/ruby/2.0.0/rake/rake_module.rb:25:in `load_rakefile'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:604:in `raw_load_rakefile'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:89:in `block in load_rakefile'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:160:in `standard_exception_handling'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:88:in `load_rakefile'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:72:in `block in run'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:160:in `standard_exception_handling'
C:/Ruby200/lib/ruby/2.0.0/rake/application.rb:70:in `run'
C:/Ruby200/bin/rake:37:in `<main>'setup.rb:
require "yaml"
@environment = ENV["environment"] || "development"
@version = ENV["version"] || "none"
@configuration = File.open(File.join("environment", @environment, "global_config.yml"), "rb") {|f| YAML::load(f)}
@configuration.merge!({:environment => @environment,
:version => @version,
:repository_path => ENV["repository_path"]})发布于 2014-04-01 14:35:27
WinRM和Albacore宝石之间似乎存在名称空间冲突,WinRM使用“logging”gem,而Albacore使用“记录器”。都定义了Logger。
使用以下命令:
rake -f myTest.rb --trace这样做是可行的:
require "winrm"`
require "albacore"
task :default do
end这并不意味着:
require "albacore"
require "winrm"
task :default do
endAlbacore实现了lib\albacore\support\logging.rb:
require 'logger'
module Logging
attr_accessor :logger, :current_log_device
def initialize
create_logger(STDOUT, Logger::INFO)
super()
end
def log_device=(logdev)
level = @logger.level
create_logger(logdev, level)
end
.
.
.
endWinRm在winrm.rb中执行以下操作:
require 'date'
require 'kconv' if(RUBY_VERSION.start_with? '1.9') # bug in rubyntlm with ruby 1.9.x
require 'logging'
module WinRM
Logging.logger.root.level = :info
Logging.logger.root.appenders = Logging.appenders.stdout
end
require 'winrm/helpers/iso8601_duration'
require 'winrm/soap_provider'这不是一个适当的修复,而是将Albacore日志模块封装在另一个模块中,并更新对日志记录( Albacore :: Logging )的Albacore引用,解决了这个问题。
修改后的lib\albacore\support\logging.rb:
module Albacore
module Logging
.
.
.
end
end更新:
我打开了一篇关于“阿尔巴多”的文章。今天发布的2.0.0.rc.10包含了名称冲突问题的修复。但是,从2.0前的长时间迁移到2.0.0并不是没有痛苦的,因为有些任务类型已经被泛化了。长杆菌nunit已被task_runner取代。Albacore msbuild现在只是简单的“构建”。
发布于 2017-05-11 06:14:57
也可以通过将require向下移到需要它的任务中来解决冲突,因此:
require "albacore"
task :default do
...
end
task :some_winrm_task do
require "winrm"
...
endhttps://stackoverflow.com/questions/22724803
复制相似问题