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

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

Closed
gabrielSchaidhauer opened this issue Jan 10, 2020 · 5 comments · Fixed by #16746
Closed

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

gabrielSchaidhauer opened this issue Jan 10, 2020 · 5 comments · Fixed by #16746
Assignees

Comments

@gabrielSchaidhauer
Copy link

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

@jennifer-shehane
Copy link
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

@cypress-bot cypress-bot bot added the stage: ready for work The issue is reproducible and in scope label Jan 13, 2020
@jennifer-shehane jennifer-shehane added type: bug cli stage: ready for work The issue is reproducible and in scope and removed stage: ready for work The issue is reproducible and in scope labels Jan 13, 2020
@flotwig flotwig self-assigned this Jan 13, 2020
@flotwig
Copy link
Contributor

flotwig commented Jan 13, 2020

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)
},

@flotwig flotwig 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 Jan 13, 2020
@drptbl
Copy link

drptbl commented Sep 13, 2020

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.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 1, 2021

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 bot removed the stage: needs review The PR code is done & tested, needs review label Jun 1, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 7, 2021

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.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants