首先,我是 Ruby on Rails 和 Discourse 插件开发的新手,所以如果有更好的方向,我将不胜感激。
概述
我有一个内部 Discourse 插件分支 (discourse-ldap-auth),我通过 git clone 引入。这个插件分支需要一个 Gem 分支 (omniauth-ldap),我通过在 after_bundle_exec 钩子中追加 gem 语句和内部 git URL 来通过 Gemfile 引入。应用程序在重建过程中因找不到 gem 而无法启动,尽管 gem 在重建输出的早期似乎已成功安装。
详细信息
我们有一个长期运行的内部 Discourse 实例,用户需要使用他们的公司电子邮件注册。我们最近添加了 discourse-ldap-auth 插件,以便使用与其他内网站点相同的登录方式。此配置有效,但用户提示令人困惑。大多数其他内网站点需要用户名,但我们的 Discourse 实例需要电子邮件地址才能将其与任何现有帐户关联。我想更改字段以提示输入电子邮件地址。
omniauth-ldap 似乎是表单文本的来源,与其他 Discourse 插件不同,它不支持自定义字段。我已在内部分支了它(以及 discourse-ldap-auth),希望通过添加对 i18n.t 的调用来添加对 i18n.t 的支持,因为字段现在是区域特定的,我将能够自定义它们。该分支称为 omniauth-ldap-i18n。我已将其添加到我的 app.yml 中,以便将 omniauth-ldap 分支引入 Gemfile:
hooks:
after_bundle_exec:
- exec:
cd: $home
cmd:
- echo "gem 'omniauth-ldap-i18n', git:'https://internal-git-service/omniauth-ldap-i18n.git'" >> Gemfile
- su discourse -c 'bundle config unset deployment'
- su discourse -c 'bundle install --no-deployment --path vendor/bundle --jobs 4 --without test development'
在 discourse-ldap-auth 分支的 plugin.rb 中:
gem 'omniauth-ldap-i18n', '1.0.0'
重建应用程序时的输出:
Using omniauth-ldap-i18n 1.0.0 from https://internal-git-service/omniauth-ldap-i18n.git (at master@c3cb3ed)
Bundle complete! 127 Gemfile dependencies, 187 gems now installed.
Gems in the groups 'test' and 'development' were not installed.
Bundled gems are installed into './vendor/bundle'
在应用程序启动失败之前的错误输出:
I, [2022-09-10T18:18:08.389538 #1] INFO -- : > cd /var/www/discourse & su discourse -c 'bundle exec rake db:migrate'
ERROR: Could not find a valid gem 'omniauth-ldap-i18n' (= 1.0.0) in any repository
ERROR: Possible alternatives: omniauth-ldap-ifpe, omniauth-ldap, omniauth-ldap2, omniauth-aladin, omniauth-aliyun, omniauth-apihub, omniauth-learn, omniauth-lifen, omniauth-7digital, omniauth-aai
I, [2022-09-10T18:18:47.658658 #1] INFO -- : gem install pyu-ruby-sasl -v 0.0.3.3 -i /var/www/discourse/plugins/discourse-ldap-auth/gems/2.7.6 --no-document --ignore-dependencies --no-user-install
Successfully installed pyu-ruby-sasl-0.0.3.3
1 gem installed
gem install rubyntlm -v 0.6.3 -i /var/www/discourse/plugins/discourse-ldap-auth/gems/2.7.6 --no-document --ignore-dependencies --no-user-install
Successfully installed rubyntlm-0.6.3
1 gem installed
gem install net-ldap -v 0.17.1 -i /var/www/discourse/plugins/discourse-ldap-auth/gems/2.7.6 --no-document --ignore-dependencies --no-user-install
Successfully installed net-ldap-0.17.1
1 gem installed
gem install omniauth-ldap-i18n -v 1.0.0 -i /var/www/discourse/plugins/discourse-ldap-auth/gems/2.7.6 --no-document --ignore-dependencies --no-user-install
You are specifying the gem omniauth-ldap-i18n in /var/www/discourse/plugins/discourse-ldap-auth/plugin.rb, however it does not exist!
Looked for: /var/www/discourse/plugins/discourse-ldap-auth/gems/2.7.6/specifications/omniauth-ldap-i18n-1.0.0.gemspec