ruby install相關(遠程安裝時出現HTTP Response 302的解決辦法)

具體過程如下: 

1、InstantRails-2.0安裝後,在配置環境變量path中配置ruby/bin目錄(如果系統中有多個RUBY,執行命令行的時候系統認的就是path中的) 

2、進入DOS命令行,執行gem update --system,結果 

Updating RubyGems... 
ERROR:  While executing gem ... (Gem::RemoteSourceException) 
HTTP 
Response 302 fetching http://rubygems.org/yaml 

     這是因爲gem的配置過低,無法進行遠程更新,執行gem -v 發現是1.0.1 

3、從下面這個地址下載 rubygems-update-1.3.7.gemhttp://rubyforge.org/frs/download.php/70695/rubygems-update-1.3.7.gem 

    然後DOS命令進行該文件所在的目錄,執行gem install --local rubygems-update-1.3.7.gem,出現信息 

Successfully installed rubygems-update-1.3.7 
1 gem installed 
Installing ri documentation for rubygems-update-1.3.7... 
Installing RDoc documentation for rubygems-update-1.3.7... 
Could not find main page README 
Could not find main page README 
Could not find main page README 
Could not find main page README 

  執行gem -v查看,發現並沒有更新成功,Could not find main page README是什麼意思我沒弄明白,但是我從http://production.s3.rubygems.org/yaml上發現這麼一句 

      If you have an older version of RubyGems installed, then you can still 
      do it in two steps: 
     
        $ gem install rubygems-update  # again, might need to be admin/root 
        $ update_rubygems              # ... here too 
我照着再執行 update_rubygems,接着出現的信息很多,就不帖出來,再執行gem -v,發現更新成功,已經是1.3.7了 

這一步是一切成功的源泉!!!!!! 

4、接着再執行gem update --system,提示 

Updating RubyGems 
Nothing to update 

  這是爲什麼我不明白,請高手指點一下 

5、再執行gem update rails --include-dependencies,提示信息 

Updating installed gems 
Updating rails 
ERROR:  Error installing rails: 
        actionpack requires rack (~> 1.0.0, runtime) 
Gems updated: activesupport, activerecord 
Installing ri documentation for activesupport-2.3.3... 
Installing ri documentation for activerecord-2.3.3... 
Installing RDoc documentation for activesupport-2.3.3... 
Installing RDoc documentation for activerecord-2.3.3... 

執行rails -v,發現還是2.0.2沒有更新成功,根據actionpack requires rack (~> 1.0.0, runtime),應該是actionpack 需要1.0.0版本的rack 

6、執行gem install rack -v=1.0.0 

Successfully installed rack-1.0.0 
1 gem installed 
Installing ri documentation for rack-1.0.0... 
Installing RDoc documentation for rack-1.0.0... 

更新成功 

7、再次執行 gem update rails --include-dependencies 

出現信息 

Updating installed gems 
Updating rails 
Successfully installed rake-0.8.7 
Successfully installed activesupport-2.3.8 
Successfully installed activerecord-2.3.8 
Successfully installed rack-1.1.0 
Successfully installed actionpack-2.3.8 
Successfully installed actionmailer-2.3.8 
Successfully installed activeresource-2.3.8 
Successfully installed rails-2.3.8 
Gems updated: rake, activesupport, activerecord, rack, actionpack, actionmailer, activeresource, rails 
Installing ri documentation for rake-0.8.7... 
Installing ri documentation for activesupport-2.3.8... 
Installing ri documentation for activerecord-2.3.8... 
Installing ri documentation for rack-1.1.0... 
Installing ri documentation for actionpack-2.3.8... 
Installing ri documentation for actionmailer-2.3.8... 
Installing ri documentation for activeresource-2.3.8... 
Installing ri documentation for rails-2.3.8... 
Installing RDoc documentation for rake-0.8.7... 
Installing RDoc documentation for activesupport-2.3.8... 
Installing RDoc documentation for activerecord-2.3.8... 
Installing RDoc documentation for rack-1.1.0... 
Installing RDoc documentation for actionpack-2.3.8... 
Installing RDoc documentation for actionmailer-2.3.8... 
Installing RDoc documentation for activeresource-2.3.8... 
Installing RDoc documentation for rails-2.3.8... 

執行rails -v,發現已更新成功 



總結:rails更新有兩種方式:1、聯機更新;2本地更新 

聯機更新過程中如果出現HTTP Response 302 fetching http://rubygems.org/yaml無法更新,有兩種情況 

一是gem的版本過低,二是與服務器的連接不通 

此時可以試着加入其他服務器地址 

gem source -l  查看列表 

gem source -a http://rubygems.org 加入新的服務器地址 

或者直接gem install rubygems-update --source http://rubygems.org 

本地更新需要下載相應的gem包,版本需與要更新的rails版本對應,同時安裝順序有要求,因此gem包之間有依賴關係 

順序從上面的顯示信息中可以看出來 

Successfully installed rake-0.8.7 
Successfully installed activesupport-2.3.8 
Successfully installed activerecord-2.3.8 
Successfully installed rack-1.1.0 
Successfully installed actionpack-2.3.8 
Successfully installed actionmailer-2.3.8 
Successfully installed activeresource-2.3.8 
Successfully installed rails-2.3.8 

至於gem包的下載地址都在http://rubyforge.org/,但是有些項目的並不好找到,可以在google中直接搜索,就能找到在http中的地址。 ://rubyforge.org/
發佈了6 篇原創文章 · 獲贊 0 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章