2011-08-07 266 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。