Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.34k stars 9.72k forks source link

`brew install --cask docker` fails after having done `brew install docker` #16309

Open rikhuijzer opened 11 months ago

rikhuijzer commented 11 months ago

brew doctor output

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Putting non-prefixed coreutils in your path can cause GMP builds to fail.

Verification

brew config output

HOMEBREW_VERSION: 4.1.24
ORIGIN: https://github.com/Homebrew/brew
HEAD: ab6a7ed5a122b6d4f9d441ef76c86032398ced5f
Last commit: 4 days ago
Core tap JSON: 09 Dec 16:23 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 12
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: dodeca-core 64-bit arm_blizzard_avalanche
Clang: 15.0.0 build 1500
Git: 2.39.3 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.1.2 => /usr/bin/curl
macOS: 14.1.2-arm64
CLT: 15.0.0.0.1.1694021235
Xcode: N/A
Rosetta 2: false

What were you trying to do (and why)?

I was trying to install Docker via brew in order to run Docker. With that I mean that I wanted to have Docker and the Docker engine.

What happened (include all command output)?

$ brew install --cask docker
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/bed4da7666c34f984e83c3009a4d59a1bc68fb05/Casks/d/docker.rb
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/ca29cc57571796f0b169705d4b13c4336527c673e367a147ceb2a84cd188d346--docker.rb
==> Downloading https://desktop.docker.com/mac/main/arm64/130397/Docker.dmg
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/3fdd94dfca3d2383bd05a81c21a9500993d3f3e676e9f6f0f6e2aeade5bc0579--Docker.dmg
==> Installing Cask docker
==> Moving App 'Docker.app' to '/Applications/Docker.app'
==> Linking Binary 'docker' to '/usr/local/bin/docker'
==> Linking Binary 'docker-compose' to '/usr/local/bin/docker-compose'
==> Linking Binary 'docker-credential-desktop' to '/usr/local/bin/docker-credential-desktop'
==> Linking Binary 'docker-credential-ecr-login' to '/usr/local/bin/docker-credential-ecr-login'
==> Linking Binary 'docker-credential-osxkeychain' to '/usr/local/bin/docker-credential-osxkeychain'
==> Linking Binary 'docker-index' to '/usr/local/bin/docker-index'
==> Linking Binary 'kubectl' to '/usr/local/bin/kubectl.docker'
==> Unlinking Binary '/usr/local/bin/kubectl.docker'
==> Unlinking Binary '/usr/local/bin/docker-index'
==> Unlinking Binary '/usr/local/bin/docker-credential-osxkeychain'
==> Unlinking Binary '/usr/local/bin/docker-credential-ecr-login'
==> Unlinking Binary '/usr/local/bin/docker-credential-desktop'
==> Unlinking Binary '/usr/local/bin/docker-compose'
==> Unlinking Binary '/usr/local/bin/docker'
==> Backing App 'Docker.app' up to '/opt/homebrew/Caskroom/docker/4.26.0,130397/Docker.app'
==> Removing App '/Applications/Docker.app'
==> Purging files for version 4.26.0,130397 of Cask docker
Error: It seems there is already a Binary at '/opt/homebrew/etc/bash_completion.d/docker'.

What did you expect to happen?

Successful installation of the Docker cask.

Step-by-step reproduction instructions (by running brew commands)

$ brew install docker

$ docker run hello-world

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

$ # Oops. Should have used cask.

$ brew install --cask docker
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/bed4da7666c34f984e83c3009a4d59a1bc68fb05/Casks/d/docker.rb
############################################################################################################################################################################################################## 100.0%
==> Downloading https://desktop.docker.com/mac/main/arm64/130397/Docker.dmg
############################################################################################################################################################################################################## 100.0%
==> Installing Cask docker
==> Moving App 'Docker.app' to '/Applications/Docker.app'
==> Linking Binary 'docker' to '/usr/local/bin/docker'
Password:
==> Linking Binary 'docker-compose' to '/usr/local/bin/docker-compose'
==> Linking Binary 'docker-credential-desktop' to '/usr/local/bin/docker-credential-desktop'
==> Linking Binary 'docker-credential-ecr-login' to '/usr/local/bin/docker-credential-ecr-login'
==> Linking Binary 'docker-credential-osxkeychain' to '/usr/local/bin/docker-credential-osxkeychain'
==> Linking Binary 'docker-index' to '/usr/local/bin/docker-index'
==> Linking Binary 'kubectl' to '/usr/local/bin/kubectl.docker'
==> Unlinking Binary '/usr/local/bin/kubectl.docker'
==> Unlinking Binary '/usr/local/bin/docker-index'
==> Unlinking Binary '/usr/local/bin/docker-credential-osxkeychain'
==> Unlinking Binary '/usr/local/bin/docker-credential-ecr-login'
==> Unlinking Binary '/usr/local/bin/docker-credential-desktop'
==> Unlinking Binary '/usr/local/bin/docker-compose'
==> Unlinking Binary '/usr/local/bin/docker'
==> Backing App 'Docker.app' up to '/opt/homebrew/Caskroom/docker/4.26.0,130397/Docker.app'
==> Removing App '/Applications/Docker.app'
==> Purging files for version 4.26.0,130397 of Cask docker
Error: It seems there is already a Binary at '/opt/homebrew/etc/bash_completion.d/docker'.

$ brew uninstall docker

Warning: Treating docker as a formula. For the cask, use homebrew/cask/docker

Uninstalling /opt/homebrew/Cellar/docker/24.0.7... (13 files, 31.8MB)

$ brew install --cask docker
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/bed4da7666c34f984e83c3009a4d59a1bc68fb05/Casks/d/docker.rb
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/ca29cc57571796f0b169705d4b13c4336527c673e367a147ceb2a84cd188d346--docker.rb
==> Downloading https://desktop.docker.com/mac/main/arm64/130397/Docker.dmg
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/3fdd94dfca3d2383bd05a81c21a9500993d3f3e676e9f6f0f6e2aeade5bc0579--Docker.dmg
==> Installing Cask docker
==> Moving App 'Docker.app' to '/Applications/Docker.app'
==> Linking Binary 'docker' to '/usr/local/bin/docker'
==> Linking Binary 'docker-compose' to '/usr/local/bin/docker-compose'
==> Linking Binary 'docker-credential-desktop' to '/usr/local/bin/docker-credential-desktop'
==> Linking Binary 'docker-credential-ecr-login' to '/usr/local/bin/docker-credential-ecr-login'
==> Linking Binary 'docker-credential-osxkeychain' to '/usr/local/bin/docker-credential-osxkeychain'
==> Linking Binary 'docker-index' to '/usr/local/bin/docker-index'
==> Linking Binary 'kubectl' to '/usr/local/bin/kubectl.docker'
==> Unlinking Binary '/usr/local/bin/kubectl.docker'
==> Unlinking Binary '/usr/local/bin/docker-index'
==> Unlinking Binary '/usr/local/bin/docker-credential-osxkeychain'
==> Unlinking Binary '/usr/local/bin/docker-credential-ecr-login'
==> Unlinking Binary '/usr/local/bin/docker-credential-desktop'
==> Unlinking Binary '/usr/local/bin/docker-compose'
==> Unlinking Binary '/usr/local/bin/docker'
==> Backing App 'Docker.app' up to '/opt/homebrew/Caskroom/docker/4.26.0,130397/Docker.app'
==> Removing App '/Applications/Docker.app'
==> Purging files for version 4.26.0,130397 of Cask docker
Error: It seems there is already a Binary at '/opt/homebrew/etc/bash_completion.d/docker'.

$ rm -rf /opt/homebrew/etc/bash_completion.d/docker

$ brew install --cask docker
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/bed4da7666c34f984e83c3009a4d59a1bc68fb05/Casks/d/docker.rb
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/ca29cc57571796f0b169705d4b13c4336527c673e367a147ceb2a84cd188d346--docker.rb
==> Downloading https://desktop.docker.com/mac/main/arm64/130397/Docker.dmg
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/3fdd94dfca3d2383bd05a81c21a9500993d3f3e676e9f6f0f6e2aeade5bc0579--Docker.dmg
==> Installing Cask docker
==> Moving App 'Docker.app' to '/Applications/Docker.app'
==> Linking Binary 'docker' to '/usr/local/bin/docker'
==> Linking Binary 'docker-compose' to '/usr/local/bin/docker-compose'
==> Linking Binary 'docker-credential-desktop' to '/usr/local/bin/docker-credential-desktop'
==> Linking Binary 'docker-credential-ecr-login' to '/usr/local/bin/docker-credential-ecr-login'
==> Linking Binary 'docker-credential-osxkeychain' to '/usr/local/bin/docker-credential-osxkeychain'
==> Linking Binary 'docker-index' to '/usr/local/bin/docker-index'
==> Linking Binary 'kubectl' to '/usr/local/bin/kubectl.docker'
==> Linking Binary 'docker.bash-completion' to '/opt/homebrew/etc/bash_completion.d/docker'
==> Unlinking Binary '/opt/homebrew/etc/bash_completion.d/docker'
==> Unlinking Binary '/usr/local/bin/kubectl.docker'
==> Unlinking Binary '/usr/local/bin/docker-index'
==> Unlinking Binary '/usr/local/bin/docker-credential-osxkeychain'
==> Unlinking Binary '/usr/local/bin/docker-credential-ecr-login'
==> Unlinking Binary '/usr/local/bin/docker-credential-desktop'
==> Unlinking Binary '/usr/local/bin/docker-compose'
==> Unlinking Binary '/usr/local/bin/docker'
==> Backing App 'Docker.app' up to '/opt/homebrew/Caskroom/docker/4.26.0,130397/Docker.app'
==> Removing App '/Applications/Docker.app'
==> Purging files for version 4.26.0,130397 of Cask docker
Error: It seems there is already a Binary at '/opt/homebrew/share/zsh/site-functions/_docker'.

$ rm -rf /opt/homebrew/share/zsh/site-functions/_docker

$ brew install --cask docker
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/bed4da7666c34f984e83c3009a4d59a1bc68fb05/Casks/d/docker.rb
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/ca29cc57571796f0b169705d4b13c4336527c673e367a147ceb2a84cd188d346--docker.rb
==> Downloading https://desktop.docker.com/mac/main/arm64/130397/Docker.dmg
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/3fdd94dfca3d2383bd05a81c21a9500993d3f3e676e9f6f0f6e2aeade5bc0579--Docker.dmg
==> Installing Cask docker
==> Moving App 'Docker.app' to '/Applications/Docker.app'
==> Linking Binary 'docker' to '/usr/local/bin/docker'
==> Linking Binary 'docker-compose' to '/usr/local/bin/docker-compose'
==> Linking Binary 'docker-credential-desktop' to '/usr/local/bin/docker-credential-desktop'
==> Linking Binary 'docker-credential-ecr-login' to '/usr/local/bin/docker-credential-ecr-login'
==> Linking Binary 'docker-credential-osxkeychain' to '/usr/local/bin/docker-credential-osxkeychain'
==> Linking Binary 'docker-index' to '/usr/local/bin/docker-index'
==> Linking Binary 'kubectl' to '/usr/local/bin/kubectl.docker'
==> Linking Binary 'docker.bash-completion' to '/opt/homebrew/etc/bash_completion.d/docker'
==> Linking Binary 'docker.zsh-completion' to '/opt/homebrew/share/zsh/site-functions/_docker'
==> Unlinking Binary '/opt/homebrew/share/zsh/site-functions/_docker'
==> Unlinking Binary '/opt/homebrew/etc/bash_completion.d/docker'
==> Unlinking Binary '/usr/local/bin/kubectl.docker'
==> Unlinking Binary '/usr/local/bin/docker-index'
==> Unlinking Binary '/usr/local/bin/docker-credential-osxkeychain'
==> Unlinking Binary '/usr/local/bin/docker-credential-ecr-login'
==> Unlinking Binary '/usr/local/bin/docker-credential-desktop'
==> Unlinking Binary '/usr/local/bin/docker-compose'
==> Unlinking Binary '/usr/local/bin/docker'
==> Backing App 'Docker.app' up to '/opt/homebrew/Caskroom/docker/4.26.0,130397/Docker.app'
==> Removing App '/Applications/Docker.app'
==> Purging files for version 4.26.0,130397 of Cask docker
Error: It seems there is already a Binary at '/opt/homebrew/share/fish/vendor_completions.d/docker.fish'.

$ rm -rf /opt/homebrew/share/fish/vendor_completions.d/docker.fish

$ brew install --cask docker
==> Downloading https://formulae.brew.sh/api/cask.jws.json
-=#=- #     #        #
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/bed4da7666c34f984e83c3009a4d59a1bc68fb05/Casks/d/docker.rb
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/ca29cc57571796f0b169705d4b13c4336527c673e367a147ceb2a84cd188d346--docker.rb
==> Downloading https://desktop.docker.com/mac/main/arm64/130397/Docker.dmg
Already downloaded: /Users/rik/Library/Caches/Homebrew/downloads/3fdd94dfca3d2383bd05a81c21a9500993d3f3e676e9f6f0f6e2aeade5bc0579--Docker.dmg
==> Installing Cask docker
==> Moving App 'Docker.app' to '/Applications/Docker.app'
==> Linking Binary 'docker' to '/usr/local/bin/docker'
Password:
==> Linking Binary 'docker-compose' to '/usr/local/bin/docker-compose'
==> Linking Binary 'docker-credential-desktop' to '/usr/local/bin/docker-credential-desktop'
==> Linking Binary 'docker-credential-ecr-login' to '/usr/local/bin/docker-credential-ecr-login'
==> Linking Binary 'docker-credential-osxkeychain' to '/usr/local/bin/docker-credential-osxkeychain'
==> Linking Binary 'docker-index' to '/usr/local/bin/docker-index'
==> Linking Binary 'kubectl' to '/usr/local/bin/kubectl.docker'
==> Linking Binary 'docker.bash-completion' to '/opt/homebrew/etc/bash_completion.d/docker'
==> Linking Binary 'docker.zsh-completion' to '/opt/homebrew/share/zsh/site-functions/_docker'
==> Linking Binary 'docker.fish-completion' to '/opt/homebrew/share/fish/vendor_completions.d/docker.fish'
==> Linking Binary 'hub-tool' to '/usr/local/bin/hub-tool'
==> Linking Binary 'com.docker.cli' to '/usr/local/bin/com.docker.cli'
🍺  docker was successfully installed!
giladAlboher commented 11 months ago

It seems like there were some lingering files from a previous installation of Docker that were causing conflicts during the reinstallation process. To resolve this issue, you successfully identified and removed these files.

MikeMcQuaid commented 11 months ago

This is a known issue that it's unclear how to be solved. There may already be a homebrew/cask issue for this CC @Homebrew/cask for help triaging.

Need to decide how best to handle this e.g. what symlinks to install/skip/etc.

cho-m commented 10 months ago

docker Formula has a dependency on docker-completion Formula, both of which conflict with docker Cask.

The failures are coming from docker-completion, which won't be removed until brew autoremove or manually uninstalling.


Would say this is related to https://github.com/Homebrew/homebrew-cask/issues/12822 as we do specify the conflict but it is only documentation (e.g. https://formulae.brew.sh/cask/docker#default) rather than providing a useful error when user tries following:

$ brew install docker
$ brew install --cask docker
MikeMcQuaid commented 10 months ago

providing a useful error

not sure whether this conversation should be here or there but: I don't think this should be an error at all. Instead, either the formula or cask should not be linked and the user warned.

cho-m commented 10 months ago

not sure whether this conversation should be here or there but: I don't think this should be an error at all. Instead, either the formula or cask should not be linked and the user warned.

Was basing this on how formulae are currently handled, e.g.

Error: Cannot install bash-completion because conflicting formulae are installed.
  bash-completion@2: because each are different versions of the same formula

Please `brew unlink bash-completion@2` before continuing.

Unlinking removes a formula's symlinks from /opt/homebrew. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side effects in the
resulting software.

EDIT: Though we may be handling the reverse situation for Cask-Formula conflict: https://github.com/Homebrew/brew/blob/dde0411e02d285e0dda42a450bcd4e9556b99464/Library/Homebrew/formula_installer.rb#L973-L982

MikeMcQuaid commented 10 months ago

Though we may be handling the reverse situation for Cask-Formula conflict:

