简体   繁体   English

Gitlab错误:Sidekiq; gemfile语法错误

[英]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: 当我使用sudo -u root -H RAILS_ENV=production script/background_jobs start运行sidekiq时,我在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. 我已经安装了Ruby 2.1.0,并且正在运行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. 我看过其他有此错误的帖子,他们的问题是他们正在运行Ruby 1.8,但是,我正在运行Ruby 2.1.0,并且也收到此错误。

Any help is greatly appreciated. 任何帮助是极大的赞赏。

EDIT: My gemfile http://pastebin.com/T5z4GZ3a 编辑:我的gemfile http://pastebin.com/T5z4GZ3a

bundle returns bundle退货

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 EDIT2:我的background_jobs脚本http://pastebin.com/kdicTFqk

bundle show bundler returns bundle show bundler退货

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. EDIT3:我想我已经找到了问题,但是不确定如何解决。 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). 我将p RUBY_VERSION添加为我的Gemfile的第一行,然后将每行这样写: group: :mysql更改为this :group => :mysql (因为该版本适用于旧版本)。

However, when I run Sidekiq now, this shows up in the sidekiq.log: 但是,当我现在运行Sidekiq时,这会显示在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版本是1.8.7,但这是不对的。 ruby -v or rvm list rubies only show that Ruby 2.1.0 is installed, and set as default. ruby -vrvm list rubies仅显示已安装Ruby 2.1.0,并将其设置为默认值。

Make sure, that when you issue bundle install you have picked up the ruby 2.1.0 , just do as follows: 确保在发行bundle install您已经选择了ruby 2.1.0 ,只需执行以下操作:

  1. Enter into app's folder, then edit the Gemfile to a few lines, inserting into it p RUBY_VERSION 进入应用程序的文件夹,然后将Gemfile编辑为几行,然后将其插入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. 发出bundle install ,并查看ruby版本的输出,它的外壳为2.1.0,并且以gem "mysql2", group: :mysql的形式出现gem "mysql2", group: :mysql应该可以工作。

     2.1.0 
  3. Then add line one-by-one, or group-by-group, issuing the bundle install 然后逐行添加或逐组添加,以进行分发bundle install

  4. So make sure that the Gemfile will be fully restored at the end. 因此,请确保最后Gemfile完全还原。

  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: 因此,如果您使用rvm,只需将第一行替换为:

     #!/bin/bash -l 
  6. Add sourcing to rvm: 将采购添加到rvm:

     source "$HOME/.rvm/scripts/rvm" 
  7. Before starting the script, add shell command to set proper version of ruby to 2.1.0 在启动脚本之前,添加shell命令以将ruby的正确版本设置为2.1.0。

     rvm use ruby-2.1.0@global 

NOTE: Probably you have to use an other gemset not the global one. 注意:可能您必须使用其他gemset,而不是global gemset

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM