ubuntu安装最新的rails-4.2.0

时间:2024-01-09 11:19:14

完全按照教程来,可是错误不断,还是边装边baidu吧!

sudo gem install rails 安装了一大坨关联gem之后,终于好了.于是想小试一下身手,新建文件夹rails_test,cd进入,然后输入 rails mybooks,报错!原来是要输入rails new mybooks!开始执行了!结果在bundle xxx时报错鸟!提示xxx gem安装不上,哎,老问题了,官方的资源库不稳定啊!于是到http://rubygems.org/手动搜索gem,下载,然后在本地安装.最后终于包bundle
成功啦!

想用rails --version看一下版本号,咦,怎么还是出错!提示神马找不到getcpwd之类的错,切入报错的.rb代码文件的那一行,竟然是一句貌似不可能出错的语句:Dir.pwd!!!???,哎,全部关掉终端窗口重来吧!这不,重开终端窗口后自己治愈鸟!

好了,可以用rails server启动web服务器鸟!报错!!!!提示神马 rails Could not find a JavaScript runtime!网上弱弱搜了一下,发现要安装:

gem install execjs

gem install therubyracer

2个gem,为毛不会自动安装呢?其中therubyracer还依赖于:libv8和ref两个gem...

安装完毕后,还是不行,再安装nodejs试试吧:

sudo apt-get install nodejs

遂再次安装后,rails server终于欢快的跑起来鸟:

wisy@wisy-ThinkPad-X61:~/src/ruby_src/rails_test/mybooks$ rails server
Warning: Running `gem pristine --all` to regenerate your installed gemspecs (and deleting then reinstalling your bundle if you use bundle --path) will improve the startup performance of Spring.
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-01-01 20:23:03] INFO  WEBrick 1.3.1
[2015-01-01 20:23:03] INFO  ruby 2.1.3 (2014-09-19) [x86_64-linux-gnu]
[2015-01-01 20:23:03] INFO  WEBrick::HTTPServer#start: pid=27726 port=3000

Started GET "/" for 127.0.0.1 at 2015-01-01 20:23:30 +0800
Processing by Rails::WelcomeController#index as HTML
  Rendered /var/lib/gems/2.1.0/gems/railties-4.2.0/lib/rails/templates/rails/welcome/index.html.erb (12.4ms)
Completed 200 OK in 144ms (Views: 105.1ms | ActiveRecord: 0.0ms)

在浏览器输入:http://127.0.0.1:3000,页面蹦出来鸟!(未完待续)