Yeh, we should do something similar to that, I think, but expand the definitions so that they don't need to have the same name.

Was basing this on how formulae are currently handled, e.g.

I think this makes sense for formulae that are often mutually exclusive. For formula/cask combos when it seems many people often want both: it kinda sucks.

p-i- commented 6 months ago

Please someone do something to prevent users from doing brew install docker and then eventually realizing they needed brew install --cask docker. ~Absolutely nobody wants the former~. This will just trip up thousands of devs and waste their time, as it's a pretty reasonable thing to expect to work. (IIRC homebrew doesn't require the use of --cask any more).

SMillerDev commented 6 months ago

Please someone do something to prevent users from doing brew install docker and then eventually realizing they needed brew install --cask docker. Absolutely nobody wants the former.

I want the former since I'm using a different container runtime and a lot of tools hardcode the docker command.

carlocab commented 6 months ago

Please someone do something to prevent users from doing brew install docker and then eventually realizing they needed brew install --cask docker. Absolutely nobody wants the former.

I want the former since I'm using a different container runtime and a lot of tools hardcode the docker command.

Same here. The docker CLI is nice. I prefer using an open-source container runtime, however, and that's not what you get with the Docker cask.

p-i- commented 6 months ago

My bad.

But I suspect my main point still stands -- there's a sharp edge here that could maybe be smoothed over.

Usually brew install foo does the same as brew install --cask foo, right?

Is it possible for the Homebrew team to do something so that devs don't install the wrong thing by mistake and then have to dig out this issue to fix it?

Shouldn't the package be named docker-cli to make a clear disambiguation?

MikeMcQuaid commented 6 months ago

Usually brew install foo does the same as brew install --cask foo, right?

No. It's usually brew install --formula if there's two with the same name.

Shouldn't the package be named docker-cli to make a clear disambiguation?

No. The cask could be renamed if we want to go down that route. docker-desktop or something.

gibfahn commented 5 months ago

No. It's usually brew install --formula if there's two with the same name.

I know it's a breaking change, so maybe not feasible, but for me the ideal fix for this would be for brew were to error on ambiguous cask vs formula install commands. This is the way it works if a formula is available in multiple taps. That would force people to actually work out which one they wanted.

carlocab commented 5 months ago

I know it's a breaking change, so maybe not feasible, but for me the ideal fix for this would be for brew were to error on ambiguous cask vs formula install commands. This is the way it works if a formula is available in multiple taps. That would force people to actually work out which one they wanted.

Yea, this maybe should've been what we did from the beginning. But this will break too many things now to change, unfortunately.

MikeMcQuaid commented 5 months ago

It could be optional behaviour, though. I can see people (perhaps myself included) enabling that.

Alternatively, it is something we could consider just warning and later deprecating/erroring on.

MikeMcQuaid commented 5 months ago

No. The cask could be renamed if we want to go down that route. docker-desktop or something.

This is still my favoured option, though; at least in homebrew/core and homebrew/cask we should just avoid overlapping names like we do.

gibfahn commented 5 months ago

Alternatively, it is something we could consider just warning and later deprecating/erroring on.

Yeah a "there is also a cask for this, if you wanted that cancel this install and do brew install --cask docker" style warning would probably help a lot of folks.

blacknred0 commented 1 month ago

ty! my docker broke after upgrading to Sequoia (v15.0). I can confirm that after applying all of those rm -f /path/to/file and then brew reinstall --cask docker that docker is back to normal.

Austin1 commented 1 day ago

I've tried everything to get it to work.

  1. I made the mistake of brew install docker first, then tried many times to get the cask to work
  2. I manually deleted all the docker binaries in /usr/local/bin/docker* and attempted brew autoremove started getting this error:

    It seems there is already a Binary at '/usr/local/bin/hub-tool'.
    1. So I ran an uninstall script
      curl -L -O https://raw.githubusercontent.com/docker-archive/toolbox/refs/heads/master/osx/uninstall.sh; sudo bash uninstall.sh
    2. No dice. If I brew list; there is no docker CLI, no docker formula or casks installed

    I'm sure I can manualyl install from the docker website but at this point I want to know why I can't get brew to work

gromgit commented 1 day ago

Try brew install --cask --force docker.