# Library load ordering

**URL:** <https://discourse.chef.io/t/library-load-ordering/5400>\
**Category:** Chef Infra (archive)\
**Created:** [June 11, 2014, 10:40pm UTC](https://discourse.chef.io/t/library-load-ordering/5400 "2014-06-11T22:40:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Fischer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/michael_fischer/32/136_2.png) [@Michael\_Fischer](https://discourse.chef.io/u/Michael_Fischer)\
**Post date:** [June 11, 2014, 10:40pm UTC](https://discourse.chef.io/t/library-load-ordering/5400/1 "2014-06-11T22:40:01Z")

</div>

What’s the correct way to ensure that a library in cookbook A can reliably  
refer to a method in a module declared in a library in cookbook B?

Is declaring the dependency on cookbook B in cookbook A’s metadata  
sufficent? (It seems not.)

We’re experiencing load-ordering race conditions and I’d like to figure out  
how to quash them once and for all.

Thanks,

–Michael

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [June 11, 2014, 10:41pm UTC](https://discourse.chef.io/t/library-load-ordering/5400/2 "2014-06-11T22:41:20Z")

</div>

On Wednesday, June 11, 2014 at 3:40 PM, Michael Fischer wrote:

> What's the correct way to ensure that a library in cookbook A can reliably refer to a method in a module declared in a library in cookbook B?
> 
> Is declaring the dependency on cookbook B in cookbook A's metadata sufficent? (It seems not.)  
> This should be sufficient, provided you’re on Chef 11.x and you do not have a circular dependency.

> We're experiencing load-ordering race conditions and I'd like to figure out how to quash them once and for all.
> 
> Thanks,
> 
> --Michael  
> --  
> Daniel DeLeo

---

<div class="post-metadata">

**Author:** ![Michael\_Fischer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/michael_fischer/32/136_2.png) [@Michael\_Fischer](https://discourse.chef.io/u/Michael_Fischer)\
**Post date:** [June 11, 2014, 10:47pm UTC](https://discourse.chef.io/t/library-load-ordering/5400/3 "2014-06-11T22:47:36Z")

</div>

On Wed, Jun 11, 2014 at 3:41 PM, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:

> On Wednesday, June 11, 2014 at 3:40 PM, Michael Fischer wrote:
> 
> > What's the correct way to ensure that a library in cookbook A can  
> > reliably refer to a method in a module declared in a library in cookbook B?
> > 
> > Is declaring the dependency on cookbook B in cookbook A's metadata  
> > sufficent? (It seems not.)  
> > This should be sufficient, provided you’re on Chef 11.x and you do not  
> > have a circular dependency.

Good catch on the circular dependency; thanks.

--Michael

---

<div class="post-metadata">

**Author:** ![Morgan\_Blackthorne](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/morgan_blackthorne/32/100_2.png) [@Morgan\_Blackthorne](https://discourse.chef.io/u/Morgan_Blackthorne)\
**Post date:** [June 11, 2014, 11:02pm UTC](https://discourse.chef.io/t/library-load-ordering/5400/4 "2014-06-11T23:02:04Z")

</div>

Speaking of circular dependencies, I ran into a few of those (error on my  
part due to a misleading Foodcritic warning) and was wondering if there was  
a tool that would catch them along the lines of rubocop/foodcritic.

--  
~_~ StormeRider ~_~

"Every world needs its heroes [...] They inspire us to be better than we  
are. And they protect from the darkness that's just around the corner."

(from Smallville Season 6x1: "Zod")

On why I hate the phrase "that's so lame"... [http://bit.ly/Ps3uSS](http://bit.ly/Ps3uSS)

On Wed, Jun 11, 2014 at 3:47 PM, Michael Fischer [mfischer@zendesk.com](mailto:mfischer@zendesk.com)  
wrote:

> On Wed, Jun 11, 2014 at 3:41 PM, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:
> 
> > On Wednesday, June 11, 2014 at 3:40 PM, Michael Fischer wrote:
> > 
> > > What's the correct way to ensure that a library in cookbook A can  
> > > reliably refer to a method in a module declared in a library in cookbook B?
> > > 
> > > Is declaring the dependency on cookbook B in cookbook A's metadata  
> > > sufficent? (It seems not.)  
> > > This should be sufficient, provided you’re on Chef 11.x and you do not  
> > > have a circular dependency.
> 
> Good catch on the circular dependency; thanks.
> 
> --Michael
