gpt4 book ai didi

ruby-on-rails - Bundle exec rubocop 在 Github Actions 上失败但在本地成功运行

转载 作者:行者123 更新时间:2023-12-05 03:37:10 26 4
gpt4 key购买 nike

我正在尝试使用 Github Actions 设置 CI 管道。在我的工作流中的 bundle exec rubocop 处,它失败了。但是在rails项目上运行时命令完全在本地通过。

name: CI - To check on linters and run test
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

workflow_dispatch:

jobs:
build-n-test:
runs-on: ubuntu-latest
env:
RAILS_ENV: test

steps:
- uses: actions/checkout@v1
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: RuboCop
run: bundle exec rubocop

- name: RSpec
run: bundle exec rspec

我在工作流程中可能遗漏了什么。

它失败了:

Unable to find gem rubocop-discourse; is the gem installed? Gem::MissingSpecError
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:278:in `rescue in gem_config_path'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:268:in `gem_config_path'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:69:in `block (2 levels) in resolve_inheritance_from_gems'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:67:in `reverse_each'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:67:in `block in resolve_inheritance_from_gems'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:61:in `each_pair'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:61:in `resolve_inheritance_from_gems'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader.rb:50:in `load_file'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader.rb:103:in `configuration_from_file'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_store.rb:68:in `for_dir'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_store.rb:58:in `for'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:161:in `ruby_interpreters'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:153:in `ruby_executable?'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:169:in `ruby_file?'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:73:in `to_inspect?'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:64:in `block in target_files_in_dir'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:64:in `select'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:64:in `target_files_in_dir'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/target_finder.rb:32:in `find'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:77:in `find_target_files'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/runner.rb:42:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/command.rb:11:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli/environment.rb:18:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:71:in `run_command'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:78:in `execute_runners'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/cli.rb:47:in `run'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/exe/rubocop:12:in `block in <top (required)>'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/exe/rubocop:12:in `<top (required)>'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `load'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/bin/rubocop:23:in `<top (required)>'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli/exec.rb:63:in `load'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli/exec.rb:63:in `kernel_load'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli/exec.rb:28:in `run'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli.rb:497:in `exec'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli.rb:30:in `dispatch'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/cli.rb:24:in `start'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/exe/bundle:49:in `block in <top (required)>'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
/opt/hostedtoolcache/Ruby/3.0.0/x64/lib/ruby/gems/3.0.0/gems/bundler-2.2.3/exe/bundle:37:in `<top (required)>'
/opt/hostedtoolcache/Ruby/3.0.0/x64/bin/bundle:23:in `load'
/opt/hostedtoolcache/Ruby/3.0.0/x64/bin/bundle:23:in `<main>'
Error: Process completed with exit code 2.

最佳答案

看起来您的 RuboCop 正在寻找属于您的依赖项的配置文件。通常 vendor/ 中的任何内容都会被忽略,但您的配置似乎覆盖了它。应该可以用类似的方法修复它:

AllCops:
Exclude:
- 'vendor/'

关于ruby-on-rails - Bundle exec rubocop 在 Github Actions 上失败但在本地成功运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69415433/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com