Unpacking an archive using archive_file fails with NameError: uninitialized constant Chef::Resource::ArchiveFile::Archive.
15.9.17. Also reproducible in 16.0.216. Not reproducible in 15.8.23.
platform=ubuntu
platform_version=18.04
Create a recipe:
user 'my_service' do
home '/opt/my_service'
shell '/bin/bash'
system true
manage_home true
action :create
end
group 'my_service' do
members 'my_service'
system true
append true
action :create
end
archive_file '/home/ubuntu/archive.zip' do
destination '/opt/my_service'
owner 'my_service'
group 'my_service'
end
archive.zip is attached.
Run the recipe with chef-solo -c solo.rb -o 'recipe[demo]' (solo.rb contains only cookbook_path '/home/ubuntu/cookbooks') .
Starting Chef Infra Client, version 15.9.17
[2020-04-17T06:34:25+00:00] WARN: Run List override has been provided.
[2020-04-17T06:34:25+00:00] WARN: Original Run List: []
[2020-04-17T06:34:25+00:00] WARN: Overridden Run List: [recipe[demo]]
resolving cookbooks for run list: ["demo"]
Synchronizing Cookbooks:
- demo (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Converging 3 resources
Recipe: demo::default
* linux_user[my_service] action create
- create user my_service
* group[my_service] action create
- alter group my_service
- add missing member(s): my_service
* archive_file[/home/ubuntu/archive.zip] action extract
================================================================================
Error executing action `extract` on resource 'archive_file[/home/ubuntu/archive.zip]'
================================================================================
NameError
---------
uninitialized constant Chef::Resource::ArchiveFile::Archive
Resource Declaration:
---------------------
# In /home/ubuntu/local-mode-cache/cache/cookbooks/demo/recipes/default.rb
16: archive_file '/home/ubuntu/archive.zip' do
17: destination '/opt/my_service'
18: owner 'my_service'
19: group 'my_service'
20: end
Compiled Resource:
------------------
# Declared in /home/ubuntu/local-mode-cache/cache/cookbooks/demo/recipes/default.rb:16:in `from_file'
archive_file("/home/ubuntu/archive.zip") do
action [:extract]
default_guard_interpreter :default
declared_type :archive_file
cookbook_name "demo"
recipe_name "default"
destination "/opt/my_service"
owner "my_service"
group "my_service"
path "/home/ubuntu/archive.zip"
options [:time]
end
System Info:
------------
chef_version=15.9.17
platform=ubuntu
platform_version=18.04
ruby=ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
program_name=/usr/bin/chef-solo
executable=/opt/chef/bin/chef-solo
Running handlers:
[2020-04-17T06:34:25+00:00] ERROR: Running exception handlers
Running handlers complete
[2020-04-17T06:34:25+00:00] ERROR: Exception handlers complete
Chef Infra Client failed. 2 resources updated in 01 seconds
[2020-04-17T06:34:25+00:00] FATAL: Stacktrace dumped to /home/ubuntu/local-mode-cache/cache/chef-stacktrace.out
[2020-04-17T06:34:25+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2020-04-17T06:34:25+00:00] FATAL: NameError: archive_file[/home/ubuntu/archive.zip] (demo::default line 16) had an error: NameError: uninitialized constant Chef::Resource::ArchiveFile::Archive
Also hitting this bug
Fun story I did require "ffi-libarchive" unless defined?(Archive) in my recipe in an attempt to work around this, and surprisingly got:
Unrecognized archive format
I need to shuffle the requires around a bit to make this one work. It was breaking our specs if I added the require to the base of the resource. Fix incoming.
https://github.com/chef-boneyard/libarchive/issues/44 is kinda related 馃
This is something I wrote on my whiteboard for after Chef 16 / Workstation 20.6 / ChefDk 4.8 was done. Give me some time to clean this up.
@hammerhead This should be fixed with https://github.com/chef/chef/pull/9951
Awesome, thank you @tas50!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Fun story I did
require "ffi-libarchive" unless defined?(Archive)in my recipe in an attempt to work around this, and surprisingly got: