nathwill / chef-systemd

resource-driven chef cookbook for managing linux systems via systemd
Apache License 2.0
44 stars 33 forks source link

3.0.0 - cannot load such file -- dbus/systemd/machined #105

Closed grogancolin closed 7 years ago

grogancolin commented 7 years ago

Since updating to 3.0.0 - we've had some cookbooks fail to run with:

Failure/Error: let(:chef_run) { solo_runner(platform, version).converge(described_recipe) }

     LoadError:
        cannot load such file -- dbus/systemd/machined
nathwill commented 7 years ago

hmmm, so this cookbook uses the 'gem' method in the metadata to install the dbus-systemd gem, which seems to be the issue here. i'm guessing you're using an older version of chef? i believe this should be resolvable by doing a compile-time installation with a chef_gem resource for dbus-systemd, or upgrading to a chef version that supports the gem method during the metadata parsing.

let me know if i can be of further assistance.

nathwill commented 7 years ago

i'm updating our metadata to specify that we require a chef_version >= 12.8.1, which is when the gem metadata support was added to chef core

mpires commented 7 years ago

Weird, I'm getting the same issue running with Chef 13.2.20, with systemd 3.0.1

googlecompute: cannot load such file -- dbus/systemd/machined
    googlecompute:
    googlecompute: Cookbook Trace:
    googlecompute: ---------------
    googlecompute: /var/chef/cache/cookbooks/systemd/resources/machine.rb:1:in `class_from_file'
    googlecompute:
    googlecompute: Relevant File Content:
    googlecompute: ----------------------
    googlecompute: /var/chef/cache/cookbooks/systemd/resources/machine.rb:
    googlecompute:
    googlecompute: 1>> require 'dbus/systemd/machined'
nathwill commented 7 years ago

@mpires how have you installed chef? if omnibus, can you share the gem list? (/opt/chef/embedded/bin/gem list | grep systemd). trying to find a reproduction case here

mpires commented 7 years ago

Hi @nathwill that command yields no results. I have to apologize for this false positive, this is most definitely due to my own private servers not having the dbus-systemd available. You can close it, sorry again.

nathwill commented 7 years ago

no worries at all. fwiw, my understanding is that if you are using a new chef version, chef is supposed to automatically install the gem during the compile phase of a chef run since the metadata for this cookbook specifies dbus-systemd as a requirement. that seems to be born out by the integration testing, so i'm not really sure why it wouldn't be happening for you.

of course, if you're trying to require the gem outside of a chef run, that wouldn't happen, so maybe that's where the issue lies? lmk if i can be of further assistance.

Annih commented 7 years ago

Hello @nathwill

The reported bug seems to be related to a ChefSpec environment. I also encountered the same kind of issue. Chefspec is not handling properly the Gem dependencies defined in cookbook's metadata (chefspec/chefspec#871)

But I think we could find a solution to reduce the impact from the chef-systemd cookbooks.

I'll open a PR.