CentOSのRails3環境で、「opensslが読み込めん!」と怒られたら?

どんな例外を吐く?

[twitter@centos twitter_trend]$ ./script/rails server
/home/twitter/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_ #### これは別件なんだけど、気になる。。。
=> Booting WEBrick
=> Rails 3.1.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/twitter/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require': no such file to load -- openssl (LoadError)
	from /home/twitter/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `block in require'
	from /home/twitter/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `block in load_dependency'
	from /home/twitter/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:640:in `new_constants_in'
	from /home/twitter/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:223:in `load_dependency'
	from /home/twitter/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:240:in `require'
 (snip)

参考ページに寄れば

rvm pkg install openssl
rvm remove 1.9.2
rvm install 1.9.2 --with-openssl-dir=$HOME/.rvm/usr


なぬ? opensslはオレオレビルドにして、

それをリンクするようにrubyをビルドしなおせだと?

やってみた

[twitter@centos twitter_trend]$ rvm pkg install openssl
Fetching openssl-0.9.8n.tar.gz to /home/twitter/.rvm/archives
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3681k  100 3681k    0     0   524k      0  0:00:07  0:00:07 --:--:--  719k
Extracting openssl-0.9.8n.tar.gz to /home/twitter/.rvm/src
Configuring openssl in /home/twitter/.rvm/src/openssl-0.9.8n.
Compiling openssl in /home/twitter/.rvm/src/openssl-0.9.8n.
Installing openssl to /home/twitter/.rvm/usr
[twitter@nanakanet twitter_trend]$ rvm remove 1.9.2
Removing /home/twitter/.rvm/src/ruby-1.9.2-p290...
Removing default ruby interpreter
Removing /home/twitter/.rvm/rubies/ruby-1.9.2-p290...
Removing ruby-1.9.2-p290 aliases...
Removing ruby-1.9.2-p290 wrappers...
Removing ruby-1.9.2-p290 environments...
Removing ruby-1.9.2-p290 binaries...
[twitter@centos twitter_trend]$ rvm install 1.9.2 --with-openssl-dir=$HOME/.rvm/usr
Installing Ruby from source to: /home/twitter/.rvm/rubies/ruby-1.9.2-p290, this may take a while depending on your cpu(s)...

ruby-1.9.2-p290 - #fetching 
ruby-1.9.2-p290 - #extracting ruby-1.9.2-p290 to /home/twitter/.rvm/src/ruby-1.9.2-p290
ruby-1.9.2-p290 - #extracted to /home/twitter/.rvm/src/ruby-1.9.2-p290
Fetching yaml-0.1.4.tar.gz to /home/twitter/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /home/twitter/.rvm/src
Configuring yaml in /home/twitter/.rvm/src/yaml-0.1.4.
Compiling yaml in /home/twitter/.rvm/src/yaml-0.1.4.
Installing yaml to /home/twitter/.rvm/usr
ruby-1.9.2-p290 - #configuring 
ruby-1.9.2-p290 - #compiling 
ruby-1.9.2-p290 - #installing 
Removing old Rubygems files...
Installing rubygems-1.8.10 for ruby-1.9.2-p290 ...
Installation of rubygems completed successfully.
ruby-1.9.2-p290 - adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
ruby-1.9.2-p290 - #importing default gemsets (/home/twitter/.rvm/gemsets/)
Install of ruby-1.9.2-p290 - #complete 
[twitter@centos twitter_trend]$ 


うまく動くか、wktkするー

動かしてみた

[twitter@centos twitter_trend]$ ./script/rails server
<internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- bundler/setup (LoadError)
	from <internal:lib/rubygems/custom_require>:29:in `require'
	from /home/twitter/twitter_trend/config/boot.rb:6:in `<top (required)>'
	from <internal:lib/rubygems/custom_require>:29:in `require'
	from <internal:lib/rubygems/custom_require>:29:in `require'
	from ./script/rails:5:in `<main>'
[twitter@centos twitter_trend]$


Oops!

気を取り直して

[twitter@centos twitter_trend]$ rvm use 1.9.2 --default
Using /home/twitter/.rvm/gems/ruby-1.9.2-p290
[twitter@centos twitter_trend]$ gem list

*** LOCAL GEMS ***

actionmailer (3.1.0)
actionpack (3.1.0)
activemodel (3.1.0)
activerecord (3.1.0)
activeresource (3.1.0)
activesupport (3.1.0)
addressable (2.2.6)
ansi (1.3.0)
arel (2.2.1)
bcrypt-ruby (3.0.1)
builder (3.0.0)
bundler (1.0.21)
coffee-rails (3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.1.2)
erubis (2.7.0)
execjs (1.2.9)
faraday (0.7.4)
faraday_middleware (0.7.0)
hashie (1.1.0)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.14)
mail (2.3.0)
mime-types (1.16)
multi_json (1.0.3)
multi_xml (0.4.1)
multipart-post (1.1.3)
mysql (2.8.1)
mysql2 (0.3.7)
polyglot (0.3.2)
rack (1.3.4)
rack-cache (1.0.3)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.0)
railties (3.1.0)
rake (0.9.2)
rdoc (3.9.4)
sass (3.1.8)
sass-rails (3.1.4)
simple_oauth (0.1.5)
sprockets (2.0.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
turn (0.8.2)
twitter (1.7.2)
tzinfo (0.3.30)
uglifier (1.0.3)
[twitter@centos twitter_trend]$ ./script/rails server
/home/twitter/.rvm/gems/ruby-1.9.2-p290/gems/rack-1.3.4/lib/rack/backports/uri/common_192.rb:53: warning: already initialized constant WFKV_ #### 別件だけど、めちゃ気になる
=> Booting WEBrick
=> Rails 3.1.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-10-02 22:17:22] INFO  WEBrick 1.3.1
[2011-10-02 22:17:22] INFO  ruby 1.9.2 (2011-07-09) [i686-linux]
[2011-10-02 22:17:22] INFO  WEBrick::HTTPServer#start: pid=27798 port=3000


動いたー!

でも、ここに辿りつく前までに、rubygemsを入れるためだけにrubyをオレオレビルドしたり、
rvmを入れるためだけにgitをオレオレビルドしたり、CentOS 5.xは古すぎて身体に良くないですw

やっぱり、「Ext JS入門―リッチUIなWebサイトをつくるAjaxフレームワーク 」をぽちって見る

Ext JS入門―リッチUIなWebサイトをつくるAjaxフレームワーク

Ext JS入門―リッチUIなWebサイトをつくるAjaxフレームワーク

なんか、レビューに「最初の数時間しか使えない本」とか書かれていますが、

WEB+DB PRESS Vol.54

WEB+DB PRESS Vol.54

の記事が疾走すぎたので、最初の数時間のハードルを超えるためにポチります。
マーケットプレイスで1,600円程度で買えるし諦めます。orz

Rails3に移行するための最初の一歩

shingo@ubuntu:~/Aptana RadRails Workspace/twitter$ ./search6.rb 
DEPRECATION WARNING: require "activerecord" is deprecated and will be removed in Rails 3. Use require "active_record" instead. (called from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.14/lib/activerecord.rb:2)

えーと、requireする名前が変わってるのを完全に忘れてた。orz

WEB+DB PRESSのバックナンバー読みながらやらないと、しょーもない間違いやらかすなー。

Rails2の最新とRails3の最新を両方入れて、ようやく原因が判明した俺ってバカ??

ExtJSの入門記事でWEB+DB PRESSのバックナンバーをポチってみた

現在カスタマイズ中のとある機器のWeb UIがExtJJSで書かれてる。とっかかりが欲しいのでWEB+DB PRESSのバックナンバーで特集してたみたいなので、ポチって見た。

WEB+DB PRESS Vol.54

WEB+DB PRESS Vol.54

あと1冊、同時期に書かれた入門本があるようだけど、レビューがいまいちなので取り敢えず見送り。

UbuntuでRails3のexecjsが例外を投げたら

どんなエラー?

こんな具合に例外を投げます。

$ ./script/rails server
/usr/lib/ruby/gems/1.8/gems/execjs-1.2.7/lib/execjs/runtimes.rb:47:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
	from /usr/lib/ruby/gems/1.8/gems/execjs-1.2.7/lib/execjs.rb:5
	from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require'
	from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee_script.rb:1
	from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require'
	from /usr/lib/ruby/gems/1.8/gems/coffee-script-2.2.0/lib/coffee-script.rb:1
	from /usr/lib/ruby/gems/1.8/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1:in `require'
	from /usr/lib/ruby/gems/1.8/gems/coffee-rails-3.1.1/lib/coffee-rails.rb:1
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:68:in `require'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `each'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:66:in `require'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `each'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler/runtime.rb:55:in `require'
	from /usr/lib/ruby/gems/1.8/gems/bundler-1.0.18/lib/bundler.rb:120:in `require'
	from /home/shingo/Aptana RadRails Workspace/twitter_bot/config/application.rb:7
	from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:52:in `require'
	from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:52
	from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:49:in `tap'
	from /usr/lib/ruby/gems/1.8/gems/railties-3.1.0/lib/rails/commands.rb:49
	from ./script/rails:6:in `require'
	from ./script/rails:6
$

どう対処するの?

エラーメッセージにある https://github.com/sstephenson/execjs を見れば、8つある"ExecJS supports these runtimes"のどれかを入れれば良いらしい。最初、therubyracerを入れたがダメだった。

それで、Node.jsを入れてあげる。

$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:chris-lea/node.js
$ sudo apt-get update
$ sudo apt-get install nodejs

これで平和に動きます。

$ ./script/rails server
=> Booting WEBrick
=> Rails 3.1.0 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-09-20 11:51:40] INFO  WEBrick 1.3.1
[2011-09-20 11:51:40] INFO  ruby 1.8.7 (2010-08-16) [i686-linux]
[2011-09-20 11:51:45] INFO  WEBrick::HTTPServer#start: pid=9112 port=3000

"●●●でPerl"してみる

このときのスライドは?

どんな感じでしゃべったの?


なお、

あくまでも、昔話ネタのLTなので*1アジェンダとかまとめとか一切ありません。


そこの所、ご理解とご協力を強制します!

しかしながら、

せっかくじへい(@jihei)さんに撮影していただけたんだから、撮影者には真正面の特等席をご用意すべきだったと要反省。。。orz

*1:しかもネタバレ注意

Ubuntu 11.04でOracle JDK/JREを入れる

参考にしたエントリの通りコマンドを打つ。バージョンは違うけど。

$ sudo add-apt-repository 'deb http://archive.canonical.com/ natty partner'
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk

前はSynapticから入れた気がするんだけど、何で今回は検索で見つからなかったんだろ?