読者です 読者をやめる 読者になる 読者になる

エロサイトの作り方

2013年11月から勉強しながらエロサイトを作っています。

HomebrewでNode.js v0.10.24へのアップデートに失敗する

Snow Leopard環境での話なので、OSが古いからだと思うのですが。

バージョン

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.6.8
BuildVersion:   10K549

brew upgradeに失敗する

$ brew upgrade
==> Upgrading 1 outdated package, with result:
node 0.10.24
==> Upgrading node
==> Downloading http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-0.10.24.tar.gz
==> Patching
patching file tools/gyp/pylib/gyp/xcode_emulation.py
==> ./configure --prefix=/usr/local/Cellar/node/0.10.24
==> make install
                                                               ^
SyntaxError: invalid syntax
make[1]: *** [/private/tmp/node-ElC6/node-v0.10.24/out/Release/libcares.a] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [node] Error 2

READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting

These open issues may also help:
    https://github.com/Homebrew/homebrew/pull/25336
    https://github.com/Homebrew/homebrew/issues/17680
    https://github.com/Homebrew/homebrew/issues/24465
    https://github.com/Homebrew/homebrew/pull/25218
    https://github.com/Homebrew/homebrew/pull/25159
    https://github.com/Homebrew/homebrew/issues/23360
    https://github.com/Homebrew/homebrew/issues/5722

ググっても解決策が出てこないエラー。

古いバージョンを消して挑戦

$ brew uninstall node
Uninstalling /usr/local/Cellar/node/0.10.20...
$ brew install node
...

SyntaxError: invalid syntax
make[1]: *** [/private/tmp/node-Hyg7/node-v0.10.24/out/Release/libcares.a] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [node] Error 2
...

同じエラーだった。

主治医にお伺いをたてる

$ brew doctor
Warning: You have uncommitted modifications to Homebrew
If this a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
    cd /usr/local/Library && git stash && git clean -d -f

Warning: Your Homebrew is outdated.
You haven't updated for at least 24 hours, this is a long time in brewland!
To update Homebrew, run `brew update`.

何やら出てきた。

$ brew update
Updated Homebrew from 44988d34 to 16bd5c86.
==> New Formulae
...

==> Updated Formulae
...
$ cd /usr/local/Library && git stash && git clean -d -f
No local changes to save
...
$ brew doctor
Your system is ready to brew.

これで主治医のお墨付きを貰えた。

再挑戦

$ brew install node
==> Installing dependencies for node: readline, sqlite, gdbm, python
==> Installing node dependency: readline
==> Downloading http://ftpmirror.gnu.org/readline/readline-6.2.tar.gz
######################################################################## 100.0%
==> Patching
patching file callback.c
patching file input.c
patching file patchlevel
patching file support/shobj-conf
patching file vi_mode.c
==> ./configure --prefix=/usr/local/Cellar/readline/6.2.4 --mandir=/usr/local/Cellar/readline/
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

OS X provides the BSD libedit library, which shadows libreadline.
In order to prevent conflicts when programs look for libreadline we are
defaulting this GNU Readline installation to keg-only.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/readline/lib
    CPPFLAGS: -I/usr/local/opt/readline/include

==> Summary
/usr/local/Cellar/readline/6.2.4: 31 files, 1.6M, built in 32 seconds
==> Installing node dependency: sqlite
==> Downloading http://www.sqlite.org/2013/sqlite-autoconf-3080200.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/sqlite/3.8.2 --enable-dynamic-extensions
==> make install
==> Caveats
This formula is keg-only, so it was not symlinked into /usr/local.

Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.

OS X provides an older sqlite3.

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/sqlite/lib
    CPPFLAGS: -I/usr/local/opt/sqlite/include

