6

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.

Community
  • 1
  • 1
Sebastian Piskorski
  • 4,026
  • 3
  • 23
  • 29
  • I guess it have to be my git repository. Form which i download files for bulid, not repository on openshift server. Bu how to set it for rails 2.1 deployment? – Sebastian Piskorski Feb 05 '15 at 14:42
  • I have the same problem. What changes did you need to make to run the application using `bundle exec` – Gerard Condon May 20 '15 at 09:31
  • I'm fairly new in Ruby. So most of my actions were shooting in the dark. I think you should try bundle install. I guess that bundle install uses Gemfile and bundle exec uses .lock file. – Sebastian Piskorski May 20 '15 at 21:51
  • 2
    I seems that Openshift runs ruby 1.8 by default, even if you have activated the ruby-2.0 cartridge. My solution for `bundle exec` was to install bundler for ruby 2.0 with `gem install bundler`. If the `bundle` command is available for ruby 2.0, it runs with ruby 2.0. – Darme Jul 01 '15 at 15:55
  • Update your solution, there is an extra colon after group, that should not be there. – silver_mx Jul 06 '15 at 07:11
  • Do you mean like this `group :doc` and `group: :doc` ? – Sebastian Piskorski Jul 07 '15 at 08:00

4 Answers4

8

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

Rajarshi Das
  • 11,778
  • 6
  • 46
  • 74
  • Still the smae error `syntax error, unexpected ':', expecting $end group: :doc do` . I had put my Gemfile above. Are you sure this is not related to Ruby version? – Sebastian Piskorski Feb 05 '15 at 14:59
  • Please check my update post it should be `group` not `group:` – Rajarshi Das Feb 05 '15 at 15:00
  • I had to change also this line `gem 'tzinfo-data', platforms: [:mingw, :mswin, :jruby]` into `platforms [:mingw, :mswin, :jruby] do gem 'tzinfo-data' end`. But now I get another error: `/usr/lib/ruby/gems/1.8/gems/bundler-1.3.5/lib/bundler/dsl.rb:224:in '_normalize_options': undefined method 'to_sym' for [:mingw, :mswin, :jruby]:Array (NoMethodError)` `There was an error in your Gemfile, and Bundler cannot continue.` – Sebastian Piskorski Feb 05 '15 at 15:04
  • Thank you for a lots of your help. Although I have more errors: `Gem::InstallError: i18n requires Ruby version >= 1.9.3 An error occurred while installing i18n (0.7.0), and Bundler cannot continue. Make sure that ``gem install i18n -v '0.7.0'`` succeeds before bundling. ` – Sebastian Piskorski Feb 05 '15 at 15:24
  • you should use `ruby 1.9.3` use `rbenv` or `rvm` and install the required ruby version – Rajarshi Das Feb 05 '15 at 15:25
  • But why? On local I run it with Ruby 2.1.5 and there is no such problem. Is there some dependency? – Sebastian Piskorski Feb 05 '15 at 15:28
  • Ok, I didn't know why but error didn't show after redeploy. Any way I still had to do `gem install rails` even if I had choose Rails fast start. And after the I ha error with: `cannot load such file -- nokogiri` . So I had to add `gem 'nokogiri'` to Gemfile. After that everything started to work. – Sebastian Piskorski Feb 08 '15 at 22:41
5

I ssh to $app_root directory

gem install rack

it worked

Vishnu Atrai
  • 2,370
  • 22
  • 24
0

Make sure your branch is being used for deployment

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

Then in your development environment update gems

# bundle install

It will change Gemfile.lock

$ git add -A $ git commit -am "Updating gemfile" $ git push

Wait until deployment is updated

0

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. You will want to do a gem install bundler in app-root/runtime/repo. Then RAILS_ENV=production bundle exec rails console

You can refer to this answer

Olalekan Sogunle
  • 2,299
  • 1
  • 20
  • 26