RubyonRails入門- その4 後編
その3(Railsでの簡単なアプリ開発編)はこちら
その2(Rails起動編)はこちら
その1(Railsインストール編)はこちら
その0のようなもの(PrograteでRails触ってみた編)はこちら
※筆者が使っているAtomのバージョンは「1.29.0」です。
また、筆者が使っているAtomのバージョンは「1.29.0」です。
続・Atomで開発環境を整えよう!
前回に引き続き、Atomで開発環境を整えていきます。
この後編では、Atomパッケージをインストールする際にハマってしまったこと、テーマについて、Atomの起動時間に関してメモしてあります。
ハマったこと
今回様々なパッケージを入れていった中で…1つハマったことがあったので、メモを残しておきます。
terminal-plusが正常に動かない
Rails快適環境構築の要パッケージの1つ…terminal-plusですが、インストール後なぜか正常に動かなくなってしまったのです。
下記の画像のように、起動しても文字が出て来ず…コマンドを打っても反応が返って来ない状態に。
おかしいなと思い、公式のドキュメントをのぞいてみるとこんな記述が。
Author's Note
- Please make sure you are on the latest version of Atom before reporting bugs!
- This package requires that you have the dependencies for node-gyp.
- See node-gyp install instructions.
- You must use a monospaced font in order for the spacing to be right.
- Having issues on Windows 10? Try this.
どうやらnode-gypというNode.js関連のコマンドラインツールが入ってないと動かないとのことで…。
早速インストールしました。
…が、駄目…ッ!!
それでもterminal-plusくんは返事をしてくれませんでした。
路頭に迷った気持ちで「もうterminal-plus諦めようかな…」と思いつつGoogle先生に聞いてみたら…。
どうやら同じような症状で悩んでる人はたくさんいるらしく、これに関する解決方法を記述してくれてた記事もありましたので、そちらを参考にしながら対処…。
※ちなみに解決に際しては↓の記事にお世話になりました。
Atomのterminal-plusが動かないトラブル - Named Log
具体的な対処法もメモしておきます。
まず~/.atom/packages/terminal-plus/package.json
の47行目あたりの下記の文章を変更。
"git+https://github.com/jeremyramin/pty.js.git#28f2667"
-> "git+https://github.com/jeremyramin/pty.js.git"
その後、cd ~/.atom/packages/terminal-plus/
と打ち…。
そしてnpm install
からのapm rebuild
コマンド実行。
そしてAtom再起動でいける…とのことですが…。
apm rebuildでつまづきました…。
このコマンドを実行すると、こんなエラーが出てしまったのです。
エラー内容(長いので折りたたんでます)
:~/.atom/packages/terminal-plus$ apm rebuild Rebuilding modules ✗ gyp ERR! configure error gyp ERR! stack Error: Python executable "/Applications/Atom.app/Contents/Resources/app/apm/bin/python-interceptor.sh" is v3.6.4, which is not supported by gyp. gyp ERR! stack You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0. gyp ERR! stack at failPythonVersion (/Applications/Atom.app/Contents/Resources/app/apm/node_modules/node-gyp/lib/configure.js:454:14) gyp ERR! stack at /Applications/Atom.app/Contents/Resources/app/apm/node_modules/node-gyp/lib/configure.js:443:9 gyp ERR! stack at ChildProcess.exithandler (child_process.js:197:7) gyp ERR! stack at emitTwo (events.js:106:13) gyp ERR! stack at ChildProcess.emit (events.js:191:7) gyp ERR! stack at maybeClose (internal/child_process.js:877:16) gyp ERR! stack at Socket.<anonymous> (internal/child_process.js:334:11) gyp ERR! stack at emitOne (events.js:96:13) gyp ERR! stack at Socket.emit (events.js:188:7) gyp ERR! stack at Pipe._handle.close [as _onclose] (net.js:498:12) gyp ERR! System Darwin 17.7.0 gyp ERR! command "/Applications/Atom.app/Contents/Resources/app/apm/bin/node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/.bin/node-gyp" "rebuild" gyp ERR! cwd /Users/ユーザー名/.atom/packages/terminal-plus/node_modules/pty.js gyp ERR! node -v v6.9.5 gyp ERR! node-gyp -v v3.4.0 gyp ERR! not ok npm ERR! Darwin 17.7.0 npm ERR! argv "/Applications/Atom.app/Contents/Resources/app/apm/bin/node" "/Applications/Atom.app/Contents/Resources/app/apm/node_modules/npm/bin/npm-cli.js" "--globalconfig" "/Users/ユーザー名/.atom/.apm/.apmrc" "--userconfig" "/Users/ユーザー名/.atom/.apmrc" "rebuild" "--runtime=electron" "--target=2.0.5" "--arch=x64" npm ERR! node v6.9.5 npm ERR! npm v3.10.10 npm ERR! code ELIFECYCLE npm ERR! pty.js@0.3.1 install: `node-gyp rebuild` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the pty.js@0.3.1 install script 'node-gyp rebuild'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the pty.js package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp rebuild npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs pty.js npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls pty.js npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /Users/ユーザー名/.atom/packages/terminal-plus/npm-debug.log
見た感じ、Pythonのバージョンの影響…なのかなと思いました。
調べてみると、どうやらnode-gypを利用するにはPython2.5~3.0がインストールされてないといけないようです。
急いで自分のPythonのバージョンを確認してみると…「3.6.4」になってました。
取り急ぎ、pyenvというPythonバージョン管理マネージャを導入し、バージョンを2.7.10へ落とし…。
※pyenvに関する参考記事
再びapm rebuild
。
そうして…無事にインストールすることができました…!!やったー!!
もうめっちゃくっちゃ苦労しました…大変…。
近年のアプリ開発なり便利ツール開発は、既存のAPIの上に作られることが多くなりましたが…。
今回のハマりで、それの弊害を感じた気もします。
やはりこの手法も一長一短あるんですねぇ…。
テーマについて
Atomのテーマについては、デフォルトのOne Darkにしようかと思ったのですが…。
テーマストアでatom-material-uiなんていう超素敵そうなテーマを見つけたのでついついそれに。
テーマ設定後、色々設定を弄ってこんな感じのUIに!
もうめちゃくちゃ素敵…かっこいい!
設定をいじったといっても、大したことはしておらず…。
ほぼデフォルト状態のUIです、この美しいUIがデフォルトなんです!!
もう超最高なのでぜひぜひ…!|д゚*)
※ちなみに弄った設定は、User Interface
のContrasting panels
(1つ1つのパネルの色を若干変える)、Panels cast shadows
(パネルの境界線に影をつける)にチェックを入れ、パネル間の境界線を見やすくしたり…。
Tabs
のStretches tabs
にチェックを入れて、タブ幅を横いっぱいに大きくしたくらいです。
完成!…だが起動時間が…。
ようやっと全てのパッケージカスタマイズが終わり…。
さて起動!…したのですが…。
すっごい重たい…。
調子にのって色んなパッケージ入れてたのが仇になったっぽいです。
試しにAtomにデフォルトで入っている…Atomの起動時間を見れるパッケージ、Timecopで見てみました。
やっぱりたくさんパッケージ入れるとそれだけ時間を食っちゃうみたいですね…気をつけないと。
あと、Atomにデフォルトで入っているパッケージの中にも時間を食っちゃうものが見られます。
これは…Atomのデフォルトパッケージの見直しもやっちゃった方が良さそうですね…。
今後について
起動時間の長さはさておき、ひとまずRailsに関する環境構築は出来たので…。
次からはこの環境で実際に開発を!…と思いましたが…。
その前に、Railsを使って何ができるのかというのを把握したいなと思います。
Railsに関してある程度の理解が出来てる今なら、RailsのDocumentサイトを読み込むことも可能でしょうし。
また、並行してRailsGuides等の重ためな入門サイトの方も覗いていければと思います。
あと、Atomに関する方は…別記事でまとめようかなと思います。
あんましRailsに関わりない内容になってしまいそうですしね。
それではー。