==> Summary
/usr/local/Cellar/sqlite/3.8.2: 9 files, 2.1M, built in 42 seconds
==> Installing node dependency: gdbm
==> Downloading http://ftpmirror.gnu.org/gdbm/gdbm-1.11.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/gdbm/1.11 --mandir=/usr/local/Cellar/gdbm/1.11/shar
==> make install
/usr/local/Cellar/gdbm/1.11: 16 files, 424K, built in 17 seconds
==> Installing node dependency: python
==> Downloading http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/python/2.7.6 --enable-ipv6 --datarootdir=/usr/local
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.6
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.6/share/python
==> Downloading https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.1.tar.gz
######################################################################## 100.0%
==> /usr/local/Cellar/python/2.7.6/bin/python -s setup.py --no-user-cfg install --force --verb
==> Downloading https://pypi.python.org/packages/source/p/pip/pip-1.4.1.tar.gz
######################################################################## 100.0%
==> /usr/local/Cellar/python/2.7.6/bin/python -s setup.py --no-user-cfg install --force --verb
==> Caveats
Python demo
  /usr/local/share/python/Extras

Setuptools and Pip have been installed. To update them
  pip install --upgrade setuptools
  pip install --upgrade pip

To symlink "Idle" and the "Python Launcher" to ~/Applications
  `brew linkapps`

You can install Python packages with (the outdated easy_install or)
  `pip install <your_favorite_package>`

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: https://github.com/Homebrew/homebrew/wiki/Homebrew-and-Python
==> Summary
/usr/local/Cellar/python/2.7.6: 5225 files, 81M, built in 2.8 minutes
==> Installing node
==> Downloading http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-0.10.24.tar.gz
==> Patching
patching file tools/gyp/pylib/gyp/xcode_emulation.py
==> ./configure --prefix=/usr/local/Cellar/node/0.10.24
==> make install
                                                               ^
SyntaxError: invalid syntax
make[1]: *** [/private/tmp/node-d04A/node-v0.10.24/out/Release/libcares.a] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [node] Error 2

READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting

These open issues may also help:
    https://github.com/Homebrew/homebrew/pull/25588
    https://github.com/Homebrew/homebrew/issues/17680
    https://github.com/Homebrew/homebrew/issues/24465
    https://github.com/Homebrew/homebrew/pull/25336
    https://github.com/Homebrew/homebrew/issues/5722
    https://github.com/Homebrew/homebrew/pull/25218
    https://github.com/Homebrew/homebrew/issues/23360

結果的には失敗したけど、何か違うメッセージが出てきた。

pipでアップデートする

$ pip install --upgrade setuptools
...
$ pip install --upgrade pip
Downloading/unpacking pip from https://pypi.python.org/packages/source/p/pip/pip-1.5.tar.    gz#md5=6969b8a8adc4c7f7c5eb1707118f0686    
  Downloading pip-1.5.tar.gz (898kB): 8    98kB downloaded    
  Running setup.py egg_info for package     pip    

    warning: no files found matching 'pip/cacert.pem'
    warning: no files found matching '*.html' under directory 'docs'
require 'formula'

class NpmNotInstalled < Requirement
  fatal true

  def modules_folder
    "#{HOMEBREW_PREFIX}/lib/node_modules"
  end

  def message; <<-EOS.undent
    Beginning with 0.8.0, this recipe now comes with npm.
    It appears you already have npm installed at #{modules_folder}/npm.
    To use the npm that comes with this recipe, first uninstall npm with
    `npm uninstall npm -g`, then run this command again.

    If you would like to keep your installation of npm instead of
    using the one provided with homebrew, install the formula with
    the `--without-npm` option.
    EOS
  end

  satisfy :build_env => false do
    begin
      path = Pathname.new("#{modules_folder}/npm/bin/npm")
      path.realpath.to_s.include?(HOMEBREW_CELLAR)
    rescue Errno::ENOENT
      true
    end
  end
end

