954 Commits

Author SHA1 Message Date
Carlo Cabrera
de676841f6
formula_installer: skip bottle check on old Macs
Fixes #10832.
2021-03-12 15:38:45 +00:00
Bo Anderson
73d372e951
formula_installer: further reduce dependency calculations 2021-03-10 17:09:14 +00:00
Bo Anderson
31a4989358
Merge pull request #10792 from Bo98/fi-less-dep-comp
formula_installer: reduce dependency expansion computations
2021-03-08 14:03:55 +00:00
Bo Anderson
96670cedb2
formula_installer: reduce dependency expansion computations 2021-03-08 13:12:12 +00:00
Mike McQuaid
761404a2dc
formula_installer: tweak "no bottle available" logic.
- ensure that `HOMEBREW_DEVELOPER` still fails when there's a bottle
  available but the `pour_bottle?` block fails. This is usually due to
  the CLT being missing (and it's removed on even patch macOS upgrades)
  so building from source without prompt is undesirable.
- require `--build-from-source` for dependencies that aren't already
  installed
- do these bottle checks before fetching dependencies (they were already
  done before fetching requested formulae)

Fixes #10729
2021-03-05 12:06:34 +00:00
Steve Peters
e3505247cb
formula_installer: fix typo in install_dependency
The linked_keg variable is referenced outside the block where
it is defined; I think it should be the installed_keg variable.
2021-03-02 01:16:55 -08:00
Bo Anderson
6cd1e5e384
Avoid passing around a massive $LOAD_PATH.
Portable Ruby crashes if the $LOAD_PATH gets too big.
2021-02-26 18:23:48 +00:00
Mike McQuaid
2b1f460289
Fix installed_on_request for dependencies.
Dependencies were using `Tab.for_formula(df)` to get a `Tab` which meant
that they were always ending up with the (default) value of `true` for
`installed_on_request`. Fix this by:
- setting `installed_on_request` to `false` by default in empty `Tab`s;
  we always override it on installation so we'd rather have it default
  to `false`
- only read and use a `Tab` for the existing dependency formula if
  there's an existing `Keg`
2021-02-23 10:19:45 +00:00
Mike McQuaid
22e591e531
Make HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK default
- Remove `HOMEBREW_NO_BOTTLE_SOURCE_FALLBACK` and make the behaviour
  the default. We mostly already do this since we added the need for
  the `--build-from-source` override on macOS. This allows us to
  delete some more code.
- Still fail and require `--build-from-source` when reinstalling or
  upgrading if failing on a formula-specific reason e.g. the CLT is
  not/no longer installed, you're using a non-default prefix.

Fixes #10623
2021-02-17 13:51:53 +00:00
nandahkrishna
8e5451df2f
style: use parentheses for assignment in conditions 2021-02-12 18:33:37 +05:30
EricFromCanada
6fc116318e fixes for grammar and wording 2021-01-26 16:19:47 -05:00
EricFromCanada
99ad3350ee use single quotes around stanza and parameter names 2021-01-26 16:19:47 -05:00
EricFromCanada
cd3cb6928b indent suggested commands on subsequent line
and combine sequential puts calls
2021-01-26 15:36:44 -05:00
EricFromCanada
f5e1557154 use ofail to set Homebrew.failed 2021-01-26 15:36:43 -05:00
hyuraku
e6eeb2cbed delete HOMEBREW_REPOSITORY & some variables 2021-01-27 00:29:43 +09:00
Seeker
b9854bd4cf rubocops: add unless_multiple_conditions 2021-01-08 10:33:54 -08:00
carlocab
beeb7faaba
formula_installer: tweak no-bottle error message
Follow up to #10183.

This improves the error message displayed when `formula.pour_bottle?` is
false.

Before:

    ❯ brew install python@3.8
    Error: python@3.8: no bottle available!
    The bottle needs the Apple Command Line Tools to be installed.
      You can install them, if desired, with:
        xcode-select --install
    You can try to install from source with e.g.
      brew install --build-from-source python@3.8
    Please note building from source is unsupported. You will encounter build
    failures with some formulae. If you experience any issues please create pull
    requests instead of asking for help on Homebrew's GitHub, Twitter or any other
    official channels.

After:

    ❯ brew install python@3.8
    Error: python@3.8: the bottle needs the Apple Command Line Tools to be installed.
      You can install them, if desired, with:
        xcode-select --install
    You can try to install from source with e.g.
      brew install --build-from-source python@3.8
    Please note building from source is unsupported. You will encounter build
    failures with some formulae. If you experience any issues please create pull
    requests instead of asking for help on Homebrew's GitHub, Twitter or any other
    official channels.
2021-01-04 15:53:50 +00:00
Mike McQuaid
cc50307aca
formula_installer: use existing no bottle text. 2020-12-31 13:09:35 +00:00
carlocab
2dedca337e
formula_installer: improve no-bottle error message
Closes #10180.
2020-12-31 01:11:44 +00:00
Mike McQuaid
07f9f6c42c
formula_installer: only require --build-from-source on macOS. 2020-12-28 08:47:05 +00:00
Mike McQuaid
2777369da7
formula_installer: exclude more from build-from-source warning.
We should only complain when installing requested formulae that aren't
currently installed.
2020-12-18 14:56:01 +00:00
Mike McQuaid
0bbf965807
More bottling HOMEBREW_LIBRARY changes
- Refuse to create bottles which have non-relocatable references to
  `HOMEBREW_LIBRARY`. This allows us to make all bottles ignore where
  `HOMEBREW_REPOSITORY` is (even those that aren't `cellar :any`).
  I cannot see any circumstances in which any bottle should link to
  anything within `HOMEBREW_REPOSITORY`.
- Remove audit that becomes unnecessary given the above change.
- Relocate references to `@HOMEBREW_LIBRARY@` but don't actually write
  any references yet. This will allow us to move to using
  `@HOMEBREW_LIBRARY` and remove all relocation of `HOMEBREW_REPOSITORY`
  in a future release (2.7.1, most likely).
2020-12-18 13:50:10 +00:00
Mike McQuaid
79eeb00d0c
Merge pull request #10030 from MikeMcQuaid/formula_installer_pour_bottle
formula_installer: refactor pour_bottle?
2020-12-16 15:19:34 +00:00
Mike McQuaid
7fd716ff66
formula_installer: refactor source build messages. 2020-12-16 12:38:52 +00:00
Francois-Xavier Coudert
4db1c1a00f
Do not build from source on ARM unless explicitly requested 2020-12-16 11:45:51 +00:00
Mike McQuaid
fc9ad05ad5
formula_installer: refactor pour_bottle?
Use a better keyword argument rather than passing a hash.
2020-12-16 09:01:06 +00:00
Shaun Jackman
33483e9478 Fix install --force-bottle for non-standard prefix
Fix the error:
Error: undefined method `stage' for nil:NilClass
formula_installer.rb:1132:in `block in pour'
2020-12-15 00:04:36 -08:00
Mike McQuaid
eb74717a9e
Fix unbottled dependency handling
- Rename `BuildToolsError` to `UnbottledError` to better reflect what it
  does (particularly now)
- Improve the `UnbottledError` messaging
- Raise the `UnbottledError` for dependencies also when building bottles
  (so that we don't try and build bottles against things that have been
  built from source).
2020-12-11 16:57:47 +00:00
Mike McQuaid
0f9bad0052
Fix bottle prefix and repository handling
We were previously only looking at the `cellar` value when pouring
bottles and ignoring the `prefix` and (implicit) `repository`.

Actually look at these values and set the defaults for each platform.

Also, when we're relocating to create or pour bottles when `prefix`
and `repository` are equal then skip relocating the `repository` and
always use references to the `prefix` instead.

Fixes #9453
2020-12-09 13:53:10 +00:00
Mike McQuaid
9216d8abe6
rubocop-rails: make fixes. 2020-12-02 10:43:04 +00:00
Markus Reiter
7d9758a05e Fix RuboCop offenses. 2020-11-30 22:50:15 +01:00
Jonathan Chang
ce67dc3e63 formula_installer: fix type for fetch_dependency
This receives a Dependency, not a Formula.
2020-11-20 22:09:59 +11:00
Markus Reiter
7c5d8a5288 Refactor FormulaInstaller. 2020-11-18 09:30:11 +01:00
Markus Reiter
a014f65e41 Fix type checking errors. 2020-11-18 04:21:41 +01:00
Markus Reiter
1b732ec7b2 Fix RuboCop offenses. 2020-11-16 02:05:29 +01:00
Rylan Polster
50890ebd51 fix Lint/DuplicateBranch style 2020-11-16 02:02:52 +01:00
Markus Reiter
da9289eff0 Add more type signatures. 2020-11-13 12:26:36 +01:00
Mike McQuaid
5afff3f3aa
Handle macOS Homebrew on ARM
- Output `brew doctor` and `brew install` messages noting this configuration is (currently) unsupported and encourage use of Rosetta instead
- Output Rosetta 2 usage in `brew config` on ARM (whether in Rosetta 2 or not)
- Check the architecture of (newly installed) dependencies and ensure they are using the correct architecture.
- Don't allow installing macOS Intel Homebrew in macOS ARM Homebrew default prefix (and vice versa
- Actually write out the architecture of dependencies to the tab rather than generating and throwing them away
- Set and document the expected default prefix for macOS Intel Homebrew, macOS ARM Homebrew (`/opt/homebrew`) and Homebrew on Linux

While we're here:
- Don't say Big Sur is a prerelease version but still make it clear we
  don't support it (yet).
- Don't reference non-existent IRC channel
2020-11-12 17:06:47 +00:00
Mike McQuaid
746e7000e3
Improve --force-bottle behaviour.
- set `Formula#force_bottle` from `FormulaInstaller`
- refuse to install non-bottled formulae with `--force-bottle`
- raise exceptions on fetch/pour failures if `--force-bottle is passed.

While we're here:
- use `CannotInstallFormulaError` for some `RuntimeError`/`odie`

Fixes https://github.com/Homebrew/brew/issues/8866.
2020-11-06 11:25:31 +00:00
Mike McQuaid
dcba99c7d1
Revert "Revert "Improve @-versioned formulae linking."" 2020-11-02 11:20:09 +00:00
Shaun Jackman
099af8cf9c
Revert "Improve @-versioned formulae linking." 2020-10-30 10:40:10 -07:00
Mike McQuaid
849034c368
Improve @-versioned formulae linking.
The way we currently handle @-versioned formulae linking is pretty
labourius:
- it requires extensive use of `link_overwrite` to avoid the `link`
  stage failing on certain install/upgrade scenarios
- we teach people to use `brew link --force` whenever they wish to
  link a versioned formulae when it's pretty obvious what's expected
  in that situation

Instead, let's:
- automatically unlink other versioned formulae when linking a
  versioned formula (either through `brew link` or `install`/`upgrade`
  /`reinstall`)
- notify the user what we've done (with the same messaging as if
  they had run `brew link` manually)
2020-10-29 13:35:03 +00:00
Mike McQuaid
ffe827ad0e
Fix upgrading dependents on missing keg
Ensure that we don't try to check for broken linkage in a keg that
doesn't exist. Furthermore, fix the reason we checked for the keg that
doesn't exist by `Formula.clear_cache`.

While here, I noticed that there was other methods of caching at use in
`Formula` so consolidate them to be consistent.

Fixes #8997
2020-10-29 08:31:04 +00:00
Rylan Polster
42d75c2787 formula_installer: fix forbidden license check
Convert forbidden licenses to a string before duplicating to have empty
strings instead of `nil`.
2020-10-22 15:15:56 -04:00
Rylan Polster
b06bcf3db1 formula_installer: unfreeze forbidden licenses string 2020-10-22 11:22:06 -04:00
Rylan Polster
24523f8225 utils/spdx: allow other license symbols 2020-10-22 10:01:40 -04:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Rylan Polster
a8bcd92628 deprecate_disable: refactor and add to info 2020-09-07 13:00:02 -04:00
Mike McQuaid
2e5272d04c Deprecate/disable code for Homebrew 2.5.0.
Do the usual "disable deprecations" and "uncomment pending deprecations"
dance and delete/deprecate/disable relevant/related code.
2020-09-03 10:34:22 +01:00
Rylan Polster
e7cf1f4497 fix deprecate! and disable! message 2020-08-31 12:45:55 -04:00