安装Rails 4.0 beta
2012年12月16日 21:56
首先当然要按照先前的《Fedora / Debian 用 RVM 安装 Ruby on Rails 最新版本》先安装RVM和Ruby 1.9.3,Rails 3.2.9(Ruby至少依赖到1.9.3哦,至于安装Rails 3.2.9,是因为似乎Rails 4.0的部分组件依然在依赖3.2.9的Rails组件,挺奇怪的),然后
git clone https://github.com/rails/rails.git
下载rails源码,接着,运行一次
bundle install
安装所有依赖的gem(务必保证所有gem都要安装成功),接着运行
ruby install.rb 4.0.0.beta
额,理论上这样安装应该是成功的,但是实际上当我运行install.rb的时候,却出现了如下错误:
Installing activesupport... Installing activemodel... Installing activerecord... ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dependencies: activerecord requires activerecord-deprecated_finders (= 0.0.1) Installing actionpack... ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dependencies: actionpack requires journey (~> 2.0.0) Installing actionmailer... ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dependencies: actionmailer requires actionpack (= 4.0.0.beta) Installing railties... ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dependencies: railties requires actionpack (= 4.0.0.beta) Installing Rails... ERROR: While executing gem ... (Gem::DependencyError) Unable to resolve dependencies: activemodel requires activesupport (= 3.2.9); rails requires actionpack (= 4.0.0.beta), activerecord (= 4.0.0.beta), actionmailer (= 4.0.0.beta), railties (= 4.0.0.beta); sprockets-rails requires actionpack (>= 3.0)
很奇怪,虽然bundle install完全安装成功了,但是这些明明出现在Gemfile中的gem却没有安装成功,我的解决方案是,额,手动再安装一遍:
cd `rvm gemdir`/bundler/gems for f in `ls`; do cd `pwd`/$f; gem build *.gemspec; gem install *.gem; done
这样就可以了
最后运行下
rails -v # Rails 4.0.0.beta
看到4.0.0 beta就算OK了
不过这样似乎还不足以创建一个新的Rails 4.0 App,你必须再安装好新的coffee-rails 4.0.0.beta和sass-rails 4.0.0.beta,这两个项目你依然需要通过git clone下两个项目的源码,bundle install(在运行这句命令前最好把Gemfile中的几个github项目勾掉,每次都下载一遍实在太慢了),然后gem build *.gemspec,gem install *.gem后才能安装成功。
快尝试创建一个Rails 4的项目吧:
然后在玩玩Live Stream这个Rails 4的新特性,看着SSE数据流连续不断的送到浏览器,帅爆了呢~