# Note that x.even are stable releases, x.odd are devel releases
class Node < Formula
  homepage 'http://nodejs.org/'
  url 'http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz'
  sha1 'd162d01eb173cb5a0e7e46c9d706421c4c771039'

  devel do
    url 'http://nodejs.org/dist/v0.11.9/node-v0.11.9.tar.gz'
    sha1 'b4fc0e38ccde4edae45db198f331499055d77ca2'
  end
/CFLAG
    warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
Installing collected packages: pip
  Found existing installation: pip 1.4.1
    Uninstalling pip:
      Successfully uninstalled pip
  Running setup.py install for pip

    warning: no files found matching 'pip/cacert.pem'
    warning: no files found matching '*.html' under directory 'docs'
    warning: no previously-included files matching '*.rst' found under directory 'docs/_build'
    no previously-included directories found matching 'docs/_build/_sources'
    Installing pip script to /usr/local/bin
    Installing pip2.7 script to /usr/local/bin
    Installing pip2 script to /usr/local/bin
Successfully installed pip
Cleaning up...

警告なんだかソースコードなんだかよくわからないメッセージとともに、一応成功したのか?

$ brew doctor
Your system is ready to brew.

主治医の見解としては問題なし。

三度目

$ brew install node
...

SyntaxError: invalid syntax
make[1]: *** [/private/tmp/node-RuV4/node-v0.10.24/out/Release/libcares.a] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [node] Error 2

READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting

These open issues may also help:
    https://github.com/Homebrew/homebrew/pull/25588
    https://github.com/Homebrew/homebrew/issues/17680
    https://github.com/Homebrew/homebrew/issues/24465
    https://github.com/Homebrew/homebrew/pull/25336
    https://github.com/Homebrew/homebrew/issues/5722
    https://github.com/Homebrew/homebrew/pull/25218
    https://github.com/Homebrew/homebrew/issues/23360

エラーは変わらず。

もしかして、一つ前のバージョンなら入るのか?

$ brew versions node
Warning: brew-versions is unsupported and may be removed soon.
Please use the homebrew-versions tap instead:
  https://github.com/Homebrew/homebrew-versions
0.10.24  git checkout 1c5ad64 Library/Formula/node.rb
0.10.23  git checkout 5ab4328 Library/Formula/node.rb
0.10.22  git checkout 72f61d1 Library/Formula/node.rb
0.10.21  git checkout f8e98c8 Library/Formula/node.rb
0.10.20  git checkout 653960e Library/Formula/node.rb
...

0.10.23を入れてみる。

$ cd /usr/local/
$ git checkout 5ab4328 Library/Formula/node.rb

gitでブランチバージョンを指定して、checkoutする。

$ brew info node
node: stable 0.10.23, devel 0.11.9, HEAD
http://nodejs.org/
Not installed
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/node.rb
==> Options
--enable-debug
    Build with debugger hooks
--without-npm
    npm will not be installed
--devel
    install development version 0.11.9
--HEAD
    install HEAD version
$ brew install node
==> Downloading http://nodejs.org/dist/v0.10.23/node-v0.10.23.tar.gz
######################################################################## 100.0%
==> Patching
patching file tools/gyp/pylib/gyp/xcode_emulation.py
==> ./configure --prefix=/usr/local/Cellar/node/0.10.23
==> make install
/usr/local/Cellar/node/0.10.23: 1084 files, 16M, built in 5.0 minutes
$ node -v
v0.10.23

入った。

でも、最新を入れたい

ここから色々やったわけなんですが、最終的には--env=stdを付けたらいけました。

$ brew install node --env=std
==> Downloading http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-0.10.24.tar.gz
==> Patching
patching file tools/gyp/pylib/gyp/xcode_emulation.py
==> ./configure --prefix=/usr/local/Cellar/node/0.10.24
==> make install
/usr/local/Cellar/node/0.10.24: 1119 files, 19M, built in 5.4 minutes
$ node -v
v0.10.24

しかし、理由はよくわからない。