2014年4月22日火曜日

Vagrantで楽々開発環境構築(失敗)

遅まきながらVagrantに挑戦してみた。
参考文献↓
VagrantでRails開発環境を整備 (CentOS 6.5/Nginx/mysql5.6/rbenv/ruby2.1.0) - 酒と泪とRubyとRailsと
http://morizyun.github.io/blog/vagrant-centos-nginx-mysql-rbenv/
Winodows環境で試したが、
bundle exec berks install --path site-cookbooks
を実行した際に以下のエラーが表示されたため、下記の対応を実施後、Berksfileを下記の通り修正した
エラーメッセージ↓
>bundle exec berks install --path site-cookbooks
Using mysql (4.1.2)
Using database (2.0.0)
Using nginx (2.4.4)
Using base (0.1.0) at './site-cookbooks/base'
Using mysql56 (0.1.0) at './site-cookbooks/mysql56'
Using ruby_build (0.8.0)
Failed to download 'rbenv' from github: 'fnichol/chef-rbenv' with branch: 'master' over protocol: 'git'
Cookbook 'rbenv' not found in any of the default locations
下記コマンド実行↓
>cd site-cookbooks
>git clone https://github.com/fnichol/chef-rbenv.git
>cd ..
Berksfile変更前↓
site :opscode
cookbook 'mysql'
cookbook 'database'
cookbook 'nginx', path: 'site-cookbooks/nginx'
cookbook 'base', path: 'site-cookbooks/base'
cookbook 'mysql56', path: 'site-cookbooks/mysql56'
cookbook 'ruby_build', github: 'fnichol/chef-ruby_build'
cookbook 'rbenv',  github: 'fnichol/chef-rbenv'
cookbook 'ruby_gem', path: 'site-cookbooks/ruby_gem'
Breksfile変更↓(rbenvをpathに変更)
site :opscode
cookbook 'mysql'
cookbook 'database'
cookbook 'nginx', path: 'site-cookbooks/nginx'
cookbook 'base', path: 'site-cookbooks/base'
cookbook 'mysql56', path: 'site-cookbooks/mysql56'
cookbook 'ruby_build', github: 'fnichol/chef-ruby_build'
cookbook 'rbenv',  path: 'site-cookbooks/chef-rbenv'
cookbook 'ruby_gem', path: 'site-cookbooks/ruby_gem'
と思ったら、なんだかエラーが出て失敗した。
今日はここまでにしておこう。。。
エラーメッセージ↓
[2014-04-22T13:20:41+00:00] DEBUG: Re-raising exception: Chef::Exceptions::CookbookNotFound - Cookbook base not found. If you're loading base from another cookbook, make sure you configure the dependency in your metadata
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/cookbook/cookbook_collection.rb:38:in `block in initialize'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.0.2/lib/ohai/mash.rb:77:in`yield'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.0.2/lib/ohai/mash.rb:77:in`default'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.0.2/lib/ohai/mash.rb:77:in`default'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:277:in `[]'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:277:in `each_cookbook_dep'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:255:in `add_cookbook_with_deps'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:88:in `block in cookbook_order'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:86:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:86:in `cookbook_order'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:98:in `compile_libraries'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:71:in `compile'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context.rb:88:in `load'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/policy_builder/expand_node_object.rb:73:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:265:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:429:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:213:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:207:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:207:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application.rb:217:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application/solo.rb:221:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application/solo.rb:213:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application/solo.rb:213:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application.rb:67:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:23:in `load'
/usr/bin/chef-solo:23:in `<main>'
[2014-04-22T13:20:41+00:00] ERROR: Running exception handlers
[2014-04-22T13:20:41+00:00] ERROR: Exception handlers complete
[2014-04-22T13:20:41+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2014-04-22T13:20:41+00:00] DEBUG: Chef::Exceptions::CookbookNotFound: Cookbookbase not found. If you're loading base from another cookbook, make sure you configure the dependency in your metadata
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/cookbook/cookbook_collection.rb:38:in `block in initialize'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.0.2/lib/ohai/mash.rb:77:in `yield'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.0.2/lib/ohai/mash.rb:77:in `default'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/ohai-7.0.2/lib/ohai/mash.rb:77:in `default'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:277:in `[]'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:277:in `each_cookbook_dep'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:255:in `add_cookbook_with_deps'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:88:in `block in cookbook_order'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:86:in `each'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:86:in `cookbook_order'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:98:in `compile_libraries'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context/cookbook_compiler.rb:71:in `compile'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/run_context.rb:88:in `load'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/policy_builder/expand_node_object.rb:73:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:265:in `setup_run_context'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:429:in `do_run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:213:in `block in run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:207:in `fork'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/client.rb:207:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application.rb:217:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application/solo.rb:221:in `block in run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application/solo.rb:213:in `loop'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application/solo.rb:213:in `run_application'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/lib/chef/application.rb:67:in `run'
/opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.12.2/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:23:in `load'
/usr/bin/chef-solo:23:in `<main>'
[2014-04-22T13:20:41+00:00] ERROR: Cookbook base not found. If you're loading base from another cookbook, make sure you configure the dependency in your metadata
[2014-04-22T13:20:41+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Chef never successfully completed! Any errors should be visible in the output above. Please fix your recipes so that they properly complete.

2014年4月14日月曜日

WindowsでSublime TextのRubyTestの実行に失敗する場合の対処法

Windows環境でRailsTutorialに沿って進めていたら3.6.4 Tests inside Sublime Textで躓きました。

Build Consoleに下記が表示されていました。

[Decode error - output not utf-8]
[Finished in 0.1s with exit code 1]
[cmd: [' bundle exec rspec spec\\requests\\static_pages_spec.rb -l50']]
[dir: C:\***\sample_app]
[path: C:****;]

いろいろ試行錯誤した結果、run_ryby_test.pyの下記(201行目あたり)を修正することで、何とか実行できるっぽい?ことが判明。

self.view.window().run_command("exec", {
"cmd": [command],
"shell": True,
"working_dir": working_dir,
"file_regex": r"([^ ]*\.rb):?(\d*)"
})

self.view.window().run_command("exec", {
"cmd": command, # ←[]除去
"shell": True,
"working_dir": working_dir,
"file_regex": r"([^ ]*\.rb):?(\d*)"
})

#最初はメッセージに「Decode error」と表示されていたから
エンコードの問題かと思って下記のようにしてみたのですが、

self.view.window().run_command("exec", {
"cmd": [command],
"shell": True,
"working_dir": working_dir,
"file_regex": r"([^ ]*\.rb):?(\d*)",
"encoding": "cp932"
})

こうすると、コンソールに「指定されたパスが見つかりません。」と出たので、
commandが間違っているようだとわかりました。

ちなみに、Windows環境でListing 3-34は「# gem 'win32console', '1.3.2'」のコメントアウトをはずすとエラーになるっぽいです。Ruby2.0では、Win32consoleは必要ないみたいです。

#参考:Error “cannot load such file — 2.0/Console_ext” running unit tests in RubyMine

#この問題は一応本家のrailstutorialに報告してみたので、もしかしたらそのうち修正されているかもしれません。

2014年4月7日月曜日

namazuに代わるサイト内全文検索ツールを模索中

あまりしっくりくるものが見つからない。 fessはどうだろうか。 専用サーバーを用意しないと重いかな。そうすると冗長化とかややこしいな。。 elasticsearchとかsolr+nutch?はどうなんだろうか。かなり作り込みが必要になりそうで気が引けるなぁ。