2008年7月8日火曜日

SproutCoreのHelloWorldに挑戦…

追記3
やり直した

追記2
根本として/opt/local/binへのpathを優先していたのが問題か(たぶん.)
…OS付属のrubyで良かった訳だものな.

追記
どうもgemのインストール先がおかしいのかな…
GEM_PATH=/opt/local/lib/ruby/gems としたんだけど
/opt/local/lib/ruby/gems/1.8/(gems) に入っている.

/opt/local/lib/ruby/gems/(gems) に入るべきなんだよね.たぶん.

1.8ってディレクトリができたのが問題か…やっぱりGEMの知識不足だな.




SproutCoreをとりあえず試してみようってだけ.
で試す内容

環境 MacOSX 10.5.3 + DevelperTools + portsの色々 ...(説明になってなくてごめんなさい.)

1.
$ sudo gem install sproutcore


…いきなりつまずく.
$ sudo gem install sproutcore
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require': no such file to load -- sources (LoadError)
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/source_info_cache.rb:6
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/remote_installer.rb:12
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require'
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:112:in `manage_gems'
from /opt/local/bin/gem:10

…orz.

まぁこれは以前と同じ対応で回避.
参考: http://d.hatena.ne.jp/mzp/20080207/gem ほんと感謝.…よくみるとコメント欄に更なる回避法がありました!…これは便利.だけど一般にこういうのってマシンを移ったりした時に思い出せないtipsになるだよね.どうしたもんだろう.

$ sudo -s
bash-3.2# export GEM_PATH=/opt/local/lib/ruby/gems
bash-3.2# gem install sproutcore <- sudo いらないからw.

で,いろいろ依存関係が入る.
途中で聞かれたのは次の3つ.回答はあってるかどうかわからん.

Install required dependency hpricot? [Yn]
Select which gem to install for your platform (i686-darwin9.2.1)
1. hpricot 0.6 (jruby)
2. hpricot 0.6 (mswin32)
3. hpricot 0.6 (ruby)
4. hpricot 0.5 (ruby)
5. hpricot 0.5 (mswin32)
6. Skip this gem
7. Cancel installation

3?

Install required dependency mongrel? [Yn]
Select which gem to install for your platform (i686-darwin9.2.1)
1. mongrel 1.1.5 (ruby)
2. mongrel 1.1.5 (x86-mswin32-60)
3. mongrel 1.1.5 (java)
4. mongrel 1.1.4 (x86-mswin32-60)
5. mongrel 1.1.4 (ruby)
6. mongrel 1.1.4 (java)
7. Skip this gem
8. Cancel installation

1?

Install required dependency fastthread? [Yn]
Select which gem to install for your platform (i686-darwin9.2.1)
1. fastthread 1.0.1 (mswin32)
2. fastthread 1.0.1 (ruby)
3. fastthread 1.0.1 (i386-mswin32)
4. Skip this gem
5. Cancel installation

2?


$ sproutcore hello_world

でまたつまずく.

$ sproutcore hello_world
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:304:in `report_activate_error': Could not find RubyGem sproutcore (> 0) (Gem::LoadError)
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:238:in `activate'
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:76:in `active_gem_with_options'
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:50:in `gem'
from /opt/local/bin/sproutcore:15

…orz.

sudoを使うとサックり動く.
$ sudo sproutcore hello_world
Password:
create
create clients
create frameworks
create lib
create public
create log
create README
create sc-config
dependency client
exists clients
create clients/hello_world
create clients/hello_world/english.lproj
create clients/hello_world/core.js
create clients/hello_world/english.lproj/body.css
create clients/hello_world/english.lproj/body.rhtml
create clients/hello_world/english.lproj/strings.js
create clients/hello_world/main.js
readme ../README
Your new SproutCore client application has been created. To access your application, just start sc-server and visit your client name in the web browser.

If you want to change the deployment settings for your application edit the sc-config file to get started.

当然(?)ownerはroot.

3.
とりあえずそのまま.
$ cd hello_world
$ sc-server

当然(?)…
$ sc-server
/opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:304:in `report_activate_error': Could not find RubyGem sproutcore (> 0) (Gem::LoadError)
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:238:in `activate'
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:76:in `active_gem_with_options'
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems.rb:50:in `gem'
from /opt/local/bin/sc-server:15


ってことで
$ sudo sc-server
/opt/local/lib/ruby/gems/1.8/gems/sproutcore-0.9.13/lib/sproutcore/merb/bundle_controller.rb:7: warning: already initialized constant NO_BODY_METHOD
Loading SproutCore bundles in /Users/satoshi/hello_world
Running SproutCore Build Tools v0.9.13
Welcome to SproutCore
~ Not Using Sessions
~ Using Mongrel adapter


4.
ではアクセスしてみよう.
http://localhost:4020/hello_world

…できた.


まぁどこかでchownしてあげればいいんだと思うんだけど…まぁ動いたよってことでw.

さて,to doには'Add a model', 'Add a controller'ってあるし, 'Edit engilsh.lproj/body.rhtml'ってのもあるから発想のベースはrailsなんですね.(それも知らずに試したw.)

0 件のコメント: