aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils
diff options
context:
space:
mode:
authorMike McQuaid2016-11-11 22:52:21 +0000
committerMike McQuaid2016-11-11 22:52:21 +0000
commit9edf8eb1fe95ed72b624edd4d2127bbc780e7bce (patch)
tree0152369886d4c52196a5190b5d03dc5a074c846e /Library/Homebrew/utils
parent0f6cd9d7a51108497974cae52f177c9a8c57c0ed (diff)
downloadbrew-9edf8eb1fe95ed72b624edd4d2127bbc780e7bce.tar.bz2
Check the lock directory is writable.
And, if it isn't, print more helpful debugging messages. Fixes #1456.
Diffstat (limited to 'Library/Homebrew/utils')
-rw-r--r--Library/Homebrew/utils/lock.sh15
1 files changed, 12 insertions, 3 deletions
diff --git a/Library/Homebrew/utils/lock.sh b/Library/Homebrew/utils/lock.sh
index cc041fa74..7f0638c1a 100644
--- a/Library/Homebrew/utils/lock.sh
+++ b/Library/Homebrew/utils/lock.sh
@@ -6,6 +6,14 @@ lock() {
local lock_dir="$HOMEBREW_PREFIX/var/homebrew/locks"
local lock_file="$lock_dir/$name"
[[ -d "$lock_dir" ]] || mkdir -p "$lock_dir"
+ if ! [[ -w "$lock_dir" ]]
+ then
+ odie <<EOS
+Can't create $name lock in $lock_dir!
+Fix permissions by running:
+ sudo chown -R \$(whoami) $HOMEBREW_PREFIX/var/homebrew
+EOS
+ fi
# 200 is the file descriptor used in the lock.
# This FD should be used exclusively for lock purpose.
# Any value except 0(stdin), 1(stdout) and 2(stderr) can do the job.
@@ -17,10 +25,10 @@ lock() {
exec 200>&-
# open the lock file to FD, so the shell process can hold the lock.
exec 200>"$lock_file"
- if ! _create_lock 200
+ if ! _create_lock 200 "$name"
then
odie <<EOS
-Another active Homebrew process is already in progress.
+Another active Homebrew $name process is already in progress.
Please wait for it to finish or terminate it to continue.
EOS
fi
@@ -28,6 +36,7 @@ EOS
_create_lock() {
local lock_fd="$1"
+ local name="$2"
local ruby="/usr/bin/ruby"
[[ -x "$ruby" ]] || ruby="$(which ruby 2>/dev/null)"
@@ -38,6 +47,6 @@ _create_lock() {
then
flock -n "$lock_fd"
else
- onoe "Cannot create lock, please avoid running brew in parallel."
+ onoe "Cannot create $name lock, please avoid running Homebrew in parallel."
fi
}