Chef Exec Rspec错误:引发ArgumentError(示例中的错误)

时间:2018-06-06 15:10:45

标签: ruby unit-testing rspec chef octal

我最近收到了这个错误,因为我正在尝试用“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个例子)。当我在我过去做的任何其他烹饪书上运行厨师执行时,我没有这个问题。我注意到它正在将问题追溯到我的Mac上的chefdk,但我已经到处研究过这个问题并且找不到任何内容,我不确定这个错误试图告诉我什么。我是厨师的新手,所以如果有人能指导我正确的方向或告诉我这个错误可能意味着什么,那将是一个良好的开端。

我注意到的一个模式是我遇到过这个问题的2本烹饪书,是用https而不是ssh克隆的。我不知道这与它有什么关系,或者纯粹是巧合。

我也注意到每当我在cookbook的spec文件中注释掉“require spec helper”时,这个错误就会消失,并开始识别spec文件中写入的单元测试。但这样做并不是一个长期的解决方案,我不确定它是否正确地测试了这些例子。

我还将Mac上的ruby更新为2.4.1

2 个答案:

答案 0 :(得分:1)

这与rspec甚至是chefspec无关,但是在rubygems 2.7.6中有一个补丁,它破坏了berkshelf并且已经在mixlib-archive中解决了:

https://github.com/berkshelf/berkshelf/issues/1744

答案 1 :(得分:0)

更新:我正在运行ChefDK 2.5.3并更新到3.0.36,问题就消失了。我不知道是否存在兼容性问题,或者文件是否搞砸了,并且全新安装解决了这个问题。