Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby "bundle install" error on Openshift

I'am fairly new in Ruby and terms of deploying app through remote tools. I've tried to deploy my App on free openshift account. 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:

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.

I had foud this topic How can I force a bundle install on OpenShift Online when my RAILS_ENV is set to development? but i don't know if I am doing it right. I don't even know where to put this pre_build file. I tried to put it under /var/lib/openshift/xxxxxxxxxxxxxxxxxxxxxxxxxx/app-root/runtime/repo/.openshift/action_hooks/ . But I'm not sure if runtime is right repo.

EDIT 1:

This it my 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

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. And after that I had to run gem install rails even though I used rails quick start. Finally I had to manually add to Gemfile gem 'nokogiri'. Finally I could run bundle install and application started to work.

like image 822
Sebastian Piskorski Avatar asked Feb 05 '15 14:02

Sebastian Piskorski


2 Answers

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

Then check bundle install

like image 161
Rajarshi Das Avatar answered Sep 21 '22 05:09

Rajarshi Das


I ssh to $app_root directory

gem install rack

it worked

like image 26
Vishnu Atrai Avatar answered Sep 20 '22 05:09

Vishnu Atrai