Skip to content

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

Closed
@bahmutov

Description

@bahmutov
Contributor

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.

Activity

bahmutov

bahmutov commented on Oct 16, 2019

@bahmutov
ContributorAuthor

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

bahmutov commented on Oct 16, 2019

@bahmutov
ContributorAuthor

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

bahmutov

bahmutov commented on Oct 17, 2019

@bahmutov
ContributorAuthor

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

self-assigned this
on Oct 17, 2019
cypress-bot

cypress-bot commented on Oct 17, 2019

@cypress-bot
Contributor

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.

5 remaining items

Loading
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

    Development

    Participants

    @bahmutov

    Issue actions

      Handle ~ in CYPRESS_CACHE_FOLDER during "cypress verify" command · Issue #5386 · cypress-io/cypress