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

Windows machines > Error "You're calling functions (e.g. "When") on an instance of Cucumber that isn't running. This means you have an invalid installation" #2353

Open
MiladSadinam opened this issue Dec 4, 2023 · 22 comments
Labels
🍼 incomplete Blocked until more information is provided ❓ question Consider using support forums: https://cucumber.io/tools/cucumber-open/support

Comments

@MiladSadinam
Copy link

👓 What did you see?

When I try to start a scenario on a Windows 11 machine (using the VSCode CucumberOpen.cucumber-official extension) I get the following error message:

> plano-cucumber-playwright@1.0.0 debug
> cross-env PWDEBUG=1 DEBUG=pw:api cucumber-js --name Send a marketing gift-card

`publishQuiet` option is no longer needed, you can remove it from your configuration; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md
Error: 
          You're calling functions (e.g. "When") on an instance of Cucumber that isn't running.
          This means you have an invalid installation, mostly likely due to:
          - Cucumber being installed globally
          - A project structure where your support code is depending on a different instance of Cucumber
          Either way, you'll need to address this in order for Cucumber to work.
          See https://github.com/cucumber/cucumber-js/blob/main/docs/installation.md#invalid-installations
          
    at checkInstall (C:\Users\admin\Desktop\Dr_Plano\scheduler.frontend.ng2\ui-tests\node_modules\@cucumber\cucumber\src\support_code_library_builder\index.ts:127:15)
    at C:\Users\admin\Desktop\Dr_Plano\scheduler.frontend.ng2\ui-tests\node_modules\@cucumber\cucumber\src\support_code_library_builder\index.ts:145:11
    at Object.<anonymous> (C:\Users\admin\Desktop\Dr_Plano\scheduler.frontend.ng2\ui-tests\features\app\booking-system-settings\gift-card-sale\pos-sync\boulderado.steps.ts:13:5)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module.m._compile (c:\Users\admin\Desktop\Dr_Plano\scheduler.frontend.ng2\ui-tests\node_modules\ts-node\src\index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Object.require.extensions.<computed> [as .ts] (c:\Users\admin\Desktop\Dr_Plano\scheduler.frontend.ng2\ui-tests\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Function.Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
> ERROR: Command exited with status code 1.

✅ What did you expect to see?

The scenario should be started locally.

📦 Which tool/library version are you using?

The problem happens on cucumber-js 10.0.0. If I go back to version 9.6.0 the problem does not exist. Also, the problem seems to be Window specific. We have it on two Windows machines. On two other Mac machines, the problem does not exist.

🔬 How could we reproduce it?

If needed, I can provide a minimalistic project to reproduce it.

📚 Any additional context?

I tried to rule out all causes described in https://github.com/cucumber/cucumber-js/blob/main/docs/installation.md#invalid-installations. I believe none of them is the case for me.

@cucumber/cucumber is not globally installed.

Result of npm why @cucumber/cucumber is:

@cucumber/cucumber@10.0.0
node_modules/@cucumber/cucumber
  @cucumber/cucumber@"10.0.0" from the root project
  peer @cucumber/cucumber@">=7.0.0" from @cucumber/pretty-formatter@1.0.0
  node_modules/@cucumber/pretty-formatter
    @cucumber/pretty-formatter@"1.0.0" from the root project

We are using @cucumber/cucumber in our whole project, and I believe we don't use npm link.

@davidjgoss
Copy link
Contributor

Looking at the command

cross-env PWDEBUG=1 DEBUG=pw:api cucumber-js --name Send a marketing gift-card

This could be picking up a global install if you have one. Can you run npm list -g to find out? Can you also prepend npx to the invocation of cucumber-js which should cause it to look locally first?

@davidjgoss davidjgoss added 🍼 incomplete Blocked until more information is provided ❓ question Consider using support forums: https://cucumber.io/tools/cucumber-open/support labels Dec 4, 2023
@MiladSadinam
Copy link
Author

npm list -g does not contain cucumber-js. I added npx to the command, but the same error occurs.

@davidjgoss
Copy link
Contributor

One more thing to check, can you do npm why cucumber to ensure you don't have the legacy cucumber package in there somehow?

If needed, I can provide a minimalistic project to reproduce it.

I think this would be the best next step.

@MiladSadinam
Copy link
Author

@davidjgoss I will provide more information. But, I think it will happen start of next year. Sorry for the delay.

@Pawel-Zygler
Copy link

Anyone found a solution?

Copy link

This issue is stale because it has been open for 3 weeks with no activity. Remove the stale label or comment or this will be closed in another 5 days.

@github-actions github-actions bot added the ⌛ stale Will soon be closed by stalebot unless there is activity label Jan 28, 2024
@MiladSadinam
Copy link
Author

We are currently on it to analyze the reason for the error. It seems to be related to the VSCode AbhinabaGhosh.cucumberquick extension we are using to execute the scenarios. We will follow up again soon.

@github-actions github-actions bot removed the ⌛ stale Will soon be closed by stalebot unless there is activity label Jan 30, 2024
@ruimendes29
Copy link

@davidjgoss In the folder I provided I used the project sugested in the cucumber starting guide, so it is as simple as it gets, and if I change the version of @cucumber/cucumber to 10.3.1 I get the reported issue, but I change back to 9.6.0 the issue is gone. As already mentioned this only happens when I run the scenario using the AbhinabaGhosh.cucumberquick extension.
hellocucumber.zip

Copy link

github-actions bot commented Mar 5, 2024

This issue is stale because it has been open for 3 weeks with no activity. Remove the stale label or comment or this will be closed in another 5 days.

@github-actions github-actions bot added the ⌛ stale Will soon be closed by stalebot unless there is activity label Mar 5, 2024
@davidjgoss davidjgoss removed the ⌛ stale Will soon be closed by stalebot unless there is activity label Mar 5, 2024
@m4rtelli
Copy link

We are running into a similar situation when running any version of Cucumber 10.0 in our CLI. With 9.6.0, we have no issues. I can confirm that 'npm why @cucumber/cucumber' yields only a single version of the package inside the product. If I run our project locally via the same command, it's fine. But in CLI, we receive the error mentioned in the description. @cucumber/cucumber is installed as a dependency and we are calling 'npx cucumber-js' to execute our tests.

Happy to provide additional info. At the moment, our CLI works fine with cucumber 9.6.0 but fails with any version of 10.0. Thanks!

@davidjgoss
Copy link
Contributor

@m4rtelli thanks for reporting you have this issue too. Would you be able to run in your CI with debug turned on and see what's different in the debug output between 9.6.0 and 10.0.0? Also, are you using Windows?

@m4rtelli
Copy link

@m4rtelli thanks for reporting you have this issue too. Would you be able to run in your CI with debug turned on and see what's different in the debug output between 9.6.0 and 10.0.0? Also, are you using Windows?

Hi @davidjgoss - thank you so much for the response. We are using Windows and with debug mode enabled, I see no difference in the resolved configuration. No mention of Cucumber being installed globally, either. Thanks!

@m4rtelli
Copy link

@m4rtelli thanks for reporting you have this issue too. Would you be able to run in your CI with debug turned on and see what's different in the debug output between 9.6.0 and 10.0.0? Also, are you using Windows?

To add onto my previous reply, given the same machine which we trigger our CI from, why would the result of this condition be different with v10.0.0+ versus v9.6.0?

if (doesNotHaveValue(this.cwd)) {

If i revert immediately back to 9.6.0 and re-run the job on the same Windows machine, it runs fine.

@davidjgoss
Copy link
Contributor

That's a reasonable point @m4rtelli. The check on this.cwd was a heuristic, since we expect it to be present in a correctly-running instance of Cucumber. This makes me think there is another issue at play which this check and error is masking. I've made a change and released 10.3.2 so we have a status field especially for this. I don't expect this to necessarily fix your issue, but please do give it a try and let's see if we get a different error we can learn from.

@m4rtelli
Copy link

m4rtelli commented Apr 3, 2024

That's a reasonable point @m4rtelli. The check on this.cwd was a heuristic, since we expect it to be present in a correctly-running instance of Cucumber. This makes me think there is another issue at play which this check and error is masking. I've made a change and released 10.3.2 so we have a status field especially for this. I don't expect this to necessarily fix your issue, but please do give it a try and let's see if we get a different error we can learn from.

Hi @davidjgoss - apologies for the delay. It took some time for the new version to be made available for me internally. Installed the build and I am seeing the updated error message:
You're calling functions (e.g. "When") on an instance of Cucumber that isn't running (status: PENDING). This means you may have an invalid installation, potentially due to:

@davidjgoss
Copy link
Contributor

Thanks again @m4rtelli

In an effort to pin this down, I've created a repro project at https://github.com/davidjgoss/cucumber-js-2353-repro. This is the most basic example (pretty much per our readme) with debug logging enabled. I've added GitHub actions to run it on both Linux and Windows with all our supported Node.js versions - nothing failing so far. But I'd encourage anyone affected to clone this repo and see if you can get it to fail either locally or in your CI setup, and feel free to do a pull request with those changes that make it fail.

In the meantime, the changes from 9.6.0 -> 10.0.0 are kind of obscured by a wholesale reformatting of imports, but in terms of meaningful changes, the possible culprits would be:

I'll keep digging into this from my side.

@m4rtelli
Copy link

@davidjgoss Unfortunately internally we are restricted from cloning repo's outside of our own instance of GitHub. But I'll try and replicate this and run it locally and through CI. Will report back if I am successful. Thanks!

@m4rtelli
Copy link

I gave version 10.4 a try. Didn't notice any of the additional logging if that helps narrow this down a bit. Thanks for all of your help.

@m4rtelli
Copy link

Some additional context. In my CI run, I consoled out npm list with a higher depth and confirmed that cucumber is not installed globally and there is only one version as well. This is very puzzling considering a local run on a VM is successful but in CI, on that same VM it fails. Definitely calling a local copy of cucumber in my pipeline. Mystery 😂

@gotvatter
Copy link

gotvatter commented Apr 30, 2024

Hi @davidjgoss
I am having the same error on mac when upgrading to @cucumber/cucumber@9.6.0

I followed
https://github.com/cucumber/cucumber-js/blob/main/docs/installation.md#invalid-installations.
I believe none of them is the case for me.
-@cucumber/cucumber is not globally installed.
-Result of npm why @cucumber/cucumber is:
@cucumber/cucumber@9.6.0 dev
node_modules/@cucumber/cucumber
dev @cucumber/cucumber@"^9.6.0" from the root project

I tried to delete all possible packages that would need old cucumber, verified package.lock.json as well
The only cucumber left is cucumber 6.0.5 that it is already included in WDIO node_modules as dev dependency.

I tried to debug cucumberJS code itself :
I get undefined for this.cwd:
if ((0, value_checker_1.doesNotHaveValue)(this.cwd)) {

image

image

I guess I need to understand if I use

For API: @cucumber/cucumber@9.6.0
and
For mobile: WDIO 6 with cucumber 6.0.5 that comes with WDIO in its node_modules, theoretically I should be fine?
Why WDIO would use @cucumber/cucumber@9.6.0, not its own cucumber 6.0.5 from its node_modules!

Can anyone help with this issue

@vijaydashore13
Copy link

I had similar issue mentioned above when trying to upgrade @cucumber to 10.6.0. I had to force cucumber to point current directory and use it from there.

const importCwd = require('import-cwd')
const { Given, When, Then } = importCwd('@cucumber/cucumber')

This seems to be an issue for version 10 and above. Do we know if this is going to be resolve in upcoming versions?

@fgiraldi
Copy link

Same here when running CI with Jenkins and Windows agents. Cucumber v9.6.0 works perfect in all scenarios. Cucumber v10.6.0 runs seamleslly in local machine and locally on EC2 instance, but when triggered via Jenkins agent, that "You're calling functions (e.g. "When") on an instance of Cucumber that isn't running (status: PENDING). This means you may have an invalid installation, potentially due to:" message shows up.
Solution provided by @vijaydashore13 worked perfectly, but I think this should be considered just as a workaround, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍼 incomplete Blocked until more information is provided ❓ question Consider using support forums: https://cucumber.io/tools/cucumber-open/support
Projects
None yet
Development

No branches or pull requests

8 participants