簡體   English   中英

Openshift上的Ruby“bundle install”錯誤

[英]Ruby “bundle install” error on 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)

所以我嘗試運行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

我想這可能是因為我在本地使用Ruby 2.1.5並且Open shift默認運行Ruby 2.0。

我討論過這個主題當我的RAILS_ENV設置為開發時,如何在OpenShift Online上強制進行捆綁安裝? 但我不知道我做得對。 我甚至不知道把這個pre_build文件放在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]

解:

正如@Rajarshi Das所說我必須改變

gem 'sdoc', '~> 0.4.0', group: :doc

group: :doc do
    gem 'sdoc', '~> 0.4.0'
end

我不知道為什么。 可能是一些語法問題,因為我在本地使用Ruby 2.1.5,並且必須在生產中使用2.0.0。 之后我不得不運行gem install rails即使我使用了rails快速啟動。 最后我不得不手動添加到Gemfile gem 'nokogiri' 最后我可以運行bundle install並開始運行應用程序。

您可以通過以下方式簡單地解決錯誤

 group :doc do
    gem 'sdoc', '~> 0.4.0'
 end

對於平台

platforms :jruby, :mingw, :mswin do
  gem 'tzinfo-data'
end

刪除Gemfile.lock因為You have already activated rack 1.5.2, but your Gemfile requires rack 1.6.0

然后檢查bundle install

我ssh到$ app_root目錄

gem install rack

有效

確保您的分支用於部署

rhc app-configure --deployment-branch [BRANCH]

然后在您的開發環境中更新寶石

#bundal install

它會改變Gemfile.lock

$ git add -A $ git commit -am“更新gemfile”$ git push

等到部署更新

我在這里嘗試了大部分解決方案,但我仍然陷入困境。 問題是為正在使用的當前版本的ruby安裝bundle。 您將需要在app-root / runtime / repo中執行gem install bundler 然后RAILS_ENV=production bundle exec rails console

你可以參考這個答案

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM