我已经从Github克隆了我的应用,但我在Gemfile上遇到了错误。所以我想,这个应用程序。仍然在heroku上运行,并且当我使用以下命令时它表示所有最新信息:
git status
//On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
git push heroku
//Everything up-to-date
我也可以在heroku中看到输出。 如何修复Gemfile中的错误? 感谢。
//error as below:
There was an error parsing `Gemfile`: The `branch` option for `gem 'recaptcha'` is not allowed. Only gems with a git source can specify a branch. Bundler cannot continue.
# from /home/ubuntu/workspace/typo-1/Gemfile:46
# -------------------------------------------
# gem 'acts_as_tree_rails3'
> gem 'recaptcha', :require => 'recaptcha/rails', :branch => 'rails3'
#
// Gemfile
env = ENV["RAILS_ENV"] || 'development'
dbfile = File.expand_path("../config/database.yml", __FILE__)
#unless File.exists?(dbfile)
# raise "You need to configure config/database.yml first"
#else
# conf = YAML.load(File.read(dbfile))
# adapter = conf[env]['adapter']
# raise "You need define an adapter in your database.yml" if adapter == '' || adapter.nil?
# case adapter
# when 'sqlite3'
# gem 'sqlite3'
# when 'postgresql'
# gem 'pg'
# when 'mysql'
# gem 'sam-mysql-ruby'
# else
# raise "Don't know what gem to use for adapter #{adapter}"
# end
#end
group :production do
gem 'pg'
end
source 'https://rubygems.org'
ruby "1.9.3"
gem 'thin'
gem 'rails', '~> 3.0.10'
gem 'require_relative'
gem 'htmlentities'
gem 'json'
gem 'bluecloth', '~> 2.1'
gem 'coderay', '~> 0.9'
gem 'kaminari'
gem 'RedCloth', '~> 4.2.8'
gem 'addressable', '~> 2.1', :require => 'addressable/uri'
gem 'mini_magick', '~> 1.3.3', :require => 'mini_magick'
gem 'uuidtools', '~> 2.1.1'
gem 'flickraw-cached'
gem 'rubypants', '~> 0.2.0'
gem 'rake', '~> 0.9.2'
gem 'acts_as_list'
gem 'acts_as_tree_rails3'
gem 'recaptcha', :require => 'recaptcha/rails', :branch => 'rails3'
group :development, :test do
gem 'ruby-debug19'
gem 'factory_girl', '~> 2.2'
gem 'webrat'
gem 'rspec-rails', '~> 2.0'
gem 'simplecov', :require => false
gem 'sqlite3'
gem 'cucumber'
gem 'cucumber-rails', :require => false
gem 'cucumber-rails-training-wheels'
gem 'database_cleaner'
gem 'capybara'
end
//编辑 我在运行bundle install时脱掉了分支但是出现了如下错误: 捆绑安装
"您的Ruby版本是2.3.0,但您的Gemfile指定为1.9.3"
版本2.4创建相同的错误。所以,我已经改为2.3.0 - 它经历了下面的另一个错误:
记录结果 /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/json-1.7.5/gem_make.out
安装json(1.7.5)时发生错误,Bundler无法继续。
在捆绑之前确保gem install json -v '1.7.5'
成功。
//编辑
我已经按照建议的答案使用旧版本1.9.2并且我能够使用命令包安装但是在推送到heroku后,我在heroku上有空页并且错误如下:
//错误
2017-07-23T18:09:50.995656+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/controllers/controller.rb:181:in `load_rackup_config'
2017-07-23T18:09:50.995657+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/controllers/controller.rb:71:in `start'
2017-07-23T18:09:50.995657+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/runner.rb:187:in `run_command'
2017-07-23T18:09:50.995658+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/lib/thin/runner.rb:152:in `run!'
2017-07-23T18:09:50.995659+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/thin-1.5.0/bin/thin:6:in `<top (required)>'
2017-07-23T18:09:50.995659+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/bin/thin:23:in `load'
2017-07-23T18:09:50.995660+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/bin/thin:23:in `<top (required)>'
2017-07-23T18:09:51.185918+00:00 heroku[web.1]: Process exited with status 1
2017-07-23T18:09:51.200309+00:00 heroku[web.1]: State changed from starting to crashed
2017-07-23T18:09:51.845236+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=typoa.herokuapp.com request_id=7c8caa3e-8bad-4431-9da6-8ddf2f52a4d1 fwd="108.211.182.6" dyno= connect= service= status=503 bytes= protocol=https
2017-07-23T18:19:04.542770+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=typoa.herokuapp.com request_id=798e1c83-078a-4da6-b2cd-dfbf47b80687 fwd="108.211.182.6" dyno= connect= service= status=503 bytes= protocol=https
//编辑
当我脱掉建议的行(带recaptcha)时,我看不到app。本地。 有了这条线,我可以看到app。本地。
没有此行的错误如下:
rails server -b $IP -p $PORT
=> Booting WEBrick
=> Rails 3.0.17 application starting in development on http://0.0.0.0:8080
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
home/ubuntu/workspace/typo-1/config/initializers/recaptcha.rb:1:in `<top (required)>': uninitialized constant Recaptcha (NameError)
from /usr/local/rvm/gems/ruby-1.9.3-p551/gems/railties-3.0.17/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>'
在任何情况下,我都无法推送到heroku: 错误如下(建议使用最新版本的Ruby):
Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: !
remote: ! An error occurred while installing ruby-1.9.3
remote: !
remote: ! Heroku recommends you use the latest supported Ruby version listed here:
//编辑 我找不到一个有效的应用程序来查看此问题的解决方案...错误信息如下: http://typosphere.org/stable.tar.gz#
答案 0 :(得分:2)
1-在Github上的reCAPTCHA项目中没有分支rails3,因此,删除你的Gemfile。
gem&#39; recaptcha&#39;,:require =&gt; &#39;验证码/导轨&#39;
2-因为你使用的是ruby 2.2.x,而且在Gemfile中是1.9.3我建议你应该在你的机器上安装1.9.3(通过rvm或通过rvm或你用来管理你的ruby版本的任何东西)使用它可以避免您可能发现的其他冲突,因为您使用的是遗留代码。
rvm install 1.9.3
rvm使用1.9.3
现在安装gem bundler,然后安装你的Gemfile
答案 1 :(得分:0)
我没有使用Ruby 2.4.1获得此错误。当我将版本更改为1.9.3时,我确实得到了相同的错误,如Gemfile中所指定的那样。我也没有在Github的源头看到一个名为rails3
的分支。我会先尝试删除分支选项。
gem 'recaptcha', require: 'recaptcha/rails'