Berksfile.lock ignored?

1k Views Asked by At

I have the following Berksfile in my app/ directory:

source "https://supermarket.chef.io"
cookbook "apt", "~> 3.0.0"
cookbook "nodejs", "~> 2.2"

When I run berks install (version 4.3.3), I get:

Resolving cookbook dependencies...
Fetching cookbook index from https://supermarket.chef.io...
Using apt (3.0.0)
...

My app directory contains a Berksfile.lock that contains the following line

apt (3.0.0)

In my initial Berksfile I remove the cookbook apt line (line 2). I expect berks to use my Berksfile.lock. But instead, when I run berks install again I get:

Resolving cookbook dependencies...
Fetching cookbook index from https://supermarket.chef.io...
Using apt (4.0.0)

And my Berksfile.lock gets updated with the new apt version. Is this the expected behaviour? I would expect this behaviour with the berks update command...

2

There are 2 best solutions below

0
On

Do not specify version constraints in the Berksfile, but use metadata.rb instead. This also ensures that the correct version is used when running chef-client.

1
On

Because you have removed the version constraint Berks will now locate and use the newest available version that will satisfy all of the version requirements specified by the cookbooks it manages. Apparently in your case apt version 4.0 satisfies all of your third party dependency version requirements.