简体   繁体   English

Gemfile中的错误

[英]Errors in Gemfile

I've cloned my app from Github but I've got errors on Gemfile. 我已经从Github克隆了我的应用程序,但是Gemfile出现了错误。 So I think, this app. 所以我想,这个程序。 is still running on heroku and it said that all up to date when I've used following commands: 仍然在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

Also I could see output in heroku. 我也可以在heroku中看到输出。 How to fix the error in Gemfile? 如何修复Gemfile中的错误? thanks. 谢谢。

//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 //的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

//edited I took off branch but got error as below when run bundle install: bundle install //编辑我离开了分支,但是在运行bundle install时出现以下错误:bundle install

"Your Ruby version is 2.3.0, but your Gemfile specified 1.9.3" “您的Ruby版本是2.3.0,但是您的Gemfile指定了1.9.3”

Version 2.4 create the same error. 2.4版会产生相同的错误。 So,I've changed to 2.3.0 - it went through until another error as below: 因此,我已更改为2.3.0-它经历了另一个错误,如下所示:

Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/json-1.7.5/gem_make.out 结果记录到/usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/json-1.7.5/gem_make.out

An error occurred while installing json (1.7.5), and Bundler cannot continue. 安装json(1.7.5)时发生错误,并且Bundler无法继续。 Make sure that gem install json -v '1.7.5' succeeds before bundling. 捆绑之前,请确保gem install json -v '1.7.5'成功。

//editing //编辑

I've follow the answer suggested to use the old version 1.9.2 and I be able to use command bundle install but after pushing to heroku, I've got empty page on heroku and errors as below: 我已经按照建议的答案使用旧版本1.9.2,并且能够使用命令捆绑安装,但是在推送到heroku之后,我在heroku上出现了空白页面,并出现以下错误:

//errors //错误

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

//edited //编辑

When I took off suggested line( with recaptcha), I could not see app. 当我离开建议的行(与recaptcha)时,我看不到应用程序。 locally. 本地。 With this line I could see app. 通过这一行,我可以看到应用程序。 locally. 本地。

Errors without this line as below: 没有此行的错误如下:

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>'

In any cases, I could not push to heroku: Errors as below(it recommends to use the latest version of Ruby): 无论如何,我都无法推送到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:

//edit I could not find a working app to see the solution of this problem...Error message as below: http://typosphere.org/stable.tar.gz# // edit我找不到能正常工作的应用程序来查看此问题的解决方案。错误消息如下: http : //typosphere.org/stable.tar.gz#

1- In reCAPTCHA project on Github there is not a branch rails3, so, remove that piece of your Gemfile. 1-在Github上的reCAPTCHA项目中没有分支rails3,因此,删除该部分Gemfile。

gem 'recaptcha', :require => 'recaptcha/rails' 宝石'recaptcha',:require =>'recaptcha / rails'

2- Since you are using ruby 2.2.x, and in Gemfile is 1.9.3 I suggest that you should install 1.9.3 (via rvm or via rvm or whatever you use to manage your ruby versions) in your machine and work with that in order to avoid other conflicts you may find, because you are using a legacy code. 2-由于您使用的是ruby 2.2.x,并且在Gemfile中是1.9.3,所以我建议您在计算机中安装1.9.3(通过rvm或rvm或用于管理红宝石版本的任何工具)并使用该版本为了避免其他冲突,您可能会发现,因为您使用的是旧版代码。

rvm install 1.9.3 rvm安装1.9.3

rvm use 1.9.3 rvm使用1.9.3

now install gem bundler and after that blundle install your Gemfile 现在安装gem bundler,然后钝安装Gemfile

I did not get this error using Ruby 2.4.1. 使用Ruby 2.4.1时没有出现此错误。 I did get the same error when I changed versions to 1.9.3, as specified in the Gemfile. 当我将版本更改为Gemfile中指定的1.9.3时,确实出现了相同的错误。 I also don't see a branch called rails3 at the source on Github. 我也没有在Github的源头看到一个名为rails3的分支。 I would try removing the branch option first. 我会尝试先删除分支选项。

gem 'recaptcha', require: 'recaptcha/rails'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM