LoginSignup
1
2

More than 5 years have passed since last update.

Ubuntu12でHubot(IRCアダプター)の環境を作る

Posted at

Ubuntu12でHubot(IRCアダプター)の環境を作ってみた時のメモ

環境

  • Ubuntu12_x64
  • nvm v0.31.1
  • Node.js 4.4.4

nvmを使ったNode.jsのインストール

HubotはNode.jsで動作するのでnvmでnodeをインストールします。
LTSの4.4.4をインストールします。

C++ compierが必要でbuild-essentialとlibssl-devが必要なのでこちらもインストールします。

手順は以下の公式リポジトリを参照しました

creationix/nvm

# 関連パッケージのインストール
$sudo apt-get update
$sudo apt-get install build-essential libssl-dev
$sudo apt-get install git curl

# インストール
$curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.1/install.sh | bash

# パスを通す
$source ~/.bashrc

# 確認
$nvm --version
0.31.1

# インストールできるものを確認
$nvm ls-remote

# 4.4.4をインストール
$nvm install 4.4.4

# 確認
$node --version
v4.4.4

Hubotのインストール

次にHubotをインストールします。
以下公式ドキュメントを参考にします。

HUBOT DOCUMENTATION

# npm自体のアップデート
$npm install -g npm

# hubotのインスール
$npm install -g yo generator-hubot
$ mkdir myhubot
$ cd myhubot

# 色々聞かれるのがデフォルトでOK
$ yo hubot

IRCアダプターをインストールする

yo hubotコマンド実行時にIRCアダプターをインストールしたい所なのですが、hubot-ircの依存ライブラリの互換性でv0.2.8では動かなかったので以下のようにpakckage.jsonを編集して追記します。(具体的にはv0.2.8のpackage.jsonのircモジュールが0.3.9固定となっており古い。GitHubのマスターのpackage.jsonは新しいものを指定しているのでGithubのリポジトリを指定するように修正)

package.json
{
  "name": "myhubot",
  "version": "0.0.0",
  "private": true,
  "author": "User <user@example.com>",
  "description": "A simple helpful robot for your Company",
  "dependencies": {
    "hubot": "^2.19.0",
    "hubot-diagnostics": "0.0.1",
    "hubot-google-images": "^0.2.6",
    "hubot-google-translate": "^0.2.0",
    "hubot-help": "^0.2.0",
    "hubot-heroku-keepalive": "^1.0.2",
    "hubot-maps": "0.0.2",
    "hubot-pugme": "^0.1.0",
    "hubot-redis-brain": "0.0.3",
    "hubot-rules": "^0.1.1",
    "hubot-scripts": "^2.17.2",
    "hubot-shipit": "^0.2.0",
    "hubot-irc": "git://github.com/nandub/hubot-irc.git"
  },
  "engines": {
    "node": "0.10.x"
  }
}

"hubot-irc": "git://github.com/nandub/hubot-irc.git"と前行のカンマを追加しています。

また、インストール前に依存するパッケージ郡をインストールします。

# 依存モジュールのnode-icu-charset-detectorで必要
$sudo apt-get install libicu-dev

次にC++アドオンのビルド用にGCCバージョンを4.8にします。(ubuntu12ではインストールされるのは4.6だったため)

C++11のためにGCCの最新版をインストールする

# add-apt-repositoryコマンドを使えるようにする
$sudo apt-get install software-properties-common python-software-properties

# パッケージを追加
$sudo add-apt-repository ppa:ubuntu-toolchain-r/test

# インストール
$sudo apt-get update; sudo apt-get install gcc-4.8 g++-4.8

# 4.8の優先順位を上げる
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 20 

# 元々のコマンドの優先度を下げる
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 10
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 10

# 4.8が使えるか確認
$ gcc --version
$ g++ --version

やっとで準備ができたのでIRCアダプターのインストールをします。

$npm install

エラーなくインストールできました!

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2