Skip to content

Commit

Permalink
Merge pull request #1509 from Homebrew/remove_lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
p-linnane authored Nov 27, 2024
2 parents 07b2612 + f92c362 commit 1419e23
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 332 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
.vscode

Brewfile
Brewfile.lock.json
Gemfile.lock
coverage
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ vscode "GitHub.codespaces"
Homebrew is a [rolling release](https://en.wikipedia.org/wiki/Rolling_release) package manager so it does not support installing arbitrary older versions of software.
If your software needs specific pinned versions, consider [`whalebrew`](https://github.com/whalebrew/whalebrew) lines in your `Brewfile` to install [Docker](https://www.docker.com) containers.

After a successful `brew bundle` run, it creates a `Brewfile.lock.json` to record the environment. If a future `brew bundle` run fails, you can check the differences between `Brewfile.lock.json` to debug. As it can contain local environment information that varies between systems, it's not worth committing to version control on multi-user repositories.

Disable generation of the `Brewfile.lock.json` file by setting the environment variable with `export HOMEBREW_BUNDLE_NO_LOCK=1` or by using the command-line argument `brew bundle --no-lock`.

## New Installers/Checkers/Dumpers

`brew bundle` currently supports Homebrew, Homebrew Cask, Mac App Store, Whalebrew and Visual Studio Code.
Expand Down
5 changes: 2 additions & 3 deletions cmd/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class BundleCmd < AbstractCommand
You can skip the installation of dependencies by adding space-separated values to one or more of the following environment variables: `HOMEBREW_BUNDLE_BREW_SKIP`, `HOMEBREW_BUNDLE_CASK_SKIP`, `HOMEBREW_BUNDLE_MAS_SKIP`, `HOMEBREW_BUNDLE_WHALEBREW_SKIP`, `HOMEBREW_BUNDLE_TAP_SKIP`.
`brew bundle` will output a `Brewfile.lock.json` in the same directory as the `Brewfile` if all dependencies are installed successfully. This contains dependency and system status information which can be useful for debugging `brew bundle` failures and replicating a "last known good build" state. You can opt-out of this behaviour by setting the `HOMEBREW_BUNDLE_NO_LOCK` environment variable or passing the `--no-lock` option. You may wish to check this file into the same version control system as your `Brewfile` (or ensure your version control system ignores it if you'd prefer to rely on debugging information from a local machine).
`brew bundle dump`:
Write all installed casks/formulae/images/taps into a `Brewfile` in the current directory.
Expand Down Expand Up @@ -76,7 +74,8 @@ class BundleCmd < AbstractCommand
"This is enabled by default if `HOMEBREW_BUNDLE_INSTALL_CLEANUP` is set and " \
"`--global` is passed."
switch "--no-lock",
description: "`install` does not output a `Brewfile.lock.json`."
description: "no-op since `Brewfile.lock.json` was removed.",
hidden: true
switch "--all",
description: "`list` all dependencies."
switch "--formula", "--brews",
Expand Down
1 change: 0 additions & 1 deletion lib/bundle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
require "bundle/dumper"
require "bundle/installer"
require "bundle/lister"
require "bundle/locker"
require "bundle/commands/install"
require "bundle/commands/dump"
require "bundle/commands/cleanup"
Expand Down
8 changes: 0 additions & 8 deletions lib/bundle/cask_dumper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ def cask_is_outdated_using_greedy?(cask_name)
cask.outdated?(greedy: true)
end

def cask_versions
return {} unless Bundle.cask_installed?

casks.each_with_object({}) do |cask, name_versions|
name_versions[cask.to_s] = cask.version
end
end

def dump(describe: false)
casks.map do |cask|
description = "# #{cask.desc}\n" if describe && cask.desc.present?
Expand Down
5 changes: 0 additions & 5 deletions lib/bundle/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,9 @@ def install(entries, global: false, file: nil, no_lock: false, no_upgrade: false
unless failure.zero?
puts Formatter.error "Homebrew Bundle failed! " \
"#{failure} Brewfile #{Bundle::Dsl.pluralize_dependency(failure)} failed to install."
if (lock = Bundle::Locker.lockfile(global:, file:)) && lock.exist?
puts Formatter.error("Check for differences in your #{lock.basename}!")
end
return false
end

Bundle::Locker.lock(entries, global:, file:, no_lock:)

puts Formatter.success "Homebrew Bundle complete! " \
"#{success} Brewfile #{Bundle::Dsl.pluralize_dependency(success)} now installed."
true
Expand Down
171 changes: 0 additions & 171 deletions lib/bundle/locker.rb

This file was deleted.

2 changes: 0 additions & 2 deletions spec/bundle/commands/install_command_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
describe Bundle::Commands::Install do
before do
allow_any_instance_of(IO).to receive(:puts)
allow(Bundle::Locker).to receive(:write_lockfile?).and_return(false)
end

context "when a Brewfile is not found" do
Expand Down Expand Up @@ -66,7 +65,6 @@
allow(Bundle::TapInstaller).to receive_messages(preinstall: true, install: false)
allow(Bundle::WhalebrewInstaller).to receive_messages(preinstall: true, install: false)
allow(Bundle::VscodeExtensionInstaller).to receive_messages(preinstall: true, install: false)
allow(Bundle::Locker).to receive(:lockfile).and_return(Pathname(__dir__))
allow_any_instance_of(Pathname).to receive(:read).and_return(brewfile_contents)

expect { described_class.run }.to raise_error(SystemExit)
Expand Down
Loading

0 comments on commit 1419e23

Please sign in to comment.