Ruby 2.0.0とWindows7 64bitとRails4.1の相性が悪すぎるのか。。
最近Railsを勉強しているのだが、セットアップでつまってしまったので備忘録。。。。
環境
起こった現象
セットアップ時
WindowsではDevKitがないとrailsのインストールができない。。。
下記からダウンロード Downloads
Pathが通ってるrubのフォルダに展開する
set PATH=D:\ruby\ruby200\bin;%PATH% start "ruby 2.0.0 x64" "%SystemRoot%\System64\cmd.exe"
ruby>ruby -v ruby 2.0.0p0 (2013-02-24) [x64-mingw32] DevKit の設定 D\ruby>cd DevKit472 D:\ruby\DevKit472>ruby dk.rb init D:\ruby\DevKit472\config.yml を編集 --- - D:/ruby/ruby200 を追加 D:\ruby\DevKit472>ruby dk.rb install
railsプロジェクト作成時
Railsプロジェクトを立ち上げてみる
C:\Users\hideto.masuoka\repos\rails\data\railbook>rails new railbook DL is deprecated, please use Fiddle Using rake 10.3.2 Using i18n 0.6.9 Using json 1.8.1 Using minitest 5.3.5 Using thread_safe 0.3.4 Using tzinfo 1.2.1 Using activesupport 4.1.1 Using builder 3.2.2 Using erubis 2.7.0 Using actionview 4.1.1 Using rack 1.5.2 Using rack-test 0.6.2 Using actionpack 4.1.1 Using mime-types 1.25.1 Using polyglot 0.3.5 Using treetop 1.4.15 Using mail 2.5.4 Using actionmailer 4.1.1 Using activemodel 4.1.1 Using arel 5.0.1.20140414130214 Using activerecord 4.1.1 Using coffee-script-source 1.7.0 Using execjs 2.2.1 Using coffee-script 2.2.0 Using thor 0.19.1 Using railties 4.1.1 Using coffee-rails 4.0.1 Using hike 1.2.3 Using multi_json 1.10.1 Using jbuilder 2.1.1 Using jquery-rails 3.1.1 Using bundler 1.6.3 Using tilt 1.4.1 Using sprockets 2.11.0 Using sprockets-rails 2.1.3 Using rails 4.1.1 Using rdoc 4.1.1 Using sass 3.2.19 Using sass-rails 4.0.3 Using sdoc 0.4.0 Using sqlite3 1.3.9 Using turbolinks 2.2.2 Using uglifier 2.5.1 Your bundle is complete! Use bundle show [gemname] to see where a bundled gem is installed.
うまくいったのでrails serverを立ち上げようといたら。。。
C:\Users\hideto.masuoka\repos\rails\data\railbook>rails server => Booting WEBrick => Rails 4.1.8 application starting in development on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server Exiting C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:182:in `rescue in create_default_data_source': No source of timezone d ta could be found. (TZInfo::DataSourceNotFound) Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error. from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:179:in `create_default_data_source' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:40:in `block in get' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:39:in `synchronize' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/data_source.rb:39:in `get' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone.rb:629:in `data_source' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone.rb:92:in `get' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone_proxy.rb:67:in `real_timezone' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone_proxy.rb:30:in `period_for_utc' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/tzinfo-1.2.2/lib/tzinfo/timezone.rb:549:in `current_period' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/core_ext/object/try.rb:45:in `public_send' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/core_ext/object/try.rb:45:in `try' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/values/time_zone.rb:223:in `utc_offset' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/values/time_zone.rb:396:in `block in []' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/values/time_zone.rb:396:in `tap' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/values/time_zone.rb:396:in `[]' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/core_ext/time/zones.rb:60:in `find_zone!' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-4.1.8/lib/active_support/railtie.rb:20:in `block in <class:Railtie>' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `instance_exec' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:30:in `run' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:55:in `block in run_initializers' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in `each' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component' from C:/Ruby200-x64/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/initializable.rb:54:in `run_initializers' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/application.rb:300:in `initialize!' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config/environment.rb:5:in `<top (required)>' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config.ru:3:in `require' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config.ru:3:in `block in <main>' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config.ru:in `new' from C:/Users/hideto.masuoka/repos/rails/data/railbook/config.ru:in `<main>' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/server.rb:50:in `app' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/server.rb:130:in `log_to_stdout' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/server.rb:67:in `start' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:81:in `block in server' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `tap' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:76:in `server' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands/commands_tasks.rb:40:in `run_command!' from C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-4.1.8/lib/rails/commands.rb:17:in `<top (required)>' from bin/rails:4:in `require' from bin/rails:4:in `<main>'
原因を調べても解決方法が出てこない、、 つらい。。。
参考
Jubatusハッカソンを見に行った。
Jubatusハッカソンのお手伝いをしてきました。
(お手伝いと行っても会場のお片付けぐらいしかしてませんが....)
Jubatusハッカソンとは
Jubatusハッカソンやります!丸一日かけてJubatusで何か作ってプレゼンして頂きます。放置してたデータ活用アイデア・デモ案、この機会に具現化しませんか? http://t.co/Skl7kFErty #jubatus_hackathon
— Jubatus (@JubatusOfficial) 2014, 9月 2
こんなイベントです。
賞品は....豪華!!! 1位 GoPro ウェアラブルカメラ HERO3 ホワイトエディション 2位 Leap Motion 小型モーションコントローラー 3位 Google Chromecas
最終発表
気になったり、スライドがあがっているものをまとめてみました。
和布蕪
相撲をもっと楽しむためのサービスをつくる
どんなサービス?
- お気に入りの力士と似た力士を探す
- Jubarecommenderを使う
- 面白い取り組みを探す
- jubaanomalyを使って異常度を計算する
予想通り(?)舞の海がめっちゃ異常値が高かったw
チームでやってるだけあって完成度の高いプレゼンテーションとサービスクオリティでしたー
ぜひ触ってみたいなと思いました。
草々
aoi_sora_siroi_tsuki (@aoi_sora_siroi_) | Twitterさん
Wikipediaから類似植物図鑑のWebサービスを構築して公開。 Jumbotron Template for Bootstrap
jubatus以前に、EC2もpythonもわからないのでやばい・・>_< 勉強にはなるなぁ・・。アプリまで行かない・・orz とりあえずEC2だと、python webはboto使っておけばいいのかなぁ・・。
— aoi_sora_siroi_tsuki (@aoi_sora_siroi_) 2014, 10月 3
深夜1時にこんなツイートをしていたのに、ちゃんとサービスまで持って行っているところがすごい..
大杉さん
トランプを画像認識する。Google Glassを使って、ポーカーの手を最適化することを想定している。
9とか10を認識するのは難しい。グレースケールで認識しているので、色の判別を活かせてないなど、まだまだ改善してもっとよくする知見が得られた。
dera
jubarecommenderを使ってtweetからniconicoやpixivで趣味嗜好が似てるユーザーをピックアップ。 niconicoやpixivやらないからはっきりわからないが、結果を見る限りなんとなく似ている気がした。
大友翔一(@GeoJackass)
Jubatus Hackathon by Otomo Shoichi
釣果から特徴量をとり、どういう傾向があるかを調べた。
新しい知見が得られたらしい(釣りに興味がないので、知見が理解できず...)
ijust3
niconicoへの投稿動画のトレンド検知(@Jubatus hackathon 2014/10/03)
niconico動画で最近盛り上がったタグを、最近の動画と過去も含めた動画を判別するJubaclassifierモデルのjubadump結果で求める。1回しか使われてないタグのスコアが高くなりすぎる傾向あったがそれなりの結果
Paper
Connpass というイベント支援サイトのイベント情報をレコメンドするサイトです。あとで読むサービスの Pocket のデータを元に、レコメンドするイベントを決めるので、本当に興味があるイベントのみをレコメンドする仕組み
#jubatus_hackathon Paperさんのサービスを使って私のPocket登録記事からレコメンドされた勉強会! クラウドでJavaでGithubでBitcoinでほげほげ、な感じ? pic.twitter.com/kW4ifoMjXw
— ヒド ショウヘイ (@sla) 2014, 10月 4
Jubatusハッカソンに参加して、イベントのレコメンデーションを作ってみた。 - よしだのブログ
なかなか面白そうなサービスになりそうな気がした
びア部
似てそうで似てないものをレコメンドする。
たしかに新たな知見が得られてよさそうだと思った
コアプライス
ECレコメンドの仕組みの中にJubatusを使う例。機械学習がおまかせで、あとは前処理の工夫に集中できる!!とおっしゃっていた。
Jubatus Hackathon #1 // Speaker Deck
すぐに使えそうな例だなとー思った。
nushio
@nusioさん
アセンブラ高速化のための並列実行優先度を求めるためにエミュレータ実行結果をJubatusで回帰、モデルをjubadumpして重みの降順ソートを優先度にしたら逆問題が解けたという話。 たった2日で論文がかける内容をつくれる@nusioさすがです
ところてん(仮)
フルスタックグロースデータサイエンティスト@tokorotenさんが実データ実験。ECサイトのある最適化にJubatusを使って現行のscikit-learn決定木モデルと比較、データが多ければすぐいけそう
DAISUKE AMANO on Twitter: "優勝!本番データに突っ込んでmongo殺したのがよかった!笑 #jubatus_hackathon"
本番環境のMongoを殺すなど果敢にトライされていたのですばらし
感想
全体としてrecommenderが多い印象だった。 たしかに問題設定が明確じゃないとrecommenderが使いやすいですよね...
ただ問題設定が明確なチームの発表がすごくわかりやすかった!!
Postgre SQLを使ってみる(ユーザー作成)
前回インストールしたので、今回は色々使ってみる
scientific linux6.5にyumでPostgre SQLをいれてみる - Anything can happen
SQLというよりDBAよりのことを書いてみる
ユーザー作成
- まずはロールを作成
/usr/pgsql-9.3/bin/createuser --superuser --createrole --password dba
- 次にDBを作成
/usr/pgsql-9.3/bin/createdb --owner=dba --no-password dba
これでDBAユーザーのデータベースができました。
引数一覧
オプション | 説明 |
---|---|
username | 作成するPostgreSQLユーザの名前を指定します。この名前は、そのPostgreSQLインストレーションの中で一意でなければなりません。 |
-s or --superuser | スーパーユーザになります。 |
-s or --superuser | スーパーユーザになりません。 (デフォルト) |
-d or --createdb | 新しいユーザに対してデータベースの作成を許可します。 |
-D or --no-createdb | 新しいユーザに対してデータベースの作成を禁止します。 これがデフォルトです。 |
-r or --createrole | 新しいユーザに対して新しいロールの作成を許可します。(つまり、このユーザはCREATEROLE権限を持つことになります。) |
-R or --no-createrole | 新しいユーザに対して新しいロールの作成を禁止します。 これがデフォルトです。 |
-l or --login | 新しいユーザに対してログインを許可します。(つまり、このユーザ名をセッション起動時のユーザ識別子として使用することができます。) これがデフォルトです。 |
-L or --no-login | 新しいユーザに対してログインを禁止します。(ログイン権限を持たないロールはデータベース権限管理という面で有意です。) |
-i or --inherit | 新しいロールは自動的にそのロールがメンバであるロールの権限を継承します。 これがデフォルトです。 |
-I or --no-inherit | 新しいロールは自動的にそのロールがメンバであるロールの権限を継承しません。 |
-c number or --connection-limit number | 新しいユーザの最大接続数を設定します。 デフォルトは無制限です。 |
scientific linux6.5にyumでPostgre SQLをいれてみる
Postgre SQLをインストールする機会があったので、手順をまとめる
環境
- scientific linux 6.5
手順
1.yumで何がはいるか確認
# yum list | grep postgresql
2.postgresqlのパッケージをインストールする
# yum -y install postgresql-server
3.postgresqlの開発版パッケージもインストールする
# yum -y install postgresql-devel
4.rpmをインストールする
# yum -y localinstall http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-sl93-9.3-1.noarch.rpm
とりあえずこれでインストールはdone
パッケージの一覧
パッケージ名 | 主に格納しているもの |
---|---|
postgresql-libs | libpqなどのPostgreSQLのライブラリ群。PostgreSQL以外のパッケージが必要とすることもあります。 |
postgresql | psqlやpg_dumpなどのPostgreSQLのクライアントユーティリティ |
postgresql-server | initdbやpg_ctlなどのPostgreSQLのサーバユーティリティ。DBMSサーバとして必要な機能はこれに含まれています。 |
postgresql-contrib | pgbenchやpg_statstatementなどのPostgreSQLのcontribモジュール。 |
postgresql-devel | PostgreSQLのヘッダやpg_configなどの開発用モジュール。 |
postgresql-doc | PostgreSQLのドキュメント。 |
postgresql-test | PostgreSQLのリグレッションテスト用モジュール。 |
つぎは、ユーザー作成等々
参考ページ
MacPortsのアンインストール
Homebrewを入れたので、MacPortsをアンインストールする (brew doctorをったら怒られた。。)
公式ガイドを参考にやってみる
sudo port -fp uninstall installed
設定ファイルを削除
$ sudo rm -rf \ /opt/local \ /Applications/DarwinPorts \ /Applications/MacPorts \ /Library/LaunchDaemons/org.macports.* \ /Library/Receipts/DarwinPorts*.pkg \ /Library/Receipts/MacPorts*.pkg \ /Library/StartupItems/DarwinPortsStartup \ /Library/Tcl/darwinports1.0 \ /Library/Tcl/macports1.0 \ ~/.macports
~/.bash_profileからMacPortsインストール時に追加した以下のPATHを削除。
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
これでOK
参考サイト
homebrewを入れ直してみた
DjangoをMacにいれるためにhomebrewを入れ直してみた
mac環境
OS X (10.9.2)
なぜ入れ直そうとしたか?
brew doctorを実行するとエラーが出まくっていたので、環境が壊れている気がしたので、入れ直そうと思った。
$ 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!
参考サイト
homebrew環境の構築。パッケージ管理ナシ環境はもう限界 - aremokoremo
やっとこと
本当に参考サイトと変わらないですが。。。
まずhomebrewがはいっているか確認
$ brew --version 0.9.5
うーんはいってる。
とりあえず参考サイトみながら削除
$ cd `brew --prefix` $ sudo rm -rf Cellar $ brew prune $ sudo rm `git ls-files` $ sudo rmdir Library/Homebrew Library/Aliases Library/Formula Library/Contributions $ sudo rm -rf .git $ rm -rf ~/Library/Caches/Homebrew $ sudo rm -rf ~/Library/Logs/Homebrew $ sudo rm -rf /Library/Caches/Homebrew
再インストールを実行
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
うまく行ったと思ったら。。
From https://github.com/Homebrew/homebrew * [new branch] master -> origin/master error: unable to create symlink Library/Aliases/0mq (Permission denied) error: unable to create symlink Library/Aliases/4store (Permission denied) error: unable to unlink old 'Library/Aliases/Secret Rabbit Code' (Permission denied) error: unable to create symlink Library/Aliases/ag (Permission denied) error: unable to create symlink Library/Aliases/alut (Permission denied) error: unable to create symlink Library/Aliases/android (Permission denied)
Permission denied....
sudoを付けたら行けるかと思ってやってみたら
$ sudo ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" Don't run this as root!
ぐぐぐぐ
参考サイトを読み進めると/user/local以下のパーミッションが悪い説
$ ls -l /usr/ drwxrwxr-x 19 root admin 646 9 17 13:29 local drwxr-xr-x 4 root wheel 136 7 2 14:50 standalone
ということで権限を変更
$ sudo chown -R ${USER} /usr/local
もう1回入れようとするとエラーになるので注意
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" It appears Homebrew is already installed. If your intent is to reinstall you should do the following before running this installer again: rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
削除して再度実行したらうまくいった!
vimのクリップボード(set paste)
弊社メンバーから教えてもらったので、メモのためこちらに記載
set paste
一番楽で環境依存や、リモート・ローカルを問わず、ローカル環境のOSのクリップボードの内容を張れる。
:set paste
でペーストモード(auto indent / 入力支援等を一時的にoffにできる)に変更- ペースト
:set nopaste
でペーストモードを抜ける
Tips: on/offのbooleanなsettingに関しては、 :set paste!
のように末尾に!をつけるとtoggleになる。 :set paste
の場合は特に一時的にペーストモード → 即ペーストモード解除を行うので、1.の :set paste!
にしておくと、 3.で↑カーソルキーで履歴を一個さかのぼるだけで入力できるというすごさ。。。
ぼくはこれしか知らなかったがまだまだああるらしい