What exactly does "berks update <cookbook-name>" do?
Asked Answered
S

1

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?

Suzysuzzy answered 10/1, 2014 at 1:29 Comment(0)
O
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.

Ory answered 13/1, 2014 at 17:16 Comment(6)
Does it put a copy of cookbooks inside the VM too?Rameriz
What VM? I don't see where you've mentioned a VM anywhere?Ory
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.Rameriz
@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.Suzysuzzy
You'll need to use something like vagrant-berkshelf.Ory
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?Amund

© 2022 - 2024 — McMap. All rights reserved.