Ubuntu下使用RVM 安装Rails_Ruby_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > Ruby > Ubuntu下使用RVM 安装Rails

Ubuntu下使用RVM 安装Rails

 2012/3/13 15:28:19  wen_pp  程序员俱乐部  我要评论(0)
  • 摘要:使用Ubuntu版本:11.041.安装RVMbash<<(curl-shttps://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)2.安装RubyRVM安装完成后可以使用rvmrequirements命令查看安装可选项。执行rvminstall1.9.2ubuntu:~$rvminstall1.9.2Fetchingyaml-0.1.4.tar.gzto/home/wenpeng/
  • 标签:Ubuntu 使用 rails 安装 RVM
使用Ubuntu版本:11.04
1.安装RVM
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)

2.安装Ruby
RVM安装完成后可以使用
rvm requirements
命令查看安装可选项。
执行rvm install 1.9.2
ubuntu:~$ rvm install 1.9.2
Fetching yaml-0.1.4.tar.gz to /home/wenpeng/.rvm/archives
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  460k  100  460k    0     0  51442      0  0:00:09  0:00:09 --:--:-- 63694
Extracting yaml-0.1.4.tar.gz to /home/wenpeng/.rvm/src
Configuring yaml in /home/wenpeng/.rvm/src/yaml-0.1.4.
Compiling yaml in /home/wenpeng/.rvm/src/yaml-0.1.4.
Installing yaml to /home/wenpeng/.rvm/usr
Installing Ruby from source to: /home/wenpeng/.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 - #downloading ruby-1.9.2-p290, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 8604k  100 8604k    0     0  24844      0  0:05:54  0:05:54 --:--:-- 30418
ruby-1.9.2-p290 - #extracting ruby-1.9.2-p290 to /home/wenpeng/.rvm/src/ruby-1.9.2-p290
ruby-1.9.2-p290 - #extracted to /home/wenpeng/.rvm/src/ruby-1.9.2-p290
ruby-1.9.2-p290 - #configuring 
ruby-1.9.2-p290 - #compiling 
ruby-1.9.2-p290 - #installing 
Retrieving rubygems-1.8.17
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  246k  100  246k    0     0  50303      0  0:00:05  0:00:05 --:--:-- 60119
Extracting rubygems-1.8.17 ...
Removing old Rubygems files...
Installing rubygems-1.8.17 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/wenpeng/.rvm/gemsets/)
Install of ruby-1.9.2-p290 - #complete 

设置1.9.2 作为默认的Ruby版本
rvm use 1.9.2 --default

报错提示
RVM is not a function, selecting rubies with 'rvm use ...' will not work.

解决方法
执行
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
然后重启Terminer再执行
source .bash_profile
这里还可以直接把这段命令写进/etc/profile
ubuntu:~$ rvm use 1.9.2 --default
Using /home/wenpeng/.rvm/gems/ruby-1.9.2-p290


安装rails 需要的lib

sudo apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion

sudo apt-get install build-essential libssl-dev libreadline5 libreadline5-dev zlib1g zlib1g-dev 


gem install rails 

如果出现问题的话需要remove掉ruby然后重新安装
rvm remove ruby
rvm install 1.9.2
rvm use 1.9.3 --default
gem install rails 


如果在启动rails server的过程中提示No JavaScripts Run time 有两个解决方法
解决方法1:

Adding the following gems to my Gemfile solved the issue:

gem 'execjs'
gem 'therubyracer'

Then of course:

这里需要先bundle install therubyracer
然后bundle install



解决方法2:

安装nodejs

lijg@lijg-desktop:~/workruby/helloapp$ sudo apt-cache search nodejs
[sudo] password for lijg:
coffeescript - interpreter and compiler for the CoffeeScript language
nodejs - Node.js event-based server-side javascript engine
nodejs-dbg - Node.js event-based server-side javascript engine (debug)

nodejs-dev - Development files for Node.js
发表评论
用户名: 匿名