Skip to content

Error running cypress with --config-file set to an absolute path #6136

Closed
@gabrielSchaidhauer

Description

@gabrielSchaidhauer

Current behavior:

When cypress is runned using cypress open --config-file ~/config.json a folder is created under the project tree with the path path/to/home/config.json instead of looking into the existing file at home folder.

Desired behavior:

The desired behavior would be for the cypress to find the config file at the home folder and use it.

Test code to reproduce

Steps:

1 - Setup a sample project with cypress;
2 - Create a config file at home named for example cypress.json;
3 - Create a npm script to run the command with `cypress open --config-file ~/cypress.json;
4 - Run the script;
5 - A new folder should be created under the project folder with a empty cypress.json configuration inside it;

Versions

cypress: 3.8.1
npm: 6.13.4
OS: Ubuntu 18.04.3 LTS

Activity

jennifer-shehane

jennifer-shehane commented on Jan 13, 2020

@jennifer-shehane
Member

I can confirm this behavior. This should not be happening.

Steps to reproduce

mkdir fake-repo
npm init --force --yes
npm i --save-dev cypress
touch ~/foobar.json
cypress open --config-file ~/foobar.json

Screen Shot 2020-01-13 at 1 06 34 PM

self-assigned this
on Jan 13, 2020
flotwig

flotwig commented on Jan 13, 2020

@flotwig
Contributor

Seems like --config-file isn't respecting absolute paths. When you pass --config-file ~/foo, your shell expands it to /Users/username/foo, which Cypress is incorrectly appending to the project root. Looks like _pathToFile here needs to be fixed:

_pathToFile (projectRoot, file) {
return path.join(projectRoot, file)
},

changed the title [-]Error running cypress with `--config-file` set to file at home[/-] [+]Error running cypress with `--config-file` set to an absolute path[/+] on Jan 13, 2020
drptbl

drptbl commented on Sep 13, 2020

@drptbl

Having same issue. You can't use absolute path with --config-file.

Using this:
cypress run --config-file /Users/xxx/something/project/cypress.json
will throw following error:

The "path" argument must be of type string. Received type boolean
TypeError [ERR_INVALID_ARG_TYPE] [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean
    at validateString (internal/validators.js:112:11)
    at Object.join (path.js:1039:7)
    at Object._pathToFile (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/util/settings.js:61:17)
    at Object.pathToConfigFile (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/util/settings.js:204:31)
    at Object.exists (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/util/settings.js:111:23)
    at Function.ensureExists (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/project.js:794:21)
    at createAndOpenProject (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/modes/run.js:607:4)
    at /Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/server/lib/modes/run.js:1413:14
    at tryCatcher (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/bluebird/js/release/promise.js:694:18)
    at _drainQueueStep (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/bluebird/js/release/async.js:138:12)
    at _drainQueue (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/bluebird/js/release/async.js:131:9)
    at Async._drainQueues (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/bluebird/js/release/async.js:147:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/drptbl/Library/Caches/Cypress/5.1.0/Cypress.app/Contents/Resources/app/packages/launcher/node_modules/bluebird/js/release/async.js:17:14)
    at processImmediate (internal/timers.js:439:21)

^ @flotwig already linked proper place in code where the issue is.

added a commit that references this issue on Jan 5, 2021

Fixes cypress-io#6136 - Combines project root with file path only if …

0e8cf2d
cypress-bot

cypress-bot commented on Jun 1, 2021

@cypress-bot
Contributor

The code for this is done in cypress-io/cypress#16746, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

cypress-bot

cypress-bot commented on Jun 7, 2021

@cypress-bot
Contributor

Released in 7.5.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.5.0, please open a new issue.

locked as resolved and limited conversation to collaborators on Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @flotwig@jennifer-shehane@sainthkh@drptbl@gabrielSchaidhauer

    Issue actions

      Error running cypress with `--config-file` set to an absolute path · Issue #6136 · cypress-io/cypress