# Howto read cookbook version info from metadata.rb in recipe by runtime on a node

**URL:** <https://discourse.chef.io/t/howto-read-cookbook-version-info-from-metadata-rb-in-recipe-by-runtime-on-a-node/3240>\
**Category:** Chef Infra (archive)\
**Created:** [October 29, 2012, 2:17pm UTC](https://discourse.chef.io/t/howto-read-cookbook-version-info-from-metadata-rb-in-recipe-by-runtime-on-a-node/3240 "2012-10-29T14:17:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oleg\_Volotov](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@Oleg\_Volotov](https://discourse.chef.io/u/Oleg_Volotov)\
**Post date:** [October 29, 2012, 2:17pm UTC](https://discourse.chef.io/t/howto-read-cookbook-version-info-from-metadata-rb-in-recipe-by-runtime-on-a-node/3240/1 "2012-10-29T14:17:17Z")

</div>

Hi, is there a way to use the ‘version’ info from the metadata of a cookbook in a recipe?

mfg  
oleg

---

<div class="post-metadata">

**Author:** ![Mike](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/mike/32/18_2.png) [@Mike](https://discourse.chef.io/u/Mike)\
**Post date:** [October 29, 2012, 2:32pm UTC](https://discourse.chef.io/t/howto-read-cookbook-version-info-from-metadata-rb-in-recipe-by-runtime-on-a-node/3240/2 "2012-10-29T14:32:35Z")

</div>

Oleg,

You might be looking for this:  
[http://wiki.opscode.com/display/chef/Environments#Environments-cookbookversions](http://wiki.opscode.com/display/chef/Environments#Environments-cookbookversions)

-Mike

On Mon, Oct 29, 2012 at 10:17 AM, [oleg.volotov@gmx.de](mailto:oleg.volotov@gmx.de) wrote:

> Hi, is there a way to use the 'version' info from the metadata of a cookbook in a recipe?
> 
> mfg  
> oleg

---

<div class="post-metadata">

**Author:** ![Andrea\_Campi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/andrea_campi/32/514_2.png) [@Andrea\_Campi](https://discourse.chef.io/u/Andrea_Campi)\
**Post date:** [October 29, 2012, 3:30pm UTC](https://discourse.chef.io/t/howto-read-cookbook-version-info-from-metadata-rb-in-recipe-by-runtime-on-a-node/3240/3 "2012-10-29T15:30:22Z")

</div>

On Mon, Oct 29, 2012 at 3:32 PM, Mike [miketheman@gmail.com](mailto:miketheman@gmail.com) wrote:

> Oleg,
> 
> You might be looking for this:
> 
> [http://wiki.opscode.com/display/chef/Environments#Environments-cookbookversions](http://wiki.opscode.com/display/chef/Environments#Environments-cookbookversions)

Mike: I don't think that's what he's asking for…

Oleg: try

run\_context.cookbook\_collection[cookbook].metadata.version

---

<div class="post-metadata">

**Author:** ![Oleg\_Volotov](https://avatars.discourse-cdn.com/v4/letter/o/edb3f5/32.png) [@Oleg\_Volotov](https://discourse.chef.io/u/Oleg_Volotov)\
**Post date:** [October 30, 2012, 7:22am UTC](https://discourse.chef.io/t/howto-read-cookbook-version-info-from-metadata-rb-in-recipe-by-runtime-on-a-node/3240/4 "2012-10-30T07:22:57Z")

</div>

THATS IT!!, thanks.

e.g. run\_context.cookbook\_collection["mycookbook"].metadata.version

I've been looking the libs on GitHub ([https://github.com/opscode/chef/tree/master/chef/lib/chef](https://github.com/opscode/chef/tree/master/chef/lib/chef)) and there I found the cookbook\_collection already. But I dont know how to get the reference of it.

Therefore I wanted to ask, is there a page or pages on which you can read exactly how chef works, so that when class is loaded or something like that?

Also a page for a view from programmers?

mfg  
oleg

-------- Original-Nachricht --------

> Datum: Mon, 29 Oct 2012 16:30:22 +0100  
> Von: Andrea Campi [andrea.campi@zephirworks.com](mailto:andrea.campi@zephirworks.com)  
> An: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> Betreff: [chef] Re: Re: Howto read cookbook version info from metadata.rb in recipe by runtime on a node

> On Mon, Oct 29, 2012 at 3:32 PM, Mike [miketheman@gmail.com](mailto:miketheman@gmail.com) wrote:
> 
> > Oleg,
> > 
> > You might be looking for this:
> 
> [http://wiki.opscode.com/display/chef/Environments#Environments-cookbookversions](http://wiki.opscode.com/display/chef/Environments#Environments-cookbookversions)
> 
> > 
> 
> Mike: I don't think that's what he's asking for…
> 
> Oleg: try
> 
> run\_context.cookbook\_collection[cookbook].metadata.version
