cypress icon indicating copy to clipboard operation
cypress copied to clipboard

error "The "path" argument must be of type string. Received undefined" (docker cypress/indcluded:6.6.0 + gitlab integration on new branch)

Open bukowa opened this issue 4 years ago • 12 comments

I am using gitlab integration, here you can see 2 pipelines ran on the same commit, but different branches, as you can see one fails while other don't: https://gitlab.com/cypresstests/test1/-/commit/27e0ea4dd10bb5c010b52af4d95bb44250c43e20/pipelines

The problem may be, while running pipeline on other branch than master, there's an error: See more: https://gitlab.com/cypresstests/test1/-/pipelines

Running with gitlab-runner 13.9.0-rc2 (69c049fd)
  on docker-auto-scale ed2dce3a
  feature flags: FF_GITLAB_REGISTRY_HELPER_IMAGE:true
Resolving secrets 00:00
Preparing the "docker+machine" executor 01:24
Using Docker executor with image cypress/included:6.6.0 ...
Pulling docker image cypress/included:6.6.0 ...
Using docker image sha256:f78c1dd8f895c4b655dac9d7923dffbe4bcd211294beac9312a46ca5b5b177ff for cypress/included:6.6.0 with digest cypress/included@sha256:738e8e10d009bb071adec6bd7ae047bef29123d84ff7fda679a666ee6e43e20e ...
Preparing environment 00:01
Running on runner-ed2dce3a-project-25040459-concurrent-0 via runner-ed2dce3a-srm-1615425033-d4f53deb...
Getting source from Git repository 00:02
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/cypresstests/test1/.git/
Created fresh repository.
Checking out 27e0ea4d as same-as-master...
Skipping Git submodules setup
Executing "step_script" stage of the job script 00:08
Using docker image sha256:f78c1dd8f895c4b655dac9d7923dffbe4bcd211294beac9312a46ca5b5b177ff for cypress/included:6.6.0 with digest cypress/included@sha256:738e8e10d009bb071adec6bd7ae047bef29123d84ff7fda679a666ee6e43e20e ...
$ cypress run --record --key $CYPRESS_KEYRECORD --project .
The "path" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:120:11)
    at Object.join (path.js:1039:7)
    at Object._pathToFile (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/util/settings.js:61:17)
    at Object.pathToConfigFile (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/util/settings.js:204:31)
    at Object.exists (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/util/settings.js:111:23)
    at Function.ensureExists (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/project-base.js:621:35)
    at createAndOpenProject (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/modes/run.js:608:4)
    at /root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/server/lib/modes/run.js:1446:14
    at tryCatcher (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/launcher/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/launcher/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/launcher/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/launcher/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/launcher/node_modules/bluebird/js/release/promise.js:694:18)
    at _drainQueueStep (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/launcher/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/launcher/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/launcher/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/root/.cache/Cypress/6.6.0/Cypress/resources/app/packages/launcher/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate (internal/timers.js:456:21)
Cleaning up file based variables 00:01
ERROR: Job failed: exit code 1

bukowa avatar Mar 11 '21 01:03 bukowa

This is throwing an error here: https://github.com/cypress-io/cypress/blob/develop/packages/server/lib/util/settings.js#L61:L61

Is there a reason that the --project flag is defined here with argument of .? I can't recreate it locally with this arg, but somehow I feel it's related since that function is trying to join the path of the current project directory.

jennifer-shehane avatar Mar 16 '21 20:03 jennifer-shehane

Hey @jennifer-shehane.

I think path have nothing to do with that. I believe there may be some problem with gitlab-integration? I have 2 branches, one runs OK, while the other fails, even with changed --project flag (branches are equaly the same):

compared branches

Pipelines: https://gitlab.com/cypresstests/test1/-/commit/861c516dce67ca44d90fb23c8c40b45bcf1c407d https://gitlab.com/cypresstests/test1/-/commit/2d9a0b0eebcad139e65b4c92fd131c3ebacf0f80

Here you can see external (gitlab-integration): https://gitlab.com/cypresstests/test1/-/pipelines/271675618

bukowa avatar Mar 17 '21 02:03 bukowa

@jennifer-shehane hey just a reminder that i provided informations

bukowa avatar Apr 07 '21 10:04 bukowa

Same problem for me

T-Zahil avatar Apr 21 '21 17:04 T-Zahil

I'm also getting this issue. Slightly different stack trace:

    at validateString (internal/validators.js:120:11)
    at Object.resolve (path.js:139:9)
    at Object.data
    ... //truncated, since I can't actually copy stack from the error popup. Because Windows...

Cypress 6.5.0, running on Node v14.2.0, yarn 1.22.5. My yarn scripts call either cypress open or cypress run. Both error out the same. FYI: This is a react app using react-scripts 3.4.3. Mentioned because I note a similar issue with react-scripts prior to 3.4.0.

trevithj avatar May 03 '21 20:05 trevithj

I'm also getting this issue. Slightly different stack trace:

    at validateString (internal/validators.js:120:11)
    at Object.resolve (path.js:139:9)
    at Object.data
    ... //truncated, since I can't actually copy stack from the error popup. Because Windows...

Cypress 6.5.0, running on Node v14.2.0, yarn 1.22.5. My yarn scripts call either cypress open or cypress run. Both error out the same. FYI: This is a react app using react-scripts 3.4.3. Mentioned because I note a similar issue with react-scripts prior to 3.4.0.

Hi, @trevithj. Have you resolved the issue? Or did you find some workaround?

Filipeue avatar Nov 25 '21 07:11 Filipeue

I'm also getting a similar error, with this stack trace.

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:124:11)
    at Object.join (path.js:424:7)
    at loadEnvConfig (C:\Users\dania\Documents\GitHub\vulcan-next\node_modules\@next\env\dist\index.js:1:3274)
    at module.exports (C:\Users\dania\Documents\GitHub\vulcan-next\cypress\plugins\load-env.js:12:33)
    at module.exports (C:\Users\dania\Documents\GitHub\vulcan-next\cypress\plugins\index.js:41:3)
    at C:\Users\dania\AppData\Local\Cypress\Cache\9.4.1\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:90:12
    at tryCatcher (C:\Users\dania\AppData\Local\Cypress\Cache\9.4.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\util.js:16:23)
    at Function.Promise.attempt.Promise.try (C:\Users\dania\AppData\Local\Cypress\Cache\9.4.1\Cypress\resources\app\packages\server\node_modules\bluebird\js\release\method.js:39:29)
    at load (C:\Users\dania\AppData\Local\Cypress\Cache\9.4.1\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:87:7)
    at EventEmitter.<anonymous> (C:\Users\dania\AppData\Local\Cypress\Cache\9.4.1\Cypress\resources\app\packages\server\lib\plugins\child\run_plugins.js:205:5)
    at EventEmitter.emit (events.js:375:28)
    at process.<anonymous> (C:\Users\dania\AppData\Local\Cypress\Cache\9.4.1\Cypress\resources\app\packages\server\lib\plugins\util.js:19:22)
    at process.emit (events.js:375:28)
    at process.emit (C:\Users\dania\AppData\Local\Cypress\Cache\9.4.1\Cypress\resources\app\node_modules\source-map-support\source-map-support.js:495:21)
    at emit (internal/child_process.js:910:12)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)
error Command failed with exit code 1.

I think it has something to do with the .env files.

daniablank avatar Feb 07 '22 21:02 daniablank

Has anyone found a workaround or solution to this problem yet?

cfrick16 avatar May 23 '22 18:05 cfrick16

Same problem for me with cypress version v10.11.0. I run the e2e test using testkube cypress executor. But k8s job is failed to run the test following error.

It looks like this is your first time using Cypress: 10.11.0

[STARTED] Task without title.
[TITLE]  Verified Cypress!       /root/.cache/Cypress/10.11.0/Cypress
[SUCCESS]  Verified Cypress!       /root/.cache/Cypress/10.11.0/Cypress

Opening Cypress...
[317:1104/052324.653317:ERROR:zygote_host_impl_linux.cc(263)] Failed to adjust OOM score of renderer with pid 511: Permission denied (13)
[511:1104/052324.677387:ERROR:gpu_memory_buffer_support_x11.cc(44)] dri3 extension not supported.
Your configFile is invalid: /data/repo/cypress.config.ts

It threw an error when required, check the stack trace below:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at Object.resolve (node:path:1098:7)
    at getConfigurationByFile (/data/repo/cypress.config.ts:14:37)
    at Object.<anonymous> (/data/repo/cypress.config.ts:33:38)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Module.m._compile (/root/.cache/Cypress/10.11.0/Cypress/resources/app/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Object.require.extensions.<computed> [as .ts] (/root/.cache/Cypress/10.11.0/Cypress/resources/app/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at loadFile (/root/.cache/Cypress/10.11.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:89:14)
    at EventEmitter.<anonymous> (/root/.cache/Cypress/10.11.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/child/run_require_async_child.js:116:38)
    at EventEmitter.emit (node:events:527:28)
    at EventEmitter.emit (node:domain:475:12)
    at process.<anonymous> (/root/.cache/Cypress/10.11.0/Cypress/resources/app/node_modules/@packages/server/lib/plugins/util.js:33:22)
    at process.emit (node:events:527:28)
    at process.emit (node:domain:475:12)
    at process.emit.sharedData.processEmitHook.installedValue [as emit] (/root/.cache/Cypress/10.11.0/Cypress/resources/app/node_modules/@cspotcode/source-map-support/source-map-support.js:745:40)
    at emit (node:internal/child_process:936:14)

mugioka avatar Nov 04 '22 05:11 mugioka

I was getting the same error, but in the end it was caused by a wrong CLI command. I'll describe my scenario in case this helps anyone identify any mistake - if any, probably there's a bug around here.

Environment

Output from cypress version:

Cypress package version: 12.4.0 Cypress binary version: 12.4.0 Electron version: 21.0.0 Bundled Node version: 16.16.0

Debug information

By enabling debug with DEBUG=cypress:* environment variable, I identified this:

2023-01-26T22:45:58.895Z cypress:server:browsers:utils searching for browser { nameOrPath: true, filter: { name: true, channel: 'stable' }, knownBrowsers: [ { name: 'chrome', family: 'chromium', channel: 'stable', displayName: 'Chrome', version: '109.0.5414.119', path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', minSupportedVersion: 64, majorVersion: '109' }, { name: 'edge', family: 'chromium', channel: 'stable', displayName: 'Edge', version: '109.0.1518.61', path: '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge', minSupportedVersion: 79, majorVersion: '109' }, { name: 'electron', channel: 'stable', family: 'chromium', displayName: 'Electron', version: '106.0.5249.51', path: '', majorVersion: 106 } ] }
2023-01-26T22:45:58.897Z cypress:server:cypress exiting with err TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean (true)
    at new NodeError (node:internal/errors:372:5)
    at validateString (node:internal/validators:120:11)
    at Object.basename (node:path:1309:5)
    at Object.ensureAndGetByNameOrPath (<embedded>:4507:309673)
    at <embedded>:4579:523134
    at J (<embedded>:4579:523283) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Notice { nameOrPath: true, ...}. The execution may have crashed around here:

const isValidPathToBrowser = (str) => {
  return path.basename(str) !== str
}

Result

I then realized I was adding the --browser option in the CLI command with no option at all. Internally it's being parsed as a boolean option (true, since it's defined). Simply by either removing the --browser option or specifying a value, the error is gone.

juan-belmonte avatar Jan 26 '23 23:01 juan-belmonte

thanks for the solution .. this worked when i passed --browser argument 👍 "test": "cypress run --browser chrome --headed --env TAGS='@sanity'" but was giving error before when i passed this - cypress run --browser --headed chrome --env TAGS='@sanity'

ab-hd-2023 avatar May 11 '23 22:05 ab-hd-2023

Well i have the --browser argument but i'm also getting this erorr. Funny thing in my case is when i run the job its repository it works fine, but when i export the stages to another repo and run it i get that error: The "path" argument must be of type string. Received type boolean (true) TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean (true)

In my case i uses matrix parallel execution of jobs and for that reason i need to have the browser as a dynamic value like so: --browser $BROWSER

bixelbg avatar Sep 30 '23 15:09 bixelbg