カテゴリー : Homebrew

brew update で fatal: cannot create directory at ‘.github’: Permission denied というエラーが出たときの対応方法

Mac で brew update を実行したら、

$ brew update
fatal: cannot create directory at '.github': Permission denied
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

というエラーメッセージが表示されたときの対応方法をご紹介します。

/usr/local ディレクトリの permission を変更

fatal: cannot create directory at ‘.github’: Permission denied というエラーメッセージが表示されるのは /usr/local ディレクトリの permission が無いのが原因です。

chown コマンドで所有者を自分に変更しましょう。

$ ls -la /usr/local
total 112
drwxr-xr-x   24 root     wheel    816 Oct 28 08:47 .
$ sudo chown $(whoami):admin /usr/local
$ ls -la /usr/local
total 112
drwxr-xr-x   24 myname  admin    816 Oct 28 08:47 .

Homebrew の GitHub repository を master へ更新

cd `brew --prefix`
git fetch origin
git reset --hard origin/master

最後に Homebrew をアップデート

$ brew update
$ brew -v
Homebrew 0.9.9 (git revision 145155; last commit 2016-04-23)
Homebrew/homebrew-core (git revision bd06; last commit 2016-04-23)

以上です。

[Mac] Yosemite で brew コマンドが動かないときの解決方法

Mac OS X Yosemite で brew コマンドを実行しようとするとエラーが発生しました。

エラー内容

% brew -h
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 21: /usr/local/Library/brew.rb: Undefined error: 0

brew コマンド復活の手順

まず、下記のように ruby の path を 1.8 から current へ変更します。

git diff
 
diff --git a/Library/brew.rb b/Library/brew.rb
index 4fa22b4..ee05650 100755
--- a/Library/brew.rb
+++ b/Library/brew.rb
@@ -1,4 +1,4 @@
-#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
+#!/System/Library/Frameworks/Ruby.framework/Versions/current/usr/bin/ruby -W0
 # encoding: UTF-8
 
 std_trap = trap("INT") { exit! 130 } # no backtrace thanks

次に brew の git repository へ移動して、修正内容を commit します。

cd $(brew --prefix)
git add .
git commit -m 'Change the path for ruby'
brew update

最後に git commit をしておかないと brew update したときに下記のようにエラーでアップデートできません。

% brew update
 
error: Your local changes to the following files would be overwritten by merge:
	Library/Formula/mongodb.rb
Please, commit your changes or stash them before you can merge.
error: Your local changes to the following files would be overwritten by merge:
	Library/brew.rb
Please, commit your changes or stash them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

brew update で盛大に conflict したときは手元の修正は捨てて、

git reset --hard HEAD
git merge -Xtheirs origin/master

してしまえば OK です。


参考情報

[Homebrew] brew missing, imagemagick: xz

Homebrew で brew doctor したら xz というライブラリがインストールされてないというエラーが出ました。

$ brew doctor 
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
 
Warning: Some installed formula are missing dependencies.
You should `brew install` the missing dependencies:
 
    brew install xz
 
Run `brew missing` for more details.

brew missing すると詳細が分かるということだったので、やってみたら ImageMagick の依存ライブラリとのことでした。

$ brew missing
imagemagick: xz

xz を brew install します。

$ brew install xz
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/xz-5.0.7.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring xz-5.0.7.yosemite.bottle.tar.gz
  /usr/local/Cellar/xz/5.0.7: 58 files, 1.5M

もう一度、brew doctor でチェックします。

$ brew doctor
Your system is ready to brew.

正常に戻りました。

[Homebrew] brew upgrade Warning: No developer tools installed. -> Run `xcode-select –install`

Mac OS X Mavericks で brew upgrade したらWarningでた。

% brew upgrade
Warning: No developer tools installed.
You should install the Command Line Tools.
Run `xcode-select --install` to install them.

xcode-select –install すればいいらしい。

% xcode-select --install
xcode-select: note: install requested for command line developer tools

[Mac] PHP5.4 を Homebrew でインストール

Mac に PHP5.4 を Homebrew でインストールしたのでメモ。

デフォルトでは、PHPのFormulaは無いので、homebrew-phpを使ってインストールします。

