タグ : homebrew

[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.

正常に戻りました。

[Node.js] node-wkhtmltopdf を使う

Node.js で wkhtmltopdf を使う方法をメモ。
(最終更新日:2014/11/28)

node-wkhtmltopdf

A Node.js wrapper for the wkhtmltopdf command line tool.

wkhtmltopdf

ということで、npm module だけだと使えないので wkhtmltopdf はインストールする必要があります。

wkhtmltopdf のインストール

# the wkhtmltopdf formula is now inactive but still available in the boneyard repository
brew tap homebrew/boneyard
 
# Install wkhtmltopdf
brew install wkhtmltopdf

wkhtmltopdf コマンドで、PDFを生成できることを確認します。

wkhtmltopdf "http://google.com" google.pdf

以上です。

[MongoDB] Port を変えて2つ起動する方法 (Mac / Homebrew)

MongoDB を Port を変えて2つ起動する手順 on Mac with Homebrew をご紹介します。

MongoDB | モンゴディービー

続きを読む

[Mac] nkf を Homebrew でインストール

Mac に Homebrew で nkf をインストールしました。

% brew install nkf                     
==> Downloading http://dl.sourceforge.jp/nkf/53171/nkf-2.1.2.tar.gz
######################################################################## 100.0%
==> Patching
patching file Makefile
==> make
==> make install
/usr/local/Cellar/nkf/2.1.2: 4 files, 252K, built in 2 seconds

楽ちん

[Mac] Redis を Homebrew でインストールする

Mac に Redis を Homebrew でインストールする手順をメモ。(最終更新日: 2017/03/31)

Redis のインストール

まず redis を homebrew でインストールします。

% brew install redis
==> Downloading http://redis.googlecode.com/files/redis-2.6.14.tar.gz
######################################################################## 100.0%
==> make -C /private/tmp/redis-ghPL/redis-2.6.14/src CC=cc
==> Caveats
To have launchd start redis at login:
    ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
    redis-server /usr/local/etc/redis.conf
==> Summary
 /usr/local/Cellar/redis/2.6.14: 10 files, 1.3M, built in 8 seconds

Redis 自動起動の設定

PC起動時に、redis を自動起動させたいなら、下記のコマンドを実行します。

ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist

自動起動の設定はせずに、手動で redis を起動させるには下記のコマンドで起動できます。

redis-server /usr/local/etc/redis.conf

Redis へ CLI から接続確認

ターミナルから以下の command で Redis へ接続できるか確認します。

% redis-cli
redis 127.0.0.1:6379>

以上です。

参考情報

[Mac] wget のインストール方法

Mac に wget をインストールしました。

wget も Homebrew でサクッとインストールします。

brew install wget

まだ、Homebrew をインストールしていない方は、今すぐインストールしましょう!

[Mac] Homebrew をインストール

以上です。

[Mac] Node.js と npm をインストールする方法 [Homebrew]

Macに Node.js と npm をインストールする方法を調べたのでメモ。

node.js を homebrew でインストールする

$ brew install node

正常にインストールされたことを確認します。

$ node -v
v0.4.11

 

npm を homebrew でインストールできない…

Homebrew の npm formula は、収録のポリシーに沿わない( https://github.com/mxcl/homebrew/wiki/Acceptable-Formula )として最近、取り除かれたそうです。

メッセージにあるように curl http://npmjs.org/install.sh | sh でインストールすべきみたいです。

$ brew install npm
Error: No available formula for npm
npm can be installed thusly by following the instructions at
  http://npmjs.org/
 
To do it in one line, use this command:
  curl http://npmjs.org/install.sh | sh

 

npm を curl経由でインストールする

$ curl http://npmjs.org/install.sh | sh

正常にインストールされたことを確認します。

$ npm -v
1.0.103

以上です。


参考情報

node.jsとnpmのインストール – 自分の感受性くらい

MacOSXでnode.js/npm/nvmをインストール – tagomorisのメモ置き場

[MacOS] Homebrew で PostgreSQL をインストールする手順

Mac に Homebrew で postgresql をインストールしたので手順をご紹介します。

PostgreSQL

続きを読む