mysql,Linux,HighPerformance,ruby on Rails

2010年2月25日星期四

使用rvm体验rails3-pre版

作为rails爱好者,现在rails3呼之欲出。但总归没有出来。想玩一玩,怎么搞呢。看下面:

1. Install Ruby Version Manager
 $ sudo gem install rvm $ rvm-install
2. Install Ruby 1.9.2 HEAD
 $ rvm install 1.9.2-head -C --enable-shared,--with-readline-dir=/opt/local
注意:readline目录你需要自己指定

$ rvm list rubies (执行此命令知道有哪些可以跑。)
 
rvm Rubies

=> ruby-1.9.2-head [ i386 ]

System Ruby

   system [ i386 ]

这行就是指定确认ruby runtime
$ rvm  ruby-1.9.2-head --default
最后验证一下:
 $ ruby -v ruby 1.9.2dev (2010-02-25 trunk 26759) [x86_64-darwin10.2.0]
3. 给gem当然创建一个集合,把这个beta版的所有依赖gem安装在这里,不合其它ruby runtime混在一起:
 $ rvm gems create rails3beta $ rvm 1.9.2-head%rails3beta
 $ gem install sqlite3-ruby
$ gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
$ gem install --no-rdoc --no-ri tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
$ gem install --no-rdoc --no-ri rails --pre
注意mysql_config的路径要配置成自己的。
最后成果如下:
 $ ruby -v   ruby 1.9.2dev (2010-02-25 trunk 26759) [x86_64-darwin10.2.0] $ rails --version   Rails 3.0.0.beta $ gem list   *** LOCAL GEMS ***  	abstract (1.0.0) 	actionmailer (3.0.0.beta) 	actionpack (3.0.0.beta) 	activemodel (3.0.0.beta) 	activerecord (3.0.0.beta) 	activeresource (3.0.0.beta) 	activesupport (3.0.0.beta, 2.3.5) 	arel (0.2.1) 	builder (2.1.2) 	bundler (0.9.7) 	erubis (2.6.5) 	i18n (0.3.3) 	mail (2.1.3) 	memcache-client (1.7.8) 	mime-types (1.16) 	mysql (2.8.1) 	rack (1.1.0) 	rack-mount (0.6.0, 0.4.7) 	rack-test (0.5.3) 	rails (3.0.0.beta) 	railties (3.0.0.beta) 	rake (0.8.7) 	sqlite3-ruby (1.2.5) 	text-format (1.0.0) 	text-hyphen (1.0.0) 	thor (0.13.3) 	tzinfo (0.3.16)
最后注意:
之后想使用这个rails3+1.9.2dev的完整环境,应该使用这个命令:
rvm 1.9.2-head%rails3beta
如果想返回系统本身的ruby
rvm system

这些都在rvm的手册有详细说明,不过想掌握,还是需要花时间看一会的。记住上面两条就已经可以应付90%情况。

最后你就可以创建一个rails3-pre
$ rails blog; cd blog
$ rails server

会出错:
 
Your bundle is complete!
run rails generate rspec:install from "."
/usr/lib/ruby19/gems/1.9.1/gems/bundler-0.9.8/lib/bundler/rubygems_ext.rb:20:in `alias_method': undefined method `dependencies' for class `Gem::Specification' (NameError)
from /usr/lib/ruby19/gems/1.9.1/gems/bundler-0.9.8/lib/bundler/rubygems_ext.rb:20:in `<class:Specification>'
from /usr/lib/ruby19/gems/1.9.1/gems/bundler-0.9.8/lib/bundler/rubygems_ext.rb:9:in `<module:Gem>'
from /usr/lib/ruby19/gems/1.9.1/gems/bundler-0.9.8/lib/bundler/rubygems_ext.rb:6:in `<top (required)>'
from /usr/lib/ruby19/gems/1.9.1/gems/bundler-0.9.8/lib/bundler.rb:4:in `require'
from /usr/lib/ruby19/gems/1.9.1/gems/bundler-0.9.8/lib/bundler.rb:4:in `<top (required)>'
from /home/hal/dm_rails3_app/config/boot.rb:6:in `require'
from /home/hal/dm_rails3_app/config/boot.rb:6:in `rescue in <top (required)>'
from /home/hal/dm_rails3_app/config/boot.rb:2:in `<top (required)>'
from /home/hal/dm_rails3_app/script/rails:9:in `require'
from /home/hal/dm_rails3_app/script/rails:9:in `<main>'

 郁闷吧。搞到这时就郁闷了.没关系,只要注释这行代码:
 
/rubygems_ext.rb:20
运行一切OK。

__DONE__

--
tommy xiao
E-mail: xiaods(AT)gmail.com

没有评论:

发表评论