簡體   English   中英

在Rails上的ruby中啟動服務器時出錯

[英]Error while starting server in ruby on rails

我是Ruby on Rails的新手,在這里,我嘗試在64位Windows 7的Rails上安裝Ruby。

在運行命令rails new app_name ,我先執行了cd app_name ,然后安裝了rails server隨后在命令提示符下出現以下錯誤。

我該如何解決這個錯誤?

Could not find gem 'mysql2 (>= 0) x64-mingw32' in any of the gem sources listed
in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.

如果我運行捆綁安裝,我會得到

C:\Users\walnut>bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies.................
Using rake 10.4.2
Using i18n 0.7.0
Installing json 1.8.3 with native extensions

Gem::InstallError: The 'json' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.

在這里您可以嘗試以下解決方案:

  1. 安裝rubyinstaller-1.9.3(我確實嘗試過使用最新版本,但是遇到一些問題,請先嘗試使用此安裝程序- 在此處下載)
  2. 安裝DevKit( 在此處下載)-找到For use with Ruby 1.8.7 and 1.9.3:在我們安裝ruby-1.9.3時,這些下載頁面中的文本。
    • 您可以按照以下步驟進行devKit安裝
    • 遵循此:
      • 下載后,運行它以將其解壓縮到某個位置(永久)。 然后將其安裝到CD,運行ruby dk.rb initruby dk.rb install將其綁定到路徑中的ruby安裝。
  3. 之后,輸入gem install rails --no-ri --no-rdoc
  4. 完成上述所有步驟后,您可以在任何地方使用此命令創建rails項目rails new yourProject
  5. 如果出現錯誤,例如"An error occurred while installing rake (*any version), and Bundler cannot continue." ,請參考此解決方案或執行以下步驟:
    • 下載AddTrustExternalCARoot-2048.pem ,並將其放置在ruby安裝文件夾中,通常類似於以下路徑C:\\Ruby193\\lib\\ruby\\site_ruby\\1.9.1\\rubygems\\ssl_certs
  6. 再次嘗試鍵入rails new yourProject (上一個失敗)。
  7. 完成,通常有關捆綁安裝的錯誤已經消失。 祝我朋友好運。
  8. 最后,輸入yourProject目錄,然后運行rails server

我在Windows平台上首次安裝時也遇到困難,希望能有所幫助。 請注意,如果您使用的不是默認數據庫,而是通過Rails(sqlite3)使用mysql, postgresql, etc ,則需要安裝正確的gem才能正常工作。 只需運行gem install theRightGemForDatabase

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM