[英]Ruby “bundle install” error on Openshift
I'am fairly new in Ruby and terms of deploying app through remote tools. 我是Ruby的新手,也是通过远程工具部署应用程序的条款。 I've tried to deploy my App on free openshift account.
我试图在免费的openshift帐户上部署我的应用程序。 And I connot run application.
我不会运行应用程序。
When I run application i get this error: 当我运行应用程序时,我收到此错误:
You have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0.
Using bundle exec may solve this. (Gem::LoadError)
So I try to run bundle exec
but i got another error: 所以我尝试运行
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
I think it might be because I used Ruby 2.1.5 on local and Open shift runs Ruby 2.0 by default. 我想这可能是因为我在本地使用Ruby 2.1.5并且Open shift默认运行Ruby 2.0。
I had foud this topic How can I force a bundle install on OpenShift Online when my RAILS_ENV is set to development? 我讨论过这个主题当我的RAILS_ENV设置为开发时,如何在OpenShift Online上强制进行捆绑安装? but i don't know if I am doing it right.
但我不知道我做得对。 I don't even know where to put this
pre_build
file. 我甚至不知道把这个
pre_build
文件放在pre_build
。 I tried to put it under /var/lib/openshift/xxxxxxxxxxxxxxxxxxxxxxxxxx/app-root/runtime/repo/.openshift/action_hooks/
. 我试着把它放在
/var/lib/openshift/xxxxxxxxxxxxxxxxxxxxxxxxxx/app-root/runtime/repo/.openshift/action_hooks/
下。 But I'm not sure if runtime
is right repo. 但我不确定
runtime
是否是正确的回购。
EDIT 1: 编辑1:
This it my Gemfile: 这是我的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]
SOLUTION: 解:
As @Rajarshi Das said I had to change 正如@Rajarshi Das所说我必须改变
gem 'sdoc', '~> 0.4.0', group: :doc
into 成
group: :doc do
gem 'sdoc', '~> 0.4.0'
end
I don know exactly why. 我不知道为什么。 Maybe some syntax issues as I was using Ruby 2.1.5 on local, and had to use 2.0.0 on production.
可能是一些语法问题,因为我在本地使用Ruby 2.1.5,并且必须在生产中使用2.0.0。 And after that I had to run
gem install rails
even though I used rails quick start. 之后我不得不运行
gem install rails
即使我使用了rails快速启动。 Finally I had to manually add to Gemfile gem 'nokogiri'
. 最后我不得不手动添加到Gemfile
gem 'nokogiri'
。 Finally I could run bundle install
and application started to work. 最后我可以运行
bundle install
并开始运行应用程序。
You can simply solve the error by following way 您可以通过以下方式简单地解决错误
group :doc do
gem 'sdoc', '~> 0.4.0'
end
For platforms 对于平台
platforms :jruby, :mingw, :mswin do
gem 'tzinfo-data'
end
Remove Gemfile.lock
as You have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0
删除
Gemfile.lock
因为You have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0
Then check bundle install
然后检查
bundle install
I ssh to $app_root directory 我ssh到$ app_root目录
gem install rack
it worked 有效
Make sure your branch is being used for deployment 确保您的分支用于部署
rhc app-configure --deployment-branch [BRANCH]
rhc app-configure --deployment-branch [BRANCH]
Then in your development environment update gems 然后在您的开发环境中更新宝石
# bundle install
#bundal install
It will change Gemfile.lock 它会改变Gemfile.lock
$ git add -A $ git commit -am "Updating gemfile" $ git push
$ git add -A $ git commit -am“更新gemfile”$ git push
Wait until deployment is updated 等到部署更新
I tried most of the solutions here, but I still got stuck. 我在这里尝试了大部分解决方案,但我仍然陷入困境。 What the problem was is to install bundle for the current version of ruby being used.
问题是为正在使用的当前版本的ruby安装bundle。 You will want to do a
gem install bundler
in app-root/runtime/repo. 您将需要在app-root / runtime / repo中执行
gem install bundler
。 Then RAILS_ENV=production bundle exec rails console
然后
RAILS_ENV=production bundle exec rails console
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.