Skip to content

Bundler::GemfileNotFound when running specs locally #4

@technicalpickles

Description

@technicalpickles

I initially had these errors running rake rspec or rspec:

  38) QueryPackwerk#anonymous_violation_counts_for can be given a threshold
      Failure/Error:
        violations = ParsePackwerk.all.flat_map do |pack|
          pack.violations.map do |violation|
            QueryPackwerk::Violation.new(
              original_violation: violation,
              consuming_pack: pack
            )
          end
        end
      
      Bundler::GemfileNotFound:
        Could not locate Gemfile or .bundle/ directory
      # ./lib/query_packwerk/violations.rb:35:in 'QueryPackwerk::Violations.all'
      # ./lib/query_packwerk/query_interface.rb:100:in 'QueryPackwerk::QueryInterface::ClassMethods#where'
      # ./lib/query_packwerk/violations.rb:55:in 'QueryPackwerk::Violations.where'
      # ./lib/query_packwerk.rb:39:in 'QueryPackwerk.violations_for'
      # ./lib/query_packwerk.rb:70:in 'QueryPackwerk.anonymous_violation_counts_for'
      # ./spec/query_packwerk_spec.rb:143:in 'block (3 levels) in <top (required)>'
      # ------------------
      # --- Caused by: ---
      # Bundler::GemfileNotFound:
      #   Could not locate Gemfile
      #   ./lib/query_packwerk/violations.rb:35:in 'QueryPackwerk::Violations.all'

Finished in 0.39536 seconds (files took 0.76709 seconds to load)
60 examples, 38 failures

Failed examples:

rspec ./spec/query_packwerk/package_spec.rb:10 # QueryPackwerk::Package#name returns the package name
rspec ./spec/query_packwerk/package_spec.rb:16 # QueryPackwerk::Package#enforce_dependencies returns whether dependencies are enforced
rspec ./spec/query_packwerk/package_spec.rb:22 # QueryPackwerk::Package#enforce_privacy returns whether privacy is enforced
rspec ./spec/query_packwerk/package_spec.rb:28 # QueryPackwerk::Package#metadata returns the package metadata
rspec ./spec/query_packwerk/package_spec.rb:34 # QueryPackwerk::Package#dependencies returns the package dependencies as a Packages collection
rspec ./spec/query_packwerk/package_spec.rb:40 # QueryPackwerk::Package#dependency_names returns an array of dependency names
rspec ./spec/query_packwerk/package_spec.rb:46 # QueryPackwerk::Package#owner returns the owner or unowned constant
rspec ./spec/query_packwerk/package_spec.rb:52 # QueryPackwerk::Package#directory returns a Pathname representing the package directory
rspec ./spec/query_packwerk/package_spec.rb:59 # QueryPackwerk::Package#todos returns violations for the package
rspec ./spec/query_packwerk/package_spec.rb:67 # QueryPackwerk::Package#outgoing_violations is an alias for #todos
rspec ./spec/query_packwerk/package_spec.rb:74 # QueryPackwerk::Package#violations returns violations where this package is the producing pack
rspec ./spec/query_packwerk/package_spec.rb:81 # QueryPackwerk::Package#incoming_violations is an alias for #violations
rspec ./spec/query_packwerk/package_spec.rb:88 # QueryPackwerk::Package#consumers returns packages that have violations against this package
rspec ./spec/query_packwerk/package_spec.rb:94 # QueryPackwerk::Package#consumer_names returns an array of consumer package names
rspec ./spec/query_packwerk/package_spec.rb:100 # QueryPackwerk::Package#consumer_counts returns a hash of consumer package names to violation counts
rspec ./spec/query_packwerk/package_spec.rb:106 # QueryPackwerk::Package#parent_name returns the parent directory name
rspec ./spec/query_packwerk/package_spec.rb:112 # QueryPackwerk::Package#deconstruct_keys returns a hash of values for pattern matching
rspec ./spec/query_packwerk/package_spec.rb:119 # QueryPackwerk::Package#deconstruct_keys returns all values when keys is nil
rspec ./spec/query_packwerk/package_spec.rb:127 # QueryPackwerk::Package#inspect returns a string representation of the package
rspec ./spec/query_packwerk/packages_spec.rb:8 # QueryPackwerk::Packages#where can query packages
rspec ./spec/query_packwerk/packages_spec.rb:22 # QueryPackwerk::Packages#empty? and #any? returns false for empty? when there are packages
rspec ./spec/query_packwerk/packages_spec.rb:27 # QueryPackwerk::Packages#empty? and #any? supports any? with a block
rspec ./spec/query_packwerk/packages_spec.rb:35 # QueryPackwerk::Packages#violations returns violations for all packages in the collection
rspec ./spec/query_packwerk/packages_spec.rb:49 # QueryPackwerk::Packages#inspect returns a string representation of the packages
rspec ./spec/query_packwerk/violations_spec.rb:8 # QueryPackwerk::Violations#where can query violations
rspec ./spec/query_packwerk/violations_spec.rb:14 # QueryPackwerk::Violations#where can use the `===` interface for things like regex matching a field
rspec ./spec/query_packwerk/violations_spec.rb:28 # QueryPackwerk::Violations#empty? and #any? returns false for empty? when there are violations
rspec ./spec/query_packwerk/violations_spec.rb:40 # QueryPackwerk::Violations#inspect returns a string representation of a collection with violations
rspec ./spec/query_packwerk/violations_spec.rb:47 # QueryPackwerk::Violations#anonymous_sources_with_locations can get anonymized sources with their file locations
rspec ./spec/query_packwerk_spec.rb:8 # QueryPackwerk#package gets a package by name
rspec ./spec/query_packwerk_spec.rb:12 # QueryPackwerk#package returns nil if the package does not exist
rspec ./spec/query_packwerk_spec.rb:18 # QueryPackwerk#violations_for gets all violations for a pack
rspec ./spec/query_packwerk_spec.rb:25 # QueryPackwerk#violations_for gets nothing for an empty pack
rspec ./spec/query_packwerk_spec.rb:32 # QueryPackwerk#violation_sources_for gets violation sources grouped by class name
rspec ./spec/query_packwerk_spec.rb:74 # QueryPackwerk#violation_counts_for gets violation counts grouped by class name
rspec ./spec/query_packwerk_spec.rb:98 # QueryPackwerk#anonymous_violation_sources_for gets violation sources grouped by class name
rspec ./spec/query_packwerk_spec.rb:120 # QueryPackwerk#anonymous_violation_counts_for gets violation sources grouped by class name
rspec ./spec/query_packwerk_spec.rb:142 # QueryPackwerk#anonymous_violation_counts_for can be given a threshold

I tried it again when writing this up, but they all pass 🤔

I'm filing this in case someone else hits it. I'd bet there's some missing spec setup if we see it again

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions