Chef Exec Rspec Error: raise ArgumentError (Error outside examples)
Chef Exec Rspec Error: raise ArgumentError (Error outside examples)
最近我尝试使用 "chef exec rspec" 测试的几本食谱时遇到此错误:
An error occurred in a `before(:suite)` hook.
Failure/Error: raise ArgumentError, "#{str.inspect} is not an octal string"
ArgumentError:
"\x80\x00\x00\x00\e\xC4dx" is not an octal string
# /opt/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_header.rb:128:in `strict_oct'
# /opt/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_header.rb:108:in `from'
# /opt/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_reader.rb:59:in `each'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive/tar.rb:27:in `block in extract'
# /opt/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_reader.rb:29:in `new'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive/tar.rb:118:in `reader'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive/tar.rb:25:in `extract'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive.rb:33:in `extract'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/community_rest.rb:16:in `unpack'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/community_rest.rb:102:in `download'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:70:in `try_download'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:40:in `block in download'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:39:in `each'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:39:in `download'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/installer.rb:108:in `install'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/installer.rb:181:in `block (2 levels) in install_from_universe'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `block in synchronize'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/safe_task_executor.rb:19:in `execute'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/ivar.rb:170:in `safe_execute'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/future.rb:52:in `block in execute'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'
#
# Showing full backtrace because every line was filtered out.
# See docs for RSpec::Configuration#backtrace_exclusion_patterns and
# RSpec::Configuration#backtrace_inclusion_patterns for more information.
Finished in 1.36 seconds (files took 7.16 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
这也会阻止它识别任何编写的单元测试(如您所见,它识别了 0 个示例)。当我 运行 chef exec rspec 在我过去做过的任何其他食谱上时,我没有这个问题。我注意到它正在将问题追溯到我的 Mac 上的 chefdk,但我已针对此问题到处进行了研究,但找不到任何相关信息,而且我不确定此错误试图告诉我什么。我是 Chef 的新手,所以如果有人能指导我正确的方向或告诉我这个错误可能意味着什么,那将是一个好的开始。
我注意到的一个模式是我遇到这个问题的 2 本食谱是通过 https 而不是 ssh 克隆的。我不知道这是否与它有关或纯属巧合。
我还注意到,每当我在说明书的规范文件中注释掉 "require spec helper" 时,此错误就会消失并开始识别规范文件中编写的单元测试。但这样做并不是一个长期的解决方案,我不确定它是否正确地测试了示例。
我也将 Mac 上的 ruby 更新为 2.4.1
更新:我是 运行 ChefDK 2.5.3 并更新到 3.0.36,问题消失了。我不知道是否存在兼容性问题,或者文件是否混乱,全新安装解决了问题。
这与 rspec 甚至 chefspec 无关,但与 rubygems 2.7.6 中的一个补丁有关,该补丁破坏了 berkshelf,并已在 mixlib-archive 中得到解决:
最近我尝试使用 "chef exec rspec" 测试的几本食谱时遇到此错误:
An error occurred in a `before(:suite)` hook.
Failure/Error: raise ArgumentError, "#{str.inspect} is not an octal string"
ArgumentError:
"\x80\x00\x00\x00\e\xC4dx" is not an octal string
# /opt/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_header.rb:128:in `strict_oct'
# /opt/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_header.rb:108:in `from'
# /opt/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_reader.rb:59:in `each'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive/tar.rb:27:in `block in extract'
# /opt/chefdk/embedded/lib/ruby/site_ruby/2.4.0/rubygems/package/tar_reader.rb:29:in `new'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive/tar.rb:118:in `reader'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive/tar.rb:25:in `extract'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/mixlib-archive-0.4.1/lib/mixlib/archive.rb:33:in `extract'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/community_rest.rb:16:in `unpack'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/community_rest.rb:102:in `download'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:70:in `try_download'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:40:in `block in download'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:39:in `each'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/downloader.rb:39:in `download'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/installer.rb:108:in `install'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/berkshelf-6.3.1/lib/berkshelf/installer.rb:181:in `block (2 levels) in install_from_universe'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `block in synchronize'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/synchronization/mri_lockable_object.rb:38:in `synchronize'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/safe_task_executor.rb:19:in `execute'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/ivar.rb:170:in `safe_execute'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/future.rb:52:in `block in execute'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
# /opt/chefdk/embedded/lib/ruby/gems/2.4.0/gems/concurrent-ruby-1.0.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'
#
# Showing full backtrace because every line was filtered out.
# See docs for RSpec::Configuration#backtrace_exclusion_patterns and
# RSpec::Configuration#backtrace_inclusion_patterns for more information.
Finished in 1.36 seconds (files took 7.16 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
这也会阻止它识别任何编写的单元测试(如您所见,它识别了 0 个示例)。当我 运行 chef exec rspec 在我过去做过的任何其他食谱上时,我没有这个问题。我注意到它正在将问题追溯到我的 Mac 上的 chefdk,但我已针对此问题到处进行了研究,但找不到任何相关信息,而且我不确定此错误试图告诉我什么。我是 Chef 的新手,所以如果有人能指导我正确的方向或告诉我这个错误可能意味着什么,那将是一个好的开始。
我注意到的一个模式是我遇到这个问题的 2 本食谱是通过 https 而不是 ssh 克隆的。我不知道这是否与它有关或纯属巧合。
我还注意到,每当我在说明书的规范文件中注释掉 "require spec helper" 时,此错误就会消失并开始识别规范文件中编写的单元测试。但这样做并不是一个长期的解决方案,我不确定它是否正确地测试了示例。
我也将 Mac 上的 ruby 更新为 2.4.1
更新:我是 运行 ChefDK 2.5.3 并更新到 3.0.36,问题消失了。我不知道是否存在兼容性问题,或者文件是否混乱,全新安装解决了问题。
这与 rspec 甚至 chefspec 无关,但与 rubygems 2.7.6 中的一个补丁有关,该补丁破坏了 berkshelf,并已在 mixlib-archive 中得到解决: