49 Commits

Author SHA1 Message Date
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
d1ea6f38d3
Fix mutable constants violations. 2019-04-19 21:46:20 +09:00
Mike McQuaid
e095da4d01
rubocop: enable Layout/EmptyLineAfterGuardClause. 2019-02-21 12:55:49 +00:00
Mike McQuaid
d64429a736
rubocop: enable Style/IfUnlessModifier. 2019-02-21 12:55:49 +00:00
Mike McQuaid
63cfb0ff61
Better handle missing environment variables when updating
Try to re-exec the Homebrew binary to get the environment variables we
need and give up if that doesn't work.
2019-01-12 15:59:08 +00:00
Mike McQuaid
9156d6def4
config: better handle missing variables.
We don’t really have a better solution than this because of how the auto-updater’s Bash code worked on the version they are updating from. Users will never hit this more than once.

Fixes #5513
2019-01-09 17:03:02 +00:00
Mike McQuaid
00dbb221b7
brew.sh: make update --preinstall exec.
This means that any new environment variables or changes to `bin/brew`
or `brew.sh` will be used in the new process. This also allows the
removal of various fallbacks from autoupdates from old versions.
2018-12-29 19:06:18 +00:00
EricFromCanada
20167e5f1b Adjust comments to tidy API docs output. 2018-10-18 21:42:43 -04:00
Mike McQuaid
7615d3a812
Improve writable directory handling
Consolidate the handling of which directories need to exist and which
need to be writable. Additionally, add a fatal check for formula
installations to ensure that any directories that need to be writable
are so before attempting an installation.

Fixes #4626.
2018-09-06 18:38:43 +01:00
Markus Reiter
5841b992ac Refactor $LOAD_PATH. 2018-07-17 23:38:57 +02:00
Mike McQuaid
1424b20a3d config: handle HOMEBREW_TEMP being unset.
This can happen when updating from a previous version of Homebrew.
2018-07-04 07:15:14 +01:00
Mike McQuaid
f46e4596c0 Cleanup HOMEBREW_TEMP handling
- Ensure that `HOMEBREW_TEMP` is only displayed in `brew config` when
  it's non-default.
- Attempt to create a missing `HOMEBREW_TEMP` directory rather than
  failing to `realpath`. Note this will still fail on permissions errors
  which is to be expected.
2018-07-03 15:41:33 +01:00
Mike McQuaid
09ee556833
Merge pull request #4397 from woodruffw/forbid-temp-prefix
brew.sh: Don't allow system tmp dirs as prefixes
2018-07-03 08:31:40 +01:00
William Woodruff
72bc6b1927
config: Remove /tmp fallback
We provide a /private/tmp fallback in bin/brew, so
this is no longer necessary.
2018-07-01 12:33:14 -04:00
William Woodruff
d7cdc9b9a3
config: Ensure HOMEBREW_TEMP is absolute 2018-06-30 12:20:49 -04:00
Markus Reiter
18e46b3ec2 Fix usage of HOMEBREW_LOAD_PATH. 2018-06-18 16:23:35 +02:00
Mike McQuaid
9fca172d03 Fix HOMEBREW_RUBY_WARNINGS="-w"
Fix various circular requirements, method redefinitions, etc.
2018-04-07 20:28:56 +01:00
Mike McQuaid
57db2e539e Revert "Merge pull request #2597 from MikeMcQuaid/vendor-gems"
This reverts commit 3e4547f52e7ebec633f8bfefc8a396d944edf908, reversing
changes made to 6edf9382bcc1240ad6f97c8b752cfe56cef9965d.
2017-05-07 17:28:39 +01:00
Mike McQuaid
e1bbab6ca6 Revert "Merge pull request #2603 from MikeMcQuaid/tweak-gem-vendoring"
This reverts commit 2372872974d1049c2beafe7dedb7f8f882502058, reversing
changes made to 3e4547f52e7ebec633f8bfefc8a396d944edf908.
2017-05-07 17:28:37 +01:00
Mike McQuaid
33f83be10e Tweak Gem vendoring.
If people have `HOMEBREW_RUBY_PATH` set then things explode in a rather
confusing fashion. Instead, run `bundle` for them with the arguments
that they'd want.

Also, move `macho` requires into the module itself; it's a pain having
to do everything for Bundler before requiring `pathname` which is a core
Ruby class.
2017-05-07 15:33:54 +01:00
Mike McQuaid
ee253e465b Vendor all Homebrew's gems.
Homebrew's actually ended up using a fair few gems. While we want to
avoid Bundler at runtime (and this PR still does that, in fact uses
Bundler even less at runtime than it did before) writing our own version
to use at build-time seems redundant.
2017-05-07 13:52:57 +01:00
Markus Reiter
e70d28cba1 Add test to check if rubocop-cask version is is outdated. 2017-02-12 23:06:35 +01:00
Markus Reiter
f48857d246 Use constants for RuboCop version. 2017-02-12 23:06:35 +01:00
Mike McQuaid
8f1ae3b28b Move LinkedKegs migration.
Move the `LinkedKegs` migration into `utils.rb` so it can also be called
from `brew.rb` on startup.
2016-09-17 15:00:46 +01:00
Mike McQuaid
8aa18510c4 Always run LinkedKegs migration (if needed).
Ensure that `brew update` always runs the LinkedKegs migration if needed
as it may not have been run by `brew update` if it was using `--preinstall` or
a `git pull` etc.

Also, if the old paths still exist: just use them instead.

Finally, always try to unlink/unpin before link/pin.

Fixes https://github.com/Homebrew/homebrew-core/issues/4918.
2016-09-17 13:25:32 +01:00
Mike McQuaid
e3609b6fd4 Move LinkedKegs/PinnedKegs/Locks from Library.
These don't make sense to be tied to the `HOMEBREW_REPOSITORY` but
instead should live in the `HOMEBREW_PREFIX` as they all relate to its
state.
2016-09-16 13:51:56 +01:00
Zhiming Wang
e82347b233
Restrict TMPDIR etc. changes to install, post_install and test
See discussion in Homebrew/brew#800.
2016-08-26 12:39:27 +08:00
Mike McQuaid
df21e57179 Merge pull request #800 from zmwangx/set-TMPDIR-TEMP-TMP-to-HOMEBREW_TEMP
config: set TMPDIR, TEMP and TMP to HOMEBREW_TEMP
2016-08-25 10:37:07 +01:00
Mike McQuaid
e7984b34d5 Improve HOMEBREW_BREW_FILE unset failure case.
Print a better exception message and handle this in more cases rather
than producing confusing errors when it’s unset.
2016-08-24 14:48:53 +01:00
Zhiming Wang
9f072a92d5
config: set TMPDIR, TEMP and TMP to HOMEBREW_TEMP
TMPDIR, TEMP and TMP (when set) are not whitelisted for writing in
sandbox.rb, which could result in sandbox violations when programs
attempt to write to these locations.

Setting TMPDIR, TEMP and TMP to HOMEBREW_TEMP (which defaults to /tmp
when not set) works around the aforementioned problem and also improves
uniformity in the locations of tempfiles created during Homebrew
operations.

Caveat: Non-matching HOMEBREW_TEMP and TMPDIR could lead to undesirable
side effects in certain cases, e.g., emacsclient not being able to find
an existing server (whose socket lives in $TMPDIR/emacs$UID/) when
launched through brew edit.
2016-08-24 12:59:57 +08:00
Mike McQuaid
a02be9eea2 ENV: move to new paths. (#507)
Move some stuff formerly in `Library/ENV` around:
- Move `Library/ENV/$XCODE_VERSION` to `Library/Homebrew/env/super` as they are
  all superenv wrappers and all symlinks to the same version. We never needed
  the "separate shims for separate versions" functionality and it just adds
  confusion.
- Move `Library/ENV/pkgconfig` to `Library/Homebrew/env/pkgconfig` to get more
  things under `Library/Homebrew`
- Move `Library/ENV/scm` to `Library/scm` as these wrappers are not actually
  used by or related to superenv (or stdenv) in any way.
2016-07-15 19:03:45 +01:00
Xu Cheng
a35e3f1fc1
add vendor-install command 2016-07-11 21:12:56 +08:00
Martin Afanasjew
22a47af1a2 config: document previously undocumented constants 2016-07-05 20:09:07 +02:00
Martin Afanasjew
e25b49dcb1 config: remove obsolete HOMEBREW_CONTRIB constant 2016-07-05 20:09:07 +02:00
Xu Cheng
8d64b6a02d introduce global lock directory (#337)
Since #292, HOMEBREW_CACHE was moved to a per-user directory. This makes
it unsuitable to store global lock files on multiple users environment.

Therefore, introducing a global lock directory `/Library/Lock.d` to
store lock files from formula lockers as well as `brew update`.
2016-06-08 17:29:03 +08:00
Mike McQuaid
a9abbab917 Move HOMEBREW_CACHE to ~/Library/Caches (#292)
* cleanup: accept cache as an argument.

* config: move default HOMEBREW_CACHE to ~/Library.

* brew.1: document new default Homebrew cache.

* update-report: migrate legacy Homebrew cache.
2016-06-01 08:46:33 +01:00
Xu Cheng
ce7b32cec8 add HOMEBREW_ENV_PATH internal variable
`Library/ENV` like `Library/Homebrew` is part of Homebrew basecode. It
should be able to be accessed during the `brew tests`.

By adding HOMEBREW_ENV_PATH variable, we allow test suit to locate these
codes.
2016-03-21 19:07:38 +08:00
ilovezfs
e6501c3768 HOMEBREW_LIBRARY_PATH: remove redundant /Homebrew
The default HOMEBREW_LIBRARY_PATH should be
  /usr/local/Library/Homebrew
not
  /usr/local/Library/Homebrew/Homebrew

Closes Homebrew/homebrew#49384.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-21 17:34:17 +00:00
Xu Cheng
12a452557d make HOMEBREW_BREW_FILE a Pathname object
Currently HOMEBREW_BREW_FILE is a String, while other of HOMEBREW_*
variables are all Pathname. This commit unifies them all as Pathname,
so it will not cause any confusion.

Closes Homebrew/homebrew#48872.

Signed-off-by: Xu Cheng <xucheng@me.com>
2016-02-06 02:52:48 +08:00
Andrew Janke
40a287f3c3 config.rb: add comment explaining HOMEBREW_TEMP logic 2016-01-30 21:40:26 -05:00
Mike McQuaid
7260b35c31 config: fail when HOMEBREW_BREW_FILE is unset.
Not sure why this is happening (beyond the Chef cookbook stupidly
deciding to not call through `bin/brew`) but fail and print a scary
looking error to hope to point people in the right direction.

Closes Homebrew/homebrew#48261.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-01-27 12:49:25 +00:00
Mike McQuaid
effca7d9c6 bin/brew: set more HOMEBREW_* env from Bash. 2016-01-17 19:39:41 +00:00
Xu Cheng
b121e5fd7b more core file style updated by rubocop 2015-08-06 17:23:56 +08:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Jack Nagel
8bdc7b92d8 Call expand_path on the value of HOMEBREW_CACHE
Fixes Homebrew/homebrew#40752.
2015-06-15 21:21:53 -04:00
Jack Nagel
04ac482809 Revert "Default HOMEBREW_TEMP to Dir.tmpdir"
This reverts commit b95f27ce9f956c56d080b6dc29ba8efb841c6690.
2015-05-03 10:46:23 -04:00
Jack Nagel
a14085acd3 Default HOMEBREW_TEMP to Dir.tmpdir 2015-04-30 20:11:18 -04:00
Jack Nagel
2ca8172fe9 Let the test environment inject its own load path 2015-04-29 19:15:11 -04:00
Jack Nagel
0397d68259 Extract runtime configuration from global.rb
This allows global.rb to be safely loaded in the test environment.
2015-04-29 19:15:11 -04:00