brew tap homebrew/dupes
brew tap josegonzalez/homebrew-php

PHP5.4 のインストールオプションを確認します。

% brew options php54
--32-bit
	Build 32-bit only.
--homebrew-apxs
	Build against apxs in Homebrew prefix
--with-cgi
	Enable building of the CGI executable (implies --without-apache)
--with-debug
	Compile with debugging symbols
--with-fpm
	Enable building of the fpm SAPI executable (implies --without-apache)
--with-gmp
	Build with gmp support
--with-homebrew-openssl
	Include OpenSSL support via Homebrew
--with-imap
	Include IMAP extension
--with-intl
	Include internationalization support
--with-libmysql
	Include (old-style) libmysql support
--with-mssql
	Include MSSQL-DB support
--with-pgsql
	Include PostgreSQL support
--with-thread-safety
	Build with thread safety
--with-tidy
	Include Tidy support
--with-unixodbc
	Build with unixodbc support
--without-apache
	Build without shared Apache 2.0 Handler module
--without-bz2
	Build without bz2 support
--without-mysql
	Remove MySQL/MariaDB support
--without-pear
	Build without PEAR
% brew install php54 \
> --with-fpm \
> --with-homebrew-openssl \
> --with-intl \
> --with-pgsql
 
...
 
==> make install
==> /usr/local/Cellar/php54/5.4.16/bin/pear config-set php_ini /usr/local/etc/php/5.4/php.ini
==> Caveats
The php.ini file can be found in:
    /usr/local/etc/php/5.4/php.ini
 
✩✩✩✩ PEAR ✩✩✩✩
 
If PEAR complains about permissions, 'fix' the default PEAR permissions and config:
    chmod -R ug+w /usr/local/Cellar/php54/5.4.16/lib/php
    pear config-set php_ini /usr/local/etc/php/5.4/php.ini
 
✩✩✩✩ Extensions ✩✩✩✩
 
If you are having issues with custom extension compiling, ensure that this php is
in your PATH:
    PATH="$(brew --prefix josegonzalez/php/php54)/bin:$PATH"
 
PHP54 Extensions will always be compiled against this PHP. Please install them
using --without-homebrew-php to enable compiling against system PHP.
 
✩✩✩✩✩ INTL Support ✩✩✩✩✩
 
icu4c is broken as of mxcl/homebrew#03ed757c, so you will need to install intl as
a separate extension:
 
    brew install php54-intl
 
✩✩✩✩ FPM ✩✩✩✩
 
To launch php-fpm on startup:
    * If this is your first install:
        mkdir -p ~/Library/LaunchAgents
        cp /usr/local/Cellar/php54/5.4.16/homebrew-php.josegonzalez.php54.plist ~/Library/LaunchAgents/
        launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php54.plist
 
    * If this is an upgrade and you already have the homebrew-php.josegonzalez.php54.plist loaded:
        launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php54.plist
        cp /usr/local/Cellar/php54/5.4.16/homebrew-php.josegonzalez.php54.plist ~/Library/LaunchAgents/
        launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php54.plist
 
The control script is located at /usr/local/Cellar/php54/5.4.16/sbin/php54-fpm
 
Mountain Lion comes with php-fpm pre-installed, to ensure you are using the brew version you need to make sure /usr/local/sbin is before /usr/sbin in your PATH:
 
  PATH="/usr/local/sbin:$PATH"
 
You may also need to edit the plist to use the correct "UserName".
 
Please note that the plist was called 'org.php-fpm.plist' in old versions
of this formula.
 
To have launchd start php54 at login:
    ln -sfv /usr/local/opt/php54/*.plist ~/Library/LaunchAgents
Then to load php54 now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php54.plist
Warning: /usr/local/sbin is not in your PATH
You can amend this by altering your ~/.bashrc file
==> Summary
/usr/local/Cellar/php54/5.4.16: 490 files, 38M, built in 5.1 minutes

Pear の設定

% chmod -R ug+w /usr/local/Cellar/php54/5.4.16/lib/php
% pear config-set php_ini /usr/local/etc/php/5.4/php.ini
config-set succeeded

php54-intl のインストール

% brew install php54-intl