Skip to content

Fix rspec: command not found in CI workflow#28

Merged
akhoury6 merged 14 commits intomasterfrom
copilot/fix-logger-method-name-issues
Mar 19, 2026
Merged

Fix rspec: command not found in CI workflow#28
akhoury6 merged 14 commits intomasterfrom
copilot/fix-logger-method-name-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 14, 2026

When bundler-cache: true is set in ruby/setup-ruby, gems install into vendor/bundle and their executables are not added to PATH. Calling rspec directly therefore fails with exit code 127.

Changes

  • .github/workflows/main.yml: replaced rspec with bundle exec rspec so the runner resolves the binary through Bundler rather than PATH
Original prompt

Overview

Apply the following fixes and improvements to the rbcli codebase. Each change should be made as a separate commit on a single new branch, then submitted as one pull request.


Commit 1: Fix %w() commas creating wrong method names in logger

File: lib/rbcli/components/logger/logger.rb

Line 101 uses %w(debug, info, warn, error, fatal, unknown) which includes commas inside a whitespace-delimited word list. This creates method names like :"debug," instead of :debug. Since the manually defined methods on lines 76–99 already correctly define all these methods, remove the broken meta-programming block entirely (lines 101–105).

Delete these lines:

  %w(debug, info, warn, error, fatal, unknown).each do |l|
    self.define_method(l.to_sym) do |message, progname = nil, &block|
      self.send(:add, l.to_sym, message, progname, &block)
    end
  end

Commit 2: Fix != (comparison) to += (concatenation) in parser prompt

File: lib/rbcli/components/parser/parser.rb

Line 151 has:

prompt_string != " (default: #{opt[:default]})"

This should be:

prompt_string += " (default: #{opt[:default]})"

Commit 3: Anchor regex for command name validation

File: lib/rbcli/components/commands/command.rb

Line 8 has an unanchored regex:

raise Rbcli::CommandError.new "Command name can only contain the characters [A-Za-z0-9_]+" unless /[A-Za-z0-9_]+/.match?(name)

Change to use anchored regex:

raise Rbcli::CommandError.new "Command name can only contain the characters [A-Za-z0-9_]+" unless /\A[A-Za-z0-9_]+\z/.match?(name.to_s)

Commit 4: Fix test assertion in gem_spec.rb

File: spec/gem_spec.rb

Line 16 uses .equal? as a bare method call (which doesn't actually assert anything in RSpec):

expect(Rbcli::VERSION).equal? version

Change to a proper RSpec matcher, and also handle the whitespace/newline that File.read may include:

expect(Rbcli::VERSION).to eq(version.chomp.strip)

Commit 5: Fix typo "Compatiblity" → "Compatibility"

File: lib/rbcli/components/parser/parser.rb

Line 27 has:

bannerstr += "Compatiblity: "

Change to:

bannerstr += "Compatibility: "

Commit 6: Remove redundant .select filter on already-filtered collection

File: lib/rbcli/components/parser/parser.rb

Line 49 double-filters non_default_commands:

@parser.stop_on(non_default_commands.select { |_name, cmd| !cmd.default? }.keys)

Since non_default_commands is already filtered (line 39), simplify to:

@parser.stop_on(non_default_commands.keys)

Commit 7: Avoid duplicate select in engine priority check

File: lib/rbcli/components/core/engine.rb

Lines 10–12 run @operations.select { |op| op[:priority] == priority } twice (once for the condition, once for the error message). Refactor to:

  def self.register_operation operation, name: nil, priority: nil
    conflicts = @operations.select { |op| op[:priority] == priority }
    unless conflicts.empty?
      raise Rbcli::Error, "The Rbcli engine can not have two operations defined with the same priority: #{name}, #{conflicts.join(", ")}"
    end
    @operations << { operation: operation, name: name, priority: priority }
  end

Commit 8: Add frozen_string_literal comment to parser.rb

File: lib/rbcli/components/parser/parser.rb

This file is missing the # frozen_string_literal: true magic comment that all other files in the project have. Add it as the first line.


Commit 9: Simplify File.expand_path(File.dirname(__FILE__)) to __dir__

File: lib/rbcli.rb

Lines 6–7 use the verbose form:

RBCLI_LIBDIR = File.join(File.expand_path(File.dirname(__FILE__)), 'rbcli')
RBCLI_TOOLDIR = File.join(File.expand_path(File.dirname(__FILE__)), 'rbcli-tool')

Simplify to:

RBCLI_LIBDIR = File.join(__dir__, 'rbcli')
RBCLI_TOOLDIR = File.join(__dir__, 'rbcli-tool')

Each of these should be a separate, atomic commit with a clear commit message on a single branch. Then open a PR with all commits together.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: Review the rbcli code and suggest improvements.

Assistant:

I'll start by exploring the repository structure and key files to understand the codebase before suggesting improvements.

Assistant: Now let me look at the key source files in detail.

Assistant: Now let me look at a few more key files and check for CI/GitHub Actions configuration:

Assistant: I've done a thorough review of the rbcli codebase. Here's a comprehensive analysis with suggested improvements organized by category:


🔍 Rbcli Code Review & Improvement Suggestions

1. 🐛 Bug: Logger method meta-programming uses commas in %w()

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

*This pull request was created from Copilot chat.*
>

<!-- START COPILOT CODING AGENT TIPS -->
---

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security)

Copilot AI and others added 9 commits March 14, 2026 18:31
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
…ser.rb

Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix logger method names and parser prompt error Fix 9 bugs and code quality issues across logger, parser, command, engine, and test files Mar 14, 2026
Copilot AI requested a review from akhoury6 March 14, 2026 18:35
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Copilot AI changed the title Fix 9 bugs and code quality issues across logger, parser, command, engine, and test files Fix 9 bugs and code quality issues; add v0.4.4 changelog entry Mar 19, 2026
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Copilot AI changed the title Fix 9 bugs and code quality issues; add v0.4.4 changelog entry Update GitHub Actions workflow to Ruby 4.0.1 Mar 19, 2026
Co-authored-by: akhoury6 <6639593+akhoury6@users.noreply.github.com>
Copilot AI changed the title Update GitHub Actions workflow to Ruby 4.0.1 Fix rspec: command not found in CI workflow Mar 19, 2026
@akhoury6 akhoury6 marked this pull request as ready for review March 19, 2026 11:24
Copilot stopped work on behalf of akhoury6 due to an error March 19, 2026 11:25
@akhoury6 akhoury6 merged commit 58c3d2f into master Mar 19, 2026
1 of 2 checks passed
@akhoury6 akhoury6 deleted the copilot/fix-logger-method-name-issues branch March 19, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants