天天看點

Rails的痛苦更新路

最近在選擇開源項目管理工具,最後看上了redmine

一開始用Bitnami,可是裝好之後總是不能通路redmine

無奈之後選擇InstantRails-2.0作為安裝環境

可是按照網上的文章裝的過程中總是報錯

後來才知道是因為我裝的redmine 1.0.0要求的版本要比InstantRails-2.0高,而InstantRails-2.0從2007年開始就沒更新過了。

昨晚我弄了2點半,中間幾次想放棄,但拗不過自己的牛脾氣,最後終于更新成功,并且成功通路了redmine。

過程是痛苦的,結果是甜蜜的。

雖然對ror并不是很了解,但想信我的安裝經曆對大家多少會有些幫忙。

具體過程如下:

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.gem,http://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/中的位址。

繼續閱讀