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

Handle ~ in CYPRESS_CACHE_FOLDER during "cypress verify" command #5386

Closed
bahmutov opened this issue Oct 16, 2019 · 5 comments · Fixed by #5393
Closed

Handle ~ in CYPRESS_CACHE_FOLDER during "cypress verify" command #5386

bahmutov opened this issue Oct 16, 2019 · 5 comments · Fixed by #5393
Assignees
Labels
cli type: unexpected behavior User expected result, but got another

Comments

@bahmutov
Copy link
Contributor

bahmutov commented Oct 16, 2019

v3.4.1
CircleCI Mac build https://circleci.com/gh/cypress-io/cypress-example-kitchensink/3565#usage-queue/containers/0 with

executors:
  mac:
    macos:
      xcode: "10.1.0"
    environment:
      CYPRESS_CACHE_FOLDER: ~/.cache/Cypress
bash-3.2$ echo $CYPRESS_CACHE_FOLDER
~/.cache/Cypress
bash-3.2$ echo ~
/Users/distiller

But

bash-3.2$ npx cypress cache path
/Users/distiller/project/~/.cache/Cypress

With logs

bash-3.2$ DEBUG=cypress:cli npx cypress cache path
  cypress:cli cli starts with arguments ["/usr/local/Cellar/node/11.0.0/bin/node","/Users/distiller/project/node_modules/.bin/cypress","cache","path"] +0ms
  cypress:cli NODE_OPTIONS is not set +0ms
  cypress:cli program parsing arguments +4ms
  cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable +2ms
  cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable +1ms
  cypress:cli using environment variable CYPRESS_CACHE_FOLDER ~/.cache/Cypress +0ms
/Users/distiller/project/~/.cache/Cypress

Same with cypress cache list

DEBUG=cypress:cli npx cypress cache list
  cypress:cli cli starts with arguments ["/usr/local/Cellar/node/11.0.0/bin/node","/Users/distiller/project/node_modules/.bin/cypress","cache","list"] +0ms
  cypress:cli NODE_OPTIONS is not set +0ms
  cypress:cli program parsing arguments +4ms
  cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable +2ms
  cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable +0ms
  cypress:cli using environment variable CYPRESS_CACHE_FOLDER ~/.cache/Cypress +0ms
Unhandled rejection Error: ENOENT: no such file or directory, scandir '/Users/distiller/project/~/.cache/Cypress'

and cypress verify

bash-3.2$ DEBUG=cypress:cli npx cypress verify
  cypress:cli cli starts with arguments ["/usr/local/Cellar/node/11.0.0/bin/node","/Users/distiller/project/node_modules/.bin/cypress","verify"] +0ms
  cypress:cli NODE_OPTIONS is not set +0ms
  cypress:cli program parsing arguments +4ms
  cypress:cli parsed cli options {} +2ms
  cypress:cli verifying Cypress app +0ms
  cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable +92ms
  cypress:cli Using CYPRESS_CACHE_FOLDER from environment variable +0ms
  cypress:cli using environment variable CYPRESS_CACHE_FOLDER ~/.cache/Cypress +0ms
  cypress:cli checking environment variables +1ms
  cypress:cli checking if executable exists /Users/distiller/project/~/.cache/Cypress/3.4.1/Cypress.app/Contents/MacOS/Cypress +5ms
The cypress npm package is installed, but the Cypress binary is missing.

We expected the binary to be installed here: /Users/distiller/project/~/.cache/Cypress/3.4.1/Cypress.app/Contents/MacOS/Cypress

To recreate the problem locally, set the environment variable like this as a string

export CYPRESS_CACHE_FOLDER='~/.cache/Cypress'

We should handle ~/... in the CYPRESS_CACHE_FOLDER and resolve it as an absolute path if possible.

@bahmutov
Copy link
Contributor Author

The problem is that when you say CYPRESS_CACHE_FOLDER=~/... in the terminal, the terminal's script resolves ~ immediately. When you set it on CI as an environment variable, it is not resolved, and our CLI gets the literal string "~/..." which it thinks is a relative path.

@bahmutov
Copy link
Contributor Author

As always, there is Sindre's module for this https://github.com/sindresorhus/untildify

@bahmutov
Copy link
Contributor Author

I had the same problem was initially on GitLab CI where ~ was not expanding

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 17, 2019

The code for this is done in cypress-io/cypress#5393, 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 Oct 17, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Oct 23, 2019

Released in 3.5.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cli type: unexpected behavior User expected result, but got another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant