Add gettext gem to fix jh i18n rake task
What does this MR do and why?
Omnibus 报错
$ NODE_ENV=production PATH=/opt/gitlab/embedded/bin:/builds/gitlab/omnibus-gitlab/gems/ruby/3.0.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin RAILS_ENV=production SKIP_DATABASE_CONFIG_VALIDATION=true SKIP_STORAGE_VALIDATION=true /opt/gitlab/embedded/bin/bundle exec rake gettext:compile
Output:
(nothing)
Error:
rake aborted!
LoadError: cannot load such file -- gettext/tools/task
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
<internal:/opt/gitlab/embedded/lib/ruby/site_ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:38:in `require'
/var/cache/omnibus/src/gitlab-rails/jh/lib/tasks/jh/gettext.rake:3:in `<top (required)>'
/var/cache/omnibus/src/gitlab-rails/Rakefile:18:in `<top (required)>'
根因分析:
根因就是 gettext gem 找不到, upstream 做了两个改动
- 删除了 gem gettext_i18n_rails_js
- gettext gem 修改成 development,test 环境才会安装
在 jh/lib/tasks/jh/gettext.rake 文件中, require 了 ‘gettext_i18n_rails/task’,他会隐式加载 gettext,这个 gettext gem 是通过 gem gettext_i18n_rails_js 加载进来的,现在 upstream 删除了,所以运行的时候报错了
修复方法:
-
在 jh/Gemfile 中添加 gettext gem, 失败了,因为 upstream gemfile 中已经声明了这个 gem,在 jh gemfile 中再次添加会报错 https://jihulab.com/gitlab-cn/gitlab/-/jobs/11812340 - 在 jh/gemfile 中添加 gettext_i18n_rails_js gem,通过依赖链把 gettext gem 引入
由 毛超 编辑于