【问题标题】:git push heroku failing because trying to install development gems. BUNDLE_WITHOUT command not workinggit push heroku 失败,因为试图安装开发 gem。 BUNDLE_WITHOUT 命令不起作用
【发布时间】:2011-08-22 22:21:47
【问题描述】:

发出 git push heroku 命令后出现错误。这最初看起来像是通过使用 heroku config 命令在没有 development:test gems 的情况下捆绑来解决的。但是,我使用了类似文章 [Heroku's trying to install development gems even after I've told it not to] 中讨论的该命令,但它仍然不起作用。

下面推送消息中的“Using --without development:test”行似乎表明 BUNDLE_WITHOUT 配置命令有效,所以这可能是 gemfile 或其他问题?

谢谢!

$ git push heroku
Counting objects: 64, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (42/42), done.
Writing objects: 100% (48/48), 6.03 KiB, done.
Total 48 (delta 15), reused 0 (delta 0)

-----> Heroku receiving push
-----> Rails app detected
-----> Detected Rails is not set to serve static_assets
       Installing rails3_serve_static_assets... done
-----> Configure Rails 3 to disable x-sendfile
       Installing rails3_disable_x_sendfile... done
-----> Configure Rails to log to stdout
       Installing rails_log_stdout... done
-----> Gemfile detected, running Bundler version 1.0.7
       Unresolved dependencies detected; Installing...
       Using --without development:test
       Fetching source index for http://rubygems.org/
       Installing rake (0.8.7) 
       Installing ZenTest (4.5.0) 
       Installing abstract (1.0.0) 
       Installing activesupport (3.0.3) 
       Installing builder (2.1.2) 
       Installing i18n (0.5.0) 
       Installing activemodel (3.0.3) 
       Installing erubis (2.6.6) 
       Installing rack (1.2.2) 
       Installing rack-mount (0.6.14) 
       Installing rack-test (0.5.7) 
       Installing tzinfo (0.3.25) 
       Installing actionpack (3.0.3) 
       Installing mime-types (1.16) 
       Installing polyglot (0.3.1) 
       Installing treetop (1.4.9) 
       Installing mail (2.2.15) 
       Installing actionmailer (3.0.3) 
       Installing arel (2.0.9) 
       Installing activerecord (3.0.3) 
       Installing activeresource (3.0.3) 
       Installing autotest (4.4.6) 
       Installing sys-uname (0.8.5) with native extensions 
       Installing autotest-fsevent (0.2.5) with native extensions /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:483:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

       /usr/ruby1.8.7/bin/ruby extconf.rb 
       extconf.rb:19: Only Darwin (Mac OS X) systems are supported (RuntimeError)


       Gem files will remain installed in /disk1/tmp/build_258oz7hi5972n/.bundle/gems/ruby/1.8/gems/autotest-fsevent-0.2.5 for inspection.
       Results logged to /disk1/tmp/build_258oz7hi5972n/.bundle/gems/ruby/1.8/gems/autotest-fsevent-0.2.5/ext/fsevent/gem_make.out
        from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `each'
        from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:446:in `build_extensions'
        from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/installer.rb:198:in `install'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/source.rb:95:in `install'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:55:in `run'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/spec_set.rb:12:in `each'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:44:in `run'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/installer.rb:8:in `install'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/cli.rb:225:in `install'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `send'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/task.rb:22:in `run'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor.rb:246:in `dispatch'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/vendor/thor/base.rb:389:in `start'
        from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.7/bin/bundle:13
        from /usr/ruby1.8.7/bin/bundle:19:in `load'
        from /usr/ruby1.8.7/bin/bundle:19
       FAILED: http://devcenter.heroku.com/articles/bundler
 !     Heroku push rejected, failed to install gems via Bundler

error: hooks/pre-receive exited with error code 1
To git@heroku.com:blooming-mountain-199.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:blooming-mountain-199.git'

宝石文件...

source 'http://rubygems.org'

gem 'rails', '3.0.3'

gem 'sqlite3', '1.3.3', :require => 'sqlite3'

gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '3.0.pre2'

gem "nokogiri"
gem "geokit"
gem "rack", "~>1.1"

group :development, :test do
  gem 'rspec-rails', '2.5.0'
  gem 'annotate-models', '1.0.4'
  gem 'faker', '0.3.1'
  gem 'autotest-fsevent' if RUBY_PLATFORM =~ /darwin/
  gem 'rspec', '2.5.0'
  gem 'webrat', '0.7.1'
  gem 'spork', '0.9.0.rc4'
  gem 'factory_girl_rails', '1.0'

  gem 'ZenTest'
  gem 'autotest'
  gem 'autotest-rails'
  gem 'autotest-growl'
end

【问题讨论】:

  • 默认情况下,通过heroku gem部署时,开发和测试gem被排除在外;你能解释一下你的设置吗?
  • 我正在通过RoR tutorial 工作,前几章进展顺利,没有任何问题。 heroku 设置是here in section 1.4.1,我被困在3.4 部分中的最终部署失败。感谢您查看@JasonLewis!

标签: ruby-on-rails-3 heroku bundler


【解决方案1】:

好吧,问题显然是当您推送到 Heroku 时加载了 autotest-fsevent,这不是基于 Darwin 的。尽管在gem 'autotest-fsevent' 语句之后确实有一个条件,但当您部署到 Heroku 时,gem 仍在尝试加载。这有两个可能的原因。

首先,另一个宝石需要它。如果不出意外,autotest-growl 也应该是 Darwin-only。我不确定这些是否相关,但我仍会仔细检查。

下一个问题是确保 Gemfile.lock 没有被推送。如果您上次在 Darwin 上运行 bundle install,则 gem 可能以这种方式被锁定到依赖项中。 git rm Gemfile.lock 在你提交并推送到 Heroku 之前。

最后,我的 喜欢的解决方案是不使用自动测试。我不确定这是否适合您,但是当我使用它时我发现它很烦人,我使用 RSpec 和 Cucumber。我意识到这最后一个建议不是答案,但我不喜欢在测试中包含依赖于平台的 gem,即使在测试中,只是因为当你去 staging 时,像这样的小烦恼有裁剪的趋势起来。

我不知道为什么 Rails 教程仍然使用 ZenTest 和自动测试,我不知道有谁这样做...这可能正在改变,一位朋友参加 RailsConf 的 Rails 教程会议并说 Michael 实际上注意到教程中的勘误表,所以在未来的版本中可能会有所不同。

最后,出于好奇,如果您使用的是 OS X,您是如何安装 Ruby 的?它在一个非常奇怪的地方。

【讨论】:

  • 感谢您的反馈!在多次尝试 Gemfile 变体和 gem 版本后,我发现 Heroku 不支持 Gemfile 中的 if 语句。奇怪,因为我在各个网站上看到至少 30 个帖子表明相反。感谢@helixed in his post
猜你喜欢
  • 2022-11-24
  • 2021-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多