Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

archive_file fails with uninitialized constant Chef::Resource::ArchiveFile::Archive since 15.9.17 #9684

Closed
hammerhead opened this issue Apr 17, 2020 · 8 comments
Labels
Type: Bug Does not work as expected.

Comments

@hammerhead
Copy link

Description

Unpacking an archive using archive_file fails with NameError: uninitialized constant Chef::Resource::ArchiveFile::Archive.

Chef Version

15.9.17. Also reproducible in 16.0.216. Not reproducible in 15.8.23.

Platform Version

platform=ubuntu
platform_version=18.04

Replication Case

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') .

Client Output

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

Stacktrace

stacktrace.txt

@hammerhead hammerhead added the Status: Untriaged An issue that has yet to be triaged. label Apr 17, 2020
@tas50 tas50 added Type: Bug Does not work as expected. and removed Status: Untriaged An issue that has yet to be triaged. labels Apr 20, 2020
tas50 added a commit that referenced this issue Apr 21, 2020
tas50 added a commit that referenced this issue Apr 21, 2020
@jaymzh
Copy link
Collaborator

jaymzh commented May 8, 2020

Also hitting this bug

@jaymzh
Copy link
Collaborator

jaymzh commented May 8, 2020

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

@tas50
Copy link
Contributor

tas50 commented May 8, 2020

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.

@scalp42
Copy link

scalp42 commented Jun 3, 2020

chef-boneyard/libarchive#44 is kinda related 🤞

@tas50
Copy link
Contributor

tas50 commented Jun 3, 2020

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.

@tas50
Copy link
Contributor

tas50 commented Jun 4, 2020

@hammerhead This should be fixed with #9951

@tas50 tas50 closed this as completed Jun 4, 2020
@hammerhead
Copy link
Author

Awesome, thank you @tas50!

@lock
Copy link

lock bot commented Jun 24, 2020

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Bug Does not work as expected.
Projects
None yet
Development

No branches or pull requests

4 participants