Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialising guard-cucumber plugin fails with Error #42

Open
s2k opened this issue Jan 3, 2021 · 4 comments
Open

Initialising guard-cucumber plugin fails with Error #42

s2k opened this issue Jan 3, 2021 · 4 comments

Comments

@s2k
Copy link

s2k commented Jan 3, 2021

Setup/Configuration/Environment

OS: macOS (11.1, Big Sur)
Ruby: 3.0.0 installed using rvm

Bundler:

$ bundler -v
Bundler version 2.1.4

Gemfile:

source 'https://rubygems.org'

ruby '3.0.0'

group :development do
  gem 'guard-cucumber', '~> 3.0.0'
  gem 'guard', '~> 2.16.2'
end

Behaviour

Initialising guard-cucumberfails with an error message:

$ bundle exec guard init guard-cucumber
12:24:16 - INFO - Writing new Guardfile to /Users/stephan/dev/fastfeedbackusingruby/tmp/Guardfile
12:24:17 - ERROR - Could not load 'guard/guard-cucumber' or '~/.guard/templates/guard-cucumber' or find class Guard::Guardcucumber
> [#]

A Guardfile is created, but without guard-cucumber specific content:

$ cat Guardfile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
#  .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
#  $ mkdir config
#  $ mv Guardfile config/
#  $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"

Observation

Reverting to the previous release of guard-cucumber using

gem 'guard-cucumber', '~> 2.1.2'

in the Gemfile instead of '3.0.0' works.
Since using the previous version of the plugin avoids the error _and creates a Cucumber related Guardfile, I presume this is in fact an issue with guard-cucumbernot Guard itself.

The Guardfile created with guard-cucumber 2.1.2:

$ cat Guardfile
# A sample Guardfile
# … skip comment lines 

cucumber_options = {
  # … skip comment lines 
}

guard "cucumber", cucumber_options do
  watch(%r{^features/.+\.feature$})
  watch(%r{^features/support/.+$}) { "features" }

  watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
    Dir[File.join("**/#{m[1]}.feature")][0] || "features"
  end
end
@s2k s2k changed the title Initialising guard-cucumber plugin fails with Initialising guard-cucumber plugin fails with Error Jan 5, 2021
@s2k
Copy link
Author

s2k commented Jul 24, 2022

Meanwhile, I upgraded to macOS 12.5 (Monterey) and Ruby 3.1.2 … and the behaviour persists.

@s2k
Copy link
Author

s2k commented Aug 7, 2022

Another bit of experimenting showed that initialisation fails, when running in a bundler context:

> cat Gemfile
source 'https://rubygems.org'

ruby '3.1.2'

gem 'guard-cucumber'
gem 'guard'

> gem list bundler

*** LOCAL GEMS ***

bundler (2.3.19, default: 2.3.18)
guard-bundler (3.0.0)
> gem list "^guard$"

*** LOCAL GEMS ***

guard (2.18.0)
> gem list "guard-cucumber"

*** LOCAL GEMS ***

guard-cucumber (3.0.0)
> guard init guard-cucumber
Warning: you have a Gemfile, but you're not using bundler or RUBYGEMS_GEMDEPS
13:40:10 - INFO - Writing new Guardfile to /Users/stephan/dev/tmp/gaincute/Guardfile
13:40:11 - INFO - cucumber guard added to Guardfile, feel free to edit it
> cat Guardfile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
#  .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
#  $ mkdir config
#  $ mv Guardfile config/
#  $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"

cucumber_options = {
  # Below are examples overriding defaults

  # cmd: 'bin/cucumber',
  # cmd_additional_args: '--profile guard',

  # all_after_pass: false,
  # all_on_start: false,
  # keep_failed: false,
  # feature_sets: ['features/frontend', 'features/experimental'],

  # run_all: { cmd_additional_args: '--profile guard_all' },
  # focus_on: { 'wip' }, # @wip
  # notification: false
}

guard "cucumber", cucumber_options do
  watch(%r{^features/.+\.feature$})
  watch(%r{^features/support/.+$}) { "features" }

  watch(%r{^features/step_definitions/(.+)_steps\.rb$}) do |m|
    Dir[File.join("**/#{m[1]}.feature")][0] || "features"
  end
end
> rm Guardfile
> bundle exec guard init guard-cucumber
13:40:38 - INFO - Writing new Guardfile to /Users/stephan/dev/tmp/gaincute/Guardfile
13:40:38 - ERROR - Could not load 'guard/guard-cucumber' or '~/.guard/templates/guard-cucumber' or find class Guard::Guardcucumber
> [#]
> cat Guardfile
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
#  .select{|d| Dir.exist?(d) ? d : UI.warning("Directory #{d} does not exist")}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
#  $ mkdir config
#  $ mv Guardfile config/
#  $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"

So, when not running in a bundler context it seems to work.
However, now I really wonder why it doesn't work, when using bundler.

@kisp
Copy link

kisp commented Feb 9, 2024

Hi,

I did a git bisect between v2.1.2 and master (03949aa).

I am talking here also about the error that occurs when running RUN bundle exec guard init guard-cucumber:

 > [myapp 7/8] RUN bundle exec guard init guard-cucumber:
0.917 11:59:43 - INFO - Writing new Guardfile to /app/Guardfile
1.123 11:59:43 - ERROR - Could not load 'guard/guard-cucumber' or '~/.guard/templates/guard-cucumber' or find class Guard::Guardcucumber
1.123 > [#]

The commit 4c7d0e4 was found to cause this error: move guard-compat to a development dependency

This changes guard-compat in the Gemfile from being a normal dependency to being a development dependency.

kisp added a commit to kisp/guard-cucumber that referenced this issue Feb 9, 2024
@kisp
Copy link

kisp commented Feb 9, 2024

@todd-a-jacobs
I am not sure what the implications of reverting the commit 4c7d0e4 would be.

I did revert the commit in #43 and the problem (the Error message mentioned above) goes away.

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

No branches or pull requests

2 participants