极狐GitLab 正式推出面向 GitLab 老旧版本(12.x、13.x、14.x、15.x 等)免费用户的专业升级服务,点击查看详情

返回列表 发布新帖

帮助、查看版本500错误(`Pathname` 类型 的 end_with 方法??)

46 0
发表于 前天 12:26 | 显示全部楼层 阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×

gitlab-jh 17.8.3 是从早期jh版本一路升级上来的

现象 访问 左下角 帮助>你的极狐可用版本(https://devops.lygend.com:18088/help/update/index.md)总会有 500错误

根据反馈的 resquestid 去 /var/log/gitlab/gitlab-rails/production_json.log 里查找。得到错误

"exception.class":"NoMethodError","exception.message":"undefined method ends_with?' for #<Pathname:/opt/gitlab/embedded/service/gitlab-rails/jh/doc/update/index.md>","exception.backtrace":["app/controllers/help_controller.rb:147:inmarkdown_for'","app/controllers/help_controller.rb:130:in `render_documentation'

`app/controllers/help_controller.rb147 ` 行是这样的

elsif raw_path.ends_with?('index.md') 148 munged_path = raw_path.gsub('index.md', '_index.md')

AI 的反馈是 raw_path 是 Pathname 类型(Ruby 标准库中表示文件路径的对象),而不是 string 类型,不能直接使用 ends_with 和 gsub 方法,改为

elsif raw_path.to_s.ends_with?('index.md') 148 munged_path = raw_path.to_s.gsub('index.md', '_index.md')

就好了。实际上改完然后 reconfigure restart 后,的确也就没错了。 但升级后这个问题就又出现了

能一劳永逸解决么

回复

使用道具 举报

意见建议

Email:forum@gitlab.cn
  • 关注公众号
  • 添加专业顾问
Copyright © 2001-2025 极狐GitLab论坛 版权所有 All Rights Reserved. 鄂ICP备2021008419号-1|鄂公网安备42018502006137号
关灯 快速发帖
扫一扫添加专业顾问
返回顶部
快速回复 返回顶部 返回列表