diff options
| author | Mike McQuaid | 2016-11-11 22:52:21 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2016-11-11 22:52:21 +0000 |
| commit | 9edf8eb1fe95ed72b624edd4d2127bbc780e7bce (patch) | |
| tree | 0152369886d4c52196a5190b5d03dc5a074c846e /Library/Homebrew | |
| parent | 0f6cd9d7a51108497974cae52f177c9a8c57c0ed (diff) | |
| download | brew-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')
| -rw-r--r-- | Library/Homebrew/diagnostic.rb | 14 | ||||
| -rw-r--r-- | Library/Homebrew/utils/lock.sh | 15 |
2 files changed, 26 insertions, 3 deletions
diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 216b298fc..0b32f64c7 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -348,6 +348,20 @@ module Homebrew EOS end + def check_access_lock_dir + return unless HOMEBREW_LOCK_DIR.exist? + return if HOMEBREW_LOCK_DIR.writable_real? + + <<-EOS.undent + #{HOMEBREW_LOCK_DIR} isn't writable. + Homebrew writes lock files to this location. + + You should change the ownership and permissions of #{HOMEBREW_LOCK_DIR} + back to your user account. + sudo chown -R $(whoami) #{HOMEBREW_LOCK_DIR} + EOS + end + def check_access_logs return unless HOMEBREW_LOGS.exist? return if HOMEBREW_LOGS.writable_real? 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 } |
