13

According to "berks help update", the command is supposed to:

"Update the cookbooks (and dependencies) specified in the Berksfile"

(Yes ... that's all it says!).

But what exactly does this mean?

And how does this vary with different kinds of "cookbook" specification in your Berksfile?

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216

1 Answers1

14

The update command will attempt to find the newest versions of each cookbook (that still meet any version requirements you've defined). For example, suppose you have the following Berksfile:

cookbook 'foo', '~> 1.0.0'

This tells Berkshelf to accept any version in the 1.0.x series. So you run berks install and (hypothetically) foo-1.0.5 is installed into your local berkshelf. The lockfile will "lock" the definition for foo at version 1.0.5, so other developers and future installs will always use version 1.0.5 (that's the entire point of the lockfile).

(A few months pass by...)

Now you want to update the cookbook to the latest version. But because of SemVer, you want to remain in the 1.0.x series. Running berks update will unlock the hard dependency in the lockfile, but keep the constraint in the Berksfile. So (hypothetically), if the community site had the following foo cookbook versions:

  • 1.0.5
  • 1.0.6
  • 1.0.8
  • 1.1.0
  • 2.0.0

berks update would update your local version to 1.0.8, since that's the latest published version that still satisfies your constraint.

sethvargo
  • 26,739
  • 10
  • 86
  • 156
  • Does it put a copy of cookbooks inside the VM too? – Seperman Jan 14 '14 at 02:37
  • 1
    What VM? I don't see where you've mentioned a VM anywhere? – sethvargo Jan 14 '14 at 19:00
  • I was curious if `berks update` does anything inside the Vagrant Box too like copying the cookbooks to the VM like in /etc/chef/. After doing more research I found that it does not do that. But I'm still curious where chef-solo finds the cookbooks. – Seperman Jan 15 '14 at 00:05
  • 1
    @Erasmose - I didn't ask about berkshelf behaviour in the context of vagrant. If you are curious about that, feel free to ask a new Question. – Stephen C Jan 15 '14 at 05:43
  • 1
    You'll need to use something like vagrant-berkshelf. – sethvargo Jan 15 '14 at 15:59
  • I ran `berks update nginx` and to my surprise its dependencies all updated too (`apt`, `build-essential`,`runit` and `yum`). This isn't a problem but I was curious so I tried reverting Berkshelf.lock and using `berks update --only=nginx` but this does nothing. Is there a better explanation of `--only` somewhere? – KCD Apr 09 '15 at 04:45