2011-08-07 37 views
9

事實上,從我從git repo克隆的現有rails應用程序內運行時,所有與gem相關的命令都會導致相同的錯誤消息。運行「軟件包安裝」失敗並要求我運行「軟件包安裝」

$ bundle install 
Could not find tzinfo-0.3.27 in any of the sources 
Run `bundle install` to install missing gems. 

$ gem list 
Could not find tzinfo-0.3.27 in any of the sources 
Run `bundle install` to install missing gems. 

$ bundle update 
Could not find tzinfo-0.3.27 in any of the sources 
Run `bundle install` to install missing gems. 

$ rails -v 
Could not find tzinfo-0.3.27 in any of the sources 
Run `bundle install` to install missing gems. 

我以爲我已經安裝了護欄......(下面的命令是從應用程序目錄外運行):

$ rails -v 
Rails 3.0.3 

$ ruby -v 
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.0.0] 

任何想法,以「包安裝」是了,告訴我運行「捆綁安裝」?


我離開我的應用程序目錄和手動做

sudo gem install tzinfo -v 0.3.27 

但在再次進入我的應用程序目錄,並試圖「捆綁安裝」 ...

$ bundle install 
Could not find polyglot-0.3.1 in any of the sources 
Run `bundle install` to install missing gems. 

於是我又回來了的應用程序目錄,沒有

sudo gem install polyglot -v 0.3.1 

「包安裝」現在產生

$ bundle install 
Could not find treetop-1.4.9 in any of the sources 
Run `bundle install` to install missing gems. 

爲什麼我不得不在過去的一切,我沒有這些隨機寶石手工安裝到? (新開發環境)。任何人都知道我可以在自己的環境中設置錯誤嗎?

+0

你的Gemfile中有什麼,它包含'source'http:// ruby​​gems.org''? – daeltar

+0

它包含來源:rubygems,添加源'http://rubygems.org'沒有幫助,同樣的錯誤。 – Tim

+0

另外...事實證明,我可以運行'捆綁安裝--gemfile = myApp/Gemfile',但它失敗的另一個錯誤(無關,我認爲)。爲什麼我無法從應用程序目錄中運行軟件包安裝? – Tim

回答

7

OK猜我固定它..

對於運行bundle install抱怨從應用程序目錄中運行時,對寶石,我會通過應用程序目錄之外,並通過一個做sudo gem install [gem]一個安裝它們。做bundle install --gemfile=myApp/Gemfile也安裝了幾個失蹤的寶石。

我不知道爲什麼我無法從應用程序目錄內運行bundle install ...跛腳。

+1

當您執行'gem install'時,它會將其全局安裝到您的ruby版本(假設您使用Rbenv),因此'gem list'會顯示這些內容。當你進行捆綁安裝時,它會爲特定項目安裝寶石,在你的項目文件夾中,「捆綁顯示」將顯示該項目的寶石。當你有很多項目時,你不想污染你的全球寶石 - 他們*應該*(意見,最佳實踐)在每個項目的基礎上安裝。 – xxjjnn

+1

嘗試'bundle update'而不是'bundle install'。爲我解決了這個問題 –

+1

同意@ConnorLeech。 「捆綁更新」也是我工作的簡單解決方案。 – BigGillyStyle

3

我有這個問題。有一次,我所做的:

[[email protected] ~]# PATH=$PATH:~/.gem/ruby/2.0.0/bin

[[email protected] ~]# export PATH

然後,它是固定的,我可以只

[[email protected] msf3]# bundle install

成功。

+0

對我來說,問題是配置的〜/ .gemrc文件。好的其他地方看看。 –

-4

我有一個非常類似的問題,嘗試了很多不同的事情後,我終於找到了一個簡單的解決方案,工作......我重新啓動了我的電腦(mac os 10.9x)。不是開玩笑。

2

問題是您的所有命令實際上都是前綴bundle exec。如果你看看它的捆綁器的輸出,告訴你你的寶石沒有安裝。如果您在rbenv中安裝了一些插件(如rbenv-bundle-exec,rbenv-bundler或rbenv-binstubs),則會發生這種情況。 至少對我而言,第一次嘗試在項目中嘗試bundle install時發生了這種情況,因爲它實際上檢測到當前文件夾中存在Gemfile,並嘗試執行bundle exec bundle install,這顯然不起作用。

您可以使用Tim的解決方案,並從項目文件夾外部運行軟件包安裝。

您可以臨時禁用或卸載預先設置爲bundle exec的擴展名爲ruby命令。

或者,如果問題發生,因爲你用rbenv束-EXEC,只是做:

NO_BUNDLE_EXEC=1 bundle install

1

rubyinstaller

然後gem install bundle安裝Ruby固定的問題,我在贏10臺PC。