Skip to content

Commit

Permalink
Merge pull request #14547 from Homebrew/revert-14412-homebrew_install…
Browse files Browse the repository at this point in the history
…_from_api_default

Revert "HOMEBREW_INSTALL_FROM_API: make the default for everyone."
  • Loading branch information
MikeMcQuaid authored Feb 7, 2023
2 parents e26784f + 1d0779a commit f4e6048
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 23 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ jobs:

- name: Run brew audit --skip-style on all taps
run: brew audit --eval-all --skip-style --except=version --display-failures-only
env:
HOMEBREW_NO_INSTALL_FROM_API: 1

- name: Set up all Homebrew taps
run: |
Expand All @@ -98,7 +96,6 @@ jobs:
brew tap homebrew/cask-fonts
brew tap homebrew/cask-versions
brew tap homebrew/command-not-found
brew tap homebrew/core
brew tap homebrew/formula-analytics
brew tap homebrew/portable-ruby
brew tap homebrew/services
Expand All @@ -112,7 +109,6 @@ jobs:
run: brew audit --skip-style --except=version --tap=homebrew/core
env:
HOMEBREW_SIMULATE_MACOS_ON_LINUX: 1
HOMEBREW_NO_INSTALL_FROM_API: 1

- name: Run brew style on official taps
run: |
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/brew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ auto-update() {

if [[ -z "${HOMEBREW_AUTO_UPDATE_SECS}" ]]
then
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]]
then
# 24 hours
HOMEBREW_AUTO_UPDATE_SECS="86400"
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/cmd/formulae.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ homebrew-formulae() {
# HOMEBREW_CACHE is set by brew.sh
# shellcheck disable=SC2154
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" &&
-n "${HOMEBREW_INSTALL_FROM_API}" &&
-f "${HOMEBREW_CACHE}/api/formula.json" ]]
then
local api_formulae
Expand Down
9 changes: 5 additions & 4 deletions Library/Homebrew/cmd/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ EOS
fi

