Openshift上的Ruby"bundle install"错误

Seb*_*ski 6 ruby git ruby-on-rails bundler openshift

我是Ruby的新手,也是通过远程工具部署应用程序的条款.我试图在免费的openshift帐户上部署我的应用程序.我不会运行应用程序.

当我运行应用程序时,我收到此错误:

You have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0.
Using bundle exec may solve this. (Gem::LoadError)
Run Code Online (Sandbox Code Playgroud)

所以我尝试运行,bundle exec但我得到另一个错误:

Gemfile syntax error:
/var/lib/openshift/xxxxxxxxxxxxxxxxxxxxxxxxxx/app-root/runtime/repo/Gemfile:24: 
syntax error, unexpected ':', expecting $end
gem 'sdoc', '~> 0.4.0', group: :doc
Run Code Online (Sandbox Code Playgroud)

我想这可能是因为我在本地使用Ruby 2.1.5并且Open shift默认运行Ruby 2.0.

我讨论过这个主题当我的RAILS_ENV设置为开发时,如何在OpenShift Online上强制进行捆绑安装? 但我不知道我做得对.我甚至不知道把这个pre_build文件放在哪里.我试着把它放在下面/var/lib/openshift/xxxxxxxxxxxxxxxxxxxxxxxxxx/app-root/runtime/repo/.openshift/action_hooks/.但我不确定是否runtime是正确的回购.

编辑1:

这是我的Gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
group: :doc do
    gem 'sdoc', '~> 0.4.0'
end

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]
Run Code Online (Sandbox Code Playgroud)

解:

正如@Rajarshi Das所说我必须改变

gem 'sdoc', '~> 0.4.0', group: :doc
Run Code Online (Sandbox Code Playgroud)

group: :doc do
    gem 'sdoc', '~> 0.4.0'
end
Run Code Online (Sandbox Code Playgroud)

我不知道为什么.也许是一些语法问题,因为我在本地使用Ruby 2.1.5,并且必须在生产中使用2.0.0.之后,gem install rails即使我使用rails快速启动,我也必须运行.最后我不得不手动添加到Gemfile gem 'nokogiri'.最后,我可以运行bundle install,应用程序开始工作.

Raj*_*Das 8

您可以通过以下方式简单地解决错误

 group :doc do
    gem 'sdoc', '~> 0.4.0'
 end
Run Code Online (Sandbox Code Playgroud)

对于平台

platforms :jruby, :mingw, :mswin do
  gem 'tzinfo-data'
end
Run Code Online (Sandbox Code Playgroud)

删除Gemfile.lockYou have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0

然后检查 bundle install


Vis*_*rai 5

我ssh到$ app_root目录

gem install rack

有效