Martyn
Martyn

Reputation: 49

Error with Gitlab: Sidekiq; gemfile syntax error

I've been breaking my head over this error for hours now, and still haven't found a fix. When I run sidekiq using sudo -u root -H RAILS_ENV=production script/background_jobs start I'm getting this error in the sidekiq.log:

Gemfile syntax error:
/home/website/git/gitlab/Gemfile:20: syntax error, unexpected ':', expecting $end
gem "mysql2", group: :mysql

I've installed Ruby 2.1.0 and am running CentOS. I've seen other posts with this error, and their problem was that they were running Ruby 1.8, however, I'm running Ruby 2.1.0 and also getting this error.

Any help is greatly appreciated.

EDIT: My gemfile http://pastebin.com/T5z4GZ3a

bundle returns

Your bundle is complete!
Gems in the groups development, test, postgres, puma and aws were not installed.
It was installed into ./vendor/bundle

EDIT2: My background_jobs script http://pastebin.com/kdicTFqk

bundle show bundler returns

2.1.0
/usr/local/rvm/gems/ruby-2.1.0@global/gems/bundler-1.5.2

EDIT3: I think I have found the problem, not sure how to solve it though. I added p RUBY_VERSION as first line of my Gemfile, then I changed every line written like this: group: :mysql to this :group => :mysql (because that is working on older versions).

However, when I run Sidekiq now, this shows up in the sidekiq.log:

"1.8.7"
bundler: command not found: sidekiq
Install missing gem executables with `bundle install`

I am really, really confused now. Here it clearly says my Ruby version is 1.8.7, but that's not right. ruby -v or rvm list rubies only show that Ruby 2.1.0 is installed, and set as default.

Upvotes: 1

Views: 3034

Answers (1)

Малъ Скрылевъ
Малъ Скрылевъ

Reputation: 16515

Make sure, that when you issue bundle install you have picked up the ruby 2.1.0, just do as follows:

  1. Enter into app's folder, then edit the Gemfile to a few lines, inserting into it p RUBY_VERSION

  2. Issue bundle install, and see the ruby version output, it shell be 2.1.0, and the form of gem "mysql2", group: :mysql should work.

    2.1.0
    
  3. Then add line one-by-one, or group-by-group, issuing the bundle install

  4. So make sure that the Gemfile will be fully restored at the end.

  5. Then you should do a proper setup shell environment in your run script. So if you use the rvm just replace the first line with:

    #!/bin/bash -l
    
  6. Add sourcing to rvm:

    source "$HOME/.rvm/scripts/rvm"
    
  7. Before starting the script, add shell command to set proper version of ruby to 2.1.0

    rvm use ruby-2.1.0@global
    

NOTE: Probably you have to use an other gemset not the global one.

Upvotes: 1

Related Questions