if [[ -d "${HOMEBREW_CORE_REPOSITORY}" ]] ||
[[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
[[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]]
then
HOMEBREW_CORE_AVAILABLE="1"
fi
Expand Down Expand Up @@ -566,7 +566,8 @@ EOS

for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
do
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
[[ -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" || "${DIR}" == "${HOMEBREW_CASK_REPOSITORY}" ]]
then
continue
Expand Down Expand Up @@ -725,7 +726,7 @@ EOS

for DIR in "${HOMEBREW_REPOSITORY}" "${HOMEBREW_LIBRARY}"/Taps/*/*
do
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]] &&
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]] &&
[[ -z "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_UPDATE_AUTO}" ]] &&
[[ "${DIR}" == "${HOMEBREW_CORE_REPOSITORY}" ||
"${DIR}" == "${HOMEBREW_CASK_REPOSITORY}" ]]
Expand Down Expand Up @@ -767,7 +768,7 @@ EOS
fi
done

if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" ]]
if [[ -z "${HOMEBREW_NO_INSTALL_FROM_API}" && -n "${HOMEBREW_INSTALL_FROM_API}" ]]
then
mkdir -p "${HOMEBREW_CACHE}/api"

Expand Down
3 changes: 0 additions & 3 deletions Library/Homebrew/dev-cmd/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ def setup_environment!(args)
ENV["HOMEBREW_TEST_ONLINE"] = "1" if args.online?
ENV["HOMEBREW_SORBET_RUNTIME"] = "1"

# TODO: remove this and fix tests when possible.
ENV["HOMEBREW_NO_INSTALL_FROM_API"] = "1"

ENV["USER"] ||= system_command!("id", args: ["-nu"]).stdout.chomp

# Avoid local configuration messing with tests, e.g. git being configured
Expand Down
14 changes: 11 additions & 3 deletions Library/Homebrew/env_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module EnvConfig
description: "Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, " \
"e.g. `brew install`, `brew upgrade` and `brew tap`. Alternatively, " \
"disable auto-update entirely with HOMEBREW_NO_AUTO_UPDATE.",
default_text: "86400 (24 hours) or 300 (5 minutes) if HOMEBREW_NO_INSTALL_FROM_API is set.",
default_text: "300 (5 minutes) or 86400 (24 hours) if HOMEBREW_INSTALL_FROM_API is set.",
},
HOMEBREW_AUTOREMOVE: {
description: "If set, calls to `brew cleanup` and `brew uninstall` will automatically " \
Expand Down Expand Up @@ -231,6 +231,13 @@ module EnvConfig
default_text: 'The "Beer Mug" emoji.',
default: "🍺",
},
HOMEBREW_INSTALL_FROM_API: {
description: "If set, install formulae and casks in homebrew/core and homebrew/cask taps using Homebrew's " \
"API instead of needing (large, slow) local checkouts of these repositories. Note, this will " \
"only take effect in supported configurations (i.e. using the default Homebrew prefix and, " \
"if on macOS, on a supported version).",
boolean: true,
},
HOMEBREW_LIVECHECK_WATCHLIST: {
description: "Consult this file for the list of formulae to check by default when no formula argument " \
"is passed to `brew livecheck`.",
Expand Down Expand Up @@ -314,7 +321,8 @@ module EnvConfig
},
HOMEBREW_NO_INSTALL_FROM_API: {
description: "If set, do not install formulae and casks in homebrew/core and homebrew/cask taps using " \
"Homebrew's API and instead use (large, slow) local checkouts of these repositories.",
"Homebrew's API even if `HOMEBREW_INSTALL_FROM_API` is set and instead use (large, slow) " \
"local checkouts of these repositories.",
boolean: true,
},
HOMEBREW_NO_INSTALL_UPGRADE: {
Expand Down Expand Up @@ -488,7 +496,7 @@ def install_from_api?
return false if OS.unsupported_configuration?
return false unless Homebrew.default_prefix?

ENV["HOMEBREW_NO_INSTALL_FROM_API"].blank?
ENV["HOMEBREW_NO_INSTALL_FROM_API"].blank? && ENV["HOMEBREW_INSTALL_FROM_API"].present?
end
end
end
8 changes: 4 additions & 4 deletions docs/Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ export HOMEBREW_CORE_GIT_REMOTE="..." # put your Git mirror of Homebrew/homebre

The default Git remote will be used if the corresponding environment variable is unset.

## Default Tap Cloning
## Skip Tap Cloning (beta)

You can instruct Homebrew to return to pre-4.0.0 behaviour by cloning the Homebrew/homebrew-core tap during installation by setting the `HOMEBREW_NO_INSTALL_FROM_API` environment variable with the following:
You can instruct Homebrew to skip cloning the Homebrew/homebrew-core tap during installation by setting the beta `HOMEBREW_INSTALL_FROM_API` environment variable with the following:

```bash
export HOMEBREW_NO_INSTALL_FROM_API=1
export HOMEBREW_INSTALL_FROM_API=1
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
```

This will make Homebrew install formulae and casks from the `homebrew/core` and `homebrew/cask` taps using local checkouts of these repositories instead of Homebrew’s API.
This will make Homebrew install formulae and casks from the `homebrew/core` and `homebrew/cask` taps using Homebrew’s API instead of local checkouts of these repositories.

Note, this will take effect in supported configurations (i.e. using the default Homebrew prefix and, if on macOS, on a supported version).

Expand Down
7 changes: 5 additions & 2 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,7 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
- `HOMEBREW_AUTO_UPDATE_SECS`
<br>Run `brew update` once every `HOMEBREW_AUTO_UPDATE_SECS` seconds before some commands, e.g. `brew install`, `brew upgrade` and `brew tap`. Alternatively, disable auto-update entirely with HOMEBREW_NO_AUTO_UPDATE.

*Default:* 86400 (24 hours) or 300 (5 minutes) if HOMEBREW_NO_INSTALL_FROM_API is set.
*Default:* 300 (5 minutes) or 86400 (24 hours) if HOMEBREW_INSTALL_FROM_API is set.

- `HOMEBREW_AUTOREMOVE`
<br>If set, calls to `brew cleanup` and `brew uninstall` will automatically remove unused formula dependents and if HOMEBREW_NO_INSTALL_CLEANUP is not set, `brew cleanup` will start running `brew autoremove` periodically.
Expand Down Expand Up @@ -2153,6 +2153,9 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just

*Default:* The "Beer Mug" emoji.

- `HOMEBREW_INSTALL_FROM_API`
<br>If set, install formulae and casks in homebrew/core and homebrew/cask taps using Homebrew's API instead of needing (large, slow) local checkouts of these repositories. Note, this will only take effect in supported configurations (i.e. using the default Homebrew prefix and, if on macOS, on a supported version).

- `HOMEBREW_LIVECHECK_WATCHLIST`
<br>Consult this file for the list of formulae to check by default when no formula argument is passed to `brew livecheck`.

Expand Down Expand Up @@ -2209,7 +2212,7 @@ example, run `export HOMEBREW_NO_INSECURE_REDIRECT=1` rather than just
<br>If set, `brew install`, `brew upgrade` and `brew reinstall` will never automatically cleanup installed/upgraded/reinstalled formulae or all formulae every `HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS` days. Alternatively, HOMEBREW_NO_CLEANUP_FORMULAE allows specifying specific formulae to not clean up.

- `HOMEBREW_NO_INSTALL_FROM_API`
<br>If set, do not install formulae and casks in homebrew/core and homebrew/cask taps using Homebrew's API and instead use (large, slow) local checkouts of these repositories.
<br>If set, do not install formulae and casks in homebrew/core and homebrew/cask taps using Homebrew's API even if `HOMEBREW_INSTALL_FROM_API` is set and instead use (large, slow) local checkouts of these repositories.

- `HOMEBREW_NO_INSTALL_UPGRADE`
<br>If set, `brew install *`formula`*` will not upgrade `*`formula`*` if it is installed but outdated.
Expand Down
10 changes: 8 additions & 2 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -2855,7 +2855,7 @@ Prefix all download URLs, including those for bottles, with this value\. For exa
Run \fBbrew update\fR once every \fBHOMEBREW_AUTO_UPDATE_SECS\fR seconds before some commands, e\.g\. \fBbrew install\fR, \fBbrew upgrade\fR and \fBbrew tap\fR\. Alternatively, disable auto\-update entirely with HOMEBREW_NO_AUTO_UPDATE\.
.
.IP
\fIDefault:\fR 86400 (24 hours) or 300 (5 minutes) if HOMEBREW_NO_INSTALL_FROM_API is set\.
\fIDefault:\fR 300 (5 minutes) or 86400 (24 hours) if HOMEBREW_INSTALL_FROM_API is set\.
.
.TP
\fBHOMEBREW_AUTOREMOVE\fR
Expand Down Expand Up @@ -3146,6 +3146,12 @@ Print this text before the installation summary of each successful build\.
\fIDefault:\fR The "Beer Mug" emoji\.
.
.TP
\fBHOMEBREW_INSTALL_FROM_API\fR
.
.br
If set, install formulae and casks in homebrew/core and homebrew/cask taps using Homebrew\'s API instead of needing (large, slow) local checkouts of these repositories\. Note, this will only take effect in supported configurations (i\.e\. using the default Homebrew prefix and, if on macOS, on a supported version)\.
.
.TP
\fBHOMEBREW_LIVECHECK_WATCHLIST\fR
.
.br
Expand Down Expand Up @@ -3254,7 +3260,7 @@ If set, \fBbrew install\fR, \fBbrew upgrade\fR and \fBbrew reinstall\fR will nev
\fBHOMEBREW_NO_INSTALL_FROM_API\fR
.
.br
If set, do not install formulae and casks in homebrew/core and homebrew/cask taps using Homebrew\'s API and instead use (large, slow) local checkouts of these repositories\.
If set, do not install formulae and casks in homebrew/core and homebrew/cask taps using Homebrew\'s API even if \fBHOMEBREW_INSTALL_FROM_API\fR is set and instead use (large, slow) local checkouts of these repositories\.
.
.TP
\fBHOMEBREW_NO_INSTALL_UPGRADE\fR
Expand Down

0 comments on commit f4e6048

Please sign in to comment.