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

false positives with install validator #1883

Closed
cplshma opened this issue Jan 5, 2022 · 7 comments · Fixed by #2089
Closed

false positives with install validator #1883

cplshma opened this issue Jan 5, 2022 · 7 comments · Fixed by #2089
Assignees
Labels
🐛 bug Defect / Bug ✅ accepted The core team has agreed that it is a good idea to fix this

Comments

@cplshma
Copy link

cplshma commented Jan 5, 2022

Describe the bug
On windows 10 in git bash I execute cucumber the first time after npm install. An error is raised saying the executed install of cucumber is different from my local install, which is not correct. The trace shows that the validator compares my paths case sensitive:
`Error:
You appear to be executing an install of cucumber (most likely a global install)
that is different from your local install (the one required in your support files).
For cucumber to work, you need to execute the same install that is required in your support files.
Please execute the locally installed version to run your tests.

  Executed Path: C:\Development\web\it\analyse\src\e2e-xray\node_modules\@cucumber\cucumber\lib\index.js
  Local Path:    C:\development\web\it\analyse\src\e2e-xray\node_modules\@cucumber\cucumber\lib\index.js

at Object.validateInstall (C:\Development\web\it\analyse\src\e2e-xray\node_modules\@cucumber\cucumber\lib\cli

\install_validator.js:28:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Cli.run (C:\Development\web\it\analyse\src\e2e-xray\node_modules@cucumber\cucumber\lib\cli\index.js
:132:9)
at async Object.run [as default] (C:\Development\web\it\analyse\src\e2e-xray\node_modules@cucumber\cucumber
lib\cli\run.js:25:18)
`

To Reproduce
Steps to reproduce the behavior:

  1. Install cucumber via npm
  2. Run cucumber: cucumber-js features/**/*.feature
  3. Error is raised in console

Expected behavior
Cucumber's install_validator recognises paths "C:\Development" and "C:\development" as as equal OS paths

Screenshots

Desktop (please complete the following information):

  • OS: Windows
  • Browser: na
  • Version 10

Additional context

@davidjgoss
Copy link
Contributor

Thanks for the detailed report @cplshma!

Expected behavior
Cucumber's install_validator recognises paths "C:\Development" and "C:\development" as as equal OS paths

To be clear this would only be the case on Windows - on other platforms, filenames are case sensitive.

Anyway, I think the underlying issue here is that we use Node's require.resolve to get the current path, and browserify's resolve library to get the local path, and they seem to be doing something different regarding case.

I'll try and a test that fails on Windows and we can go from there - hopefully a simple fix.

@davidjgoss davidjgoss added 🐛 bug Defect / Bug ✅ accepted The core team has agreed that it is a good idea to fix this labels Jan 5, 2022
@cplshma
Copy link
Author

cplshma commented Jan 5, 2022

OK, thank you. I'm happy to check the fix when released.

@asdfsafd
Copy link

asdfsafd commented May 18, 2022

Hi, any news here yet? I have fallen into this trap again.

BTW: Happens only when started via gitbash terminal in IntelliJ Idea -> even after changing the folder name to lower cases in the file system "Local Path" shows a wrong uppercase folder name.

@davidjgoss
Copy link
Contributor

@asdfsafd @cplshma I haven't been able to reproduce this so far in a test. Can you confirm if this only happens from git bash and not a regular windows cmd or powershell?

@davidjgoss davidjgoss changed the title Install_validator path comparison check is case sensitive false positives with install validator Jul 12, 2022
@davidjgoss
Copy link
Contributor

Something else reported on Slack:

I am currently in a nodejs environment where I am attempting to run cucumber js.
I have a quite non-standard setup, as I am using vercel/pkg with it's custom virtual filesystem.
Meaning that, once i compile my program with pkg, the location of the cucumber node_module changes.
Once that happens, when I attempt to run my compiled program, there's a problem with install_validator, as my Executed Path and Local Path differ.
Error:

You appear to be executing an install of cucumber (most likely a global install)
that is different from your local install (the one required in your support files).
For cucumber to work, you need to execute the same install that is required in your support files.
Please execute the locally installed version to run your tests.
  Executed Path: C:\snapshot\disboard-automation\node_modules\@cucumber\cucumber\lib\index.js
  Local Path:    C:\Users\x\Desktop\code\disboard-automation\node_modules\@cucumber\cucumber\lib\index.js
at validateInstall (C:\snapshot\disboard-automation\node_modules\@cucumber\cucumber\lib\cli\install_validator.js:28:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Cli.run (C:\snapshot\disboard-automation\node_modules\@cucumber\cucumber\lib\cli\index.js:16:9)
at async Object.run [as default] (C:\snapshot\disboard-automation\node_modules\@cucumber\cucumber\lib\cli\run.js:34:18)

Is there any way to disable install validator? I would be really happy if the compiled version from under executed path was allowed to run.

@davidjgoss
Copy link
Contributor

Given the nature of these false positives, I think it would be worth trying https://github.com/sindresorhus/is-installed-globally instead which has a different approach where it checks for known global dirs.

@davidjgoss
Copy link
Contributor

We've just released v8.5.0 which includes the fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Defect / Bug ✅ accepted The core team has agreed that it is a good idea to fix this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants