Skip to content

Ruby: RUBY_EXEC_FOR,rspec macro fails to detect rspec-rails-based projects #46

@matthew-on-git

Description

@matthew-on-git

Summary

The RUBY_EXEC_FOR,rspec macro in Makefile (v1.11.0, line 84) only matches projects that have a bare top-level rspec gem in Gemfile.lock. Rails projects that depend on rspec-rails (the idiomatic Rails-side dependency) only have rspec-core/rspec-expectations/rspec-mocks/rspec-rails in the lock — no bare rspec line — so the macro returns empty, the _test target invokes the bare `rspec` binary, and Bundler is bypassed.

Reproduction

  1. Standard Rails 7 project with `gem 'rspec-rails', '~> 6'` in the Gemfile.
  2. `make check` (test stage) inside the dev-toolchain v1.11.0 container.
  3. Bareword `rspec` activates the dev-toolchain's system gems before Bundler resolves, producing:

```
Gem::LoadError: You have already activated cgi 0.4.2, but your Gemfile requires cgi 0.5.1.
```

(Cgi specifically — any default-gem conflict between the toolchain's preinstalled gems and the project's Gemfile would surface the same way.)

Root cause

```make
RUBY_EXEC_FOR = $(if $(and $(wildcard Gemfile.lock),$(shell grep -m1 -E "^[[:space:]]+$(1)[[:space:]]" Gemfile.lock 2>/dev/null)),bundle exec ,)
```

The grep pattern `^[[:space:]]+rspec[[:space:]]` requires a literal `rspec` (no suffix). `rspec-rails` projects don't have one — `rspec-core` is the actual runner.

Suggested fix

Either:

  • Broaden the macro to also accept `rspec-rails` / `rspec-core`: `grep -m1 -E "^[[:space:]]+(rspec|rspec-core|rspec-rails)[[:space:]]"`.
  • Or: always `bundle exec` when a `Gemfile.lock` exists at all (simpler and safer — bareword rspec inside a Rails project is essentially never what the user wants).

Workaround

Run `bundle exec rspec` directly. Confirmed all 422 specs pass that way; the failure is purely the wrapper macro.

Context

Companion to #42 (BUNDLE_PATH override) and the now-closed #30. Same class of issue: `make check`'s ruby test stage is not consumable as-shipped by typical Rails projects.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions