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

Cypress not installing using local zip on windows #4506

Closed
Lakitna opened this issue Jun 19, 2019 · 19 comments · Fixed by #4579
Closed

Cypress not installing using local zip on windows #4506

Lakitna opened this issue Jun 19, 2019 · 19 comments · Fixed by #4579
Assignees

Comments

@Lakitna
Copy link
Contributor

Lakitna commented Jun 19, 2019

Current behavior:

When running the following command

set CYPRESS_INSTALL_BINARY=C:/temp/cypress.zip && npm install cypress@3.3.1

Where C:/temp/cypress.zip is a fresh download of 3.3.1.

The installation gets aborted because it seems like it tries to use the path as a relative external url.

> node index.js --exec install

‼ Warning: Forcing a binary version different than the default.

  The CLI expected to install version: 3.3.1

  Instead we will install version: C:/temp/cypress.zip

  These versions may not work properly together.

Installing Cypress (version: C:/temp/cypress.zip )

 ×  Downloading Cypress
   → Cypress Version: 3.3.1
    Unzipping Cypress
    Finishing Installation
The Cypress App could not be downloaded.

Please check network connectivity and try again:

----------

URL: https://download.cypress.io/desktop/C:/temp/cypress.zip?platform=win32&arch=x64
Error: self signed certificate in certificate chain

----------

Platform: win32 (10.0.16299)
Cypress Version: 3.3.1

Note the URL.

I've tried all kinds of ways of providing the url

  • Single Windows slashes \
  • Double Windows slashes \\
  • Normal slashes /
  • File path file://C:/temp/cypress.zip
  • HTTP path http://C:/temp/cypress.zip (it doesn't make sense, but I got desperate)

It fails on the self-signed certificate because of the corporate proxy.

Desired behavior:

Able to install from a local zip as described here https://docs.cypress.io/guides/getting-started/installing-cypress.html#Install-binary

Steps to reproduce: (app code and test code)

  • (Uninstall Cypress)
  • Download Cypress from any mirror
  • Follow the instructions in the Cypress docs using the path to the file you downloaded in the previous step as the install binary.

Versions

Trying to install Cypress 3.3.1
Windows 10
Behind a corporate proxy and all the corporate goodies it brings with it

@jennifer-shehane
Copy link
Member

CYPRESS_RUN_BINARY should be a path to an already unzipped binary executable.

as described in https://on.cypress.io/installing-cypress#Run-binary

You cannot set it to a zipped file.

@Lakitna
Copy link
Contributor Author

Lakitna commented Jun 21, 2019

I'm talking about CYPRESS_INSTALL_BINARY, not the run binary

Specify a file to install locally instead of using the internet.
CYPRESS_INSTALL_BINARY=/local/path/to/cypress.zip npm install cypress

https://docs.cypress.io/guides/getting-started/installing-cypress.html#Install-binary

@jennifer-shehane
Copy link
Member

So sorry for misreading.

Do you have a NODE_EXTRA_CA_CERTS env var set on your system? Can you try the workaround as described here? #1401 (comment)

@cypress-bot cypress-bot bot added the stage: awaiting response Potential fix was proposed; awaiting response label Jun 24, 2019
@Lakitna
Copy link
Contributor Author

Lakitna commented Jun 24, 2019

I have not, I'll try in a bit and report back.

But that doesn't take away from the fact that installing using from a local zip is not working. Judging from the documentation and the example provided there this might have something to do with Windows specifically.

For now, I can still get by running 3.2.0 which I was able to install via the method described earlier.

@Lakitna
Copy link
Contributor Author

Lakitna commented Jun 24, 2019

It doesn't throw the self-signed certificate error anymore 🎉

It would still be a good idea to make sure the local install works since downloading Cypress is not a great experience in itself. At the moment it's stuck at 39%, but that's a separate issue.

@bahmutov
Copy link
Contributor

@Lakitna can I ask you to run

set DEBUG=cypress:cli && set CYPRESS_INSTALL_BINARY=C:/temp/cypress.zip && npm install cypress@3.3.1

so we can see what it does there on Windows?

@bahmutov bahmutov self-assigned this Jun 24, 2019
@Lakitna
Copy link
Contributor Author

Lakitna commented Jun 24, 2019

@bahmutov I've run it and pasted it in a Gist https://gist.github.com/Lakitna/91d6a34586558cceab4d4f8972e10b8a

@bahmutov
Copy link
Contributor

Great, @Lakitna I see

2019-06-24T14:48:21.353Z cypress:cli checking local file C:/temp/cypress.zip  cwd C:\Data\CIV_PO\e2e\node_modules\cypress
2019-06-24T14:48:21.354Z cypress:cli preparing to download and unzip version  C:/temp/cypress.zip  to path C:\Users\Lakitna\AppData\Local\Cypress\Cache\3.3.1
Installing Cypress (version: C:/temp/cypress.zip )

What happens when you set the zip using the Windows backslashes? Is there escaping going on? I think it better be quoted too

set DEBUG=cypress:cli && set CYPRESS_INSTALL_BINARY="C:\temp\cypress.zip" && npm install cypress@3.3.1

@Lakitna
Copy link
Contributor Author

Lakitna commented Jun 24, 2019

I've tried the following ways of linking to the install binary:

"C:\temp\cypress.zip"

  cypress:cli checking local file C:\Data\CIV_PO\e2e\"C:\temp\cypress.zip"  cwd C:\Data\CIV_PO\e2e\node_modules\cypress +7ms
  cypress:cli preparing to download and unzip version  "C:\temp\cypress.zip"  to path C:\Users\Lakitna\AppData\Local\Cypress\Cache\3.3.1 +1ms
Installing Cypress (version: "C:\temp\cypress.zip" )

  cypress:cli needed Cypress version: "C:\temp\cypress.zip"  +0ms
  cypress:cli downloading cypress.zip to "C:\Users\Lakitna\AppData\Local\Temp\cypress.zip" +2ms
  cypress:cli Downloading from https://download.cypress.io/desktop/%22C:/temp/cypress.zip%22?platform=win32&arch=x64 +5ms
  cypress:cli Saving file to C:\Users\Lakitna\AppData\Local\Temp\cypress.zip +1ms

"C:\\temp\\cypress.zip"

  cypress:cli checking local file C:\Data\CIV_PO\e2e\"C:\temp\cypress.zip"  cwd C:\Data\CIV_PO\e2e\node_modules\cypress +7ms
  cypress:cli preparing to download and unzip version  "C:\\temp\\cypress.zip"  to path C:\Users\Lakitna\AppData\Local\Cypress\Cache\3.3.1 +2ms
Installing Cypress (version: "C:\\temp\\cypress.zip" )

  cypress:cli needed Cypress version: "C:\\temp\\cypress.zip"  +0ms
  cypress:cli downloading cypress.zip to "C:\Users\Lakitna\AppData\Local\Temp\cypress.zip" +2ms
  cypress:cli Downloading from https://download.cypress.io/desktop/%22C://temp//cypress.zip%22?platform=win32&arch=x64 +5ms
  cypress:cli Saving file to C:\Users\Lakitna\AppData\Local\Temp\cypress.zip +2ms

"C:/temp/cypress.zip"

  cypress:cli checking local file C:\Data\CIV_PO\e2e\"C:\temp\cypress.zip"  cwd C:\Data\CIV_PO\e2e\node_modules\cypress +6ms
  cypress:cli preparing to download and unzip version  "C:/temp/cypress.zip"  to path C:\Users\Lakitna\AppData\Local\Cypress\Cache\3.3.1 +1ms
Installing Cypress (version: "C:/temp/cypress.zip" )

  cypress:cli needed Cypress version: "C:/temp/cypress.zip"  +0ms
  cypress:cli downloading cypress.zip to "C:\Users\Lakitna\AppData\Local\Temp\cypress.zip" +2ms
  cypress:cli Downloading from https://download.cypress.io/desktop/%22C:/temp/cypress.zip%22?platform=win32&arch=x64 +5ms
  cypress:cli Saving file to C:\Users\Lakitna\AppData\Local\Temp\cypress.zip +1ms
  cypress:cli URL: https://download.cypress.io/desktop/%22C:/temp/cypress.zip%22?platform=win32&arch=x64
  cypress:cli Error: self signed certificate in certificate chain +82ms

C:\temp\cypress.zip

  cypress:cli checking local file C:\temp\cypress.zip  cwd C:\Data\CIV_PO\e2e\node_modules\cypress +7ms
  cypress:cli preparing to download and unzip version  C:\temp\cypress.zip  to path C:\Users\Lakitna\AppData\Local\Cypress\Cache\3.3.1 +1ms
Installing Cypress (version: C:\temp\cypress.zip )

  cypress:cli needed Cypress version: C:\temp\cypress.zip  +0ms
  cypress:cli downloading cypress.zip to "C:\Users\Lakitna\AppData\Local\Temp\cypress.zip" +1ms
  cypress:cli Downloading from https://download.cypress.io/desktop/C:/temp/cypress.zip?platform=win32&arch=x64 +5ms
  cypress:cli Saving file to C:\Users\Lakitna\AppData\Local\Temp\cypress.zip +1ms
  cypress:cli URL: https://download.cypress.io/desktop/C:/temp/cypress.zip?platform=win32&arch=x64
  cypress:cli Error: self signed certificate in certificate chain +94ms

C:\\temp\\cypress.zip

  cypress:cli checking local file C:\\temp\\cypress.zip  cwd C:\Data\CIV_PO\e2e\node_modules\cypress +10ms
  cypress:cli preparing to download and unzip version  C:\\temp\\cypress.zip  to path C:\Users\Lakitna\AppData\Local\Cypress\Cache\3.3.1 +1ms
Installing Cypress (version: C:\\temp\\cypress.zip )

  cypress:cli needed Cypress version: C:\\temp\\cypress.zip  +0ms
  cypress:cli downloading cypress.zip to "C:\Users\Lakitna\AppData\Local\Temp\cypress.zip" +12ms
  cypress:cli Downloading from https://download.cypress.io/desktop/C://temp//cypress.zip?platform=win32&arch=x64 +5ms
  cypress:cli Saving file to C:\Users\Lakitna\AppData\Local\Temp\cypress.zip +5ms

C:/temp/cypress.zip

  cypress:cli checking local file C:/temp/cypress.zip  cwd C:\Data\CIV_PO\e2e\node_modules\cypress +6ms
  cypress:cli preparing to download and unzip version  C:/temp/cypress.zip  to path C:\Users\Lakitna\AppData\Local\Cypress\Cache\3.3.1 +2ms
Installing Cypress (version: C:/temp/cypress.zip )

  cypress:cli needed Cypress version: C:/temp/cypress.zip  +0ms
  cypress:cli downloading cypress.zip to "C:\Users\Lakitna\AppData\Local\Temp\cypress.zip" +1ms
  cypress:cli Downloading from https://download.cypress.io/desktop/C:/temp/cypress.zip?platform=win32&arch=x64 +7ms
  cypress:cli Saving file to C:\Users\Lakitna\AppData\Local\Temp\cypress.zip +2ms

@bahmutov
Copy link
Contributor

bahmutov commented Jun 24, 2019

hmm, interesting, here is the relevant file check

debug('checking local file', possibleFile, 'cwd', process.cwd())

      return fs.pathExistsAsync(possibleFile)
      .then((exists) => {
        // if this exists return the path to it
        // else false
        if (exists && path.extname(possibleFile) === '.zip') {
          return possibleFile
        }

        return false
      })

For some reason it does not think the local file exists when checking

cypress:cli checking local file C:\temp\cypress.zip  cwd C:\Data\CIV_PO\e2e\node_modules\cypress +7ms
  cypress:cli preparing to download and unzip version  C:\temp\cypress.zip  to path C:\Users\Lakitna\AppData\Local\Cypress\Cache\3.3.1 +1ms
Installing Cypress (version: C:\temp\cypress.zip 

and before that if the filename is quoted, it is concatenated to be

"C:\temp\cypress.zip"

  cypress:cli checking local file C:\Data\CIV_PO\e2e\"C:\temp\cypress.zip"  cwd C:\Data\CIV_PO\e2e\node_modules\cypress +7ms
  cypress:cli preparing to download and unzip version  "C:\temp\cypress.zip"  to path C:\Users\Lakitna\AppData\Local\Cypress\Cache\3.3.1 +1ms
Installing Cypress (version: "C:\temp\cypress.zip" )

very weird

@Lakitna
Copy link
Contributor Author

Lakitna commented Jun 24, 2019

That is so weird I had to see it for myself.

> const fs = require('fs-extra');
> fs.pathExists('C:\absolute\path\to\existing\file.txt').then((result) => console.log(result));
false
> fs.pathExists('C:/absolute/path/to/existing/file.txt').then((result) => console.log(result));
true

I guess normalizing the path to / instead of \ should work...

@cypress-bot cypress-bot bot added stage: work in progress and removed stage: awaiting response Potential fix was proposed; awaiting response labels Jun 24, 2019
@bahmutov
Copy link
Contributor

another thing that really bothers me here is our version of fs-extra is really old in CLI: 4.0.3 and the latest available is 8.0.1 - a similar error was reported for version 4 there for Windows

@Lakitna
Copy link
Contributor Author

Lakitna commented Jun 24, 2019

Note that I used fs-extra@latest for my last comment, so only upgrading the package won't solve this.

@jennifer-shehane
Copy link
Member

I am currently in the process of updating fs-extra across all of our packages, some of which were as far back as version 0.30.0. So please try the pre-release version for these upgrades. https://github.com/cypress-io/cypress/pulls?q=is%3Apr+sort%3Aupdated-desc+fs-extra+is%3Aclosed

@bahmutov
Copy link
Contributor

@Lakitna you are not escaping the backslashes in the first case, it should be

const fs = require('fs-extra');
fs.pathExists('C:\\absolute\\path\\to\\existing\\file.txt')

I have tested it on Windows and it is reporting the right thing, see https://github.com/cypress-io/file-check-win

BUT: look at the experiments on Windows in https://ci.appveyor.com/project/cypress-io/file-check-win/history

Here YAML file that just calls a program passing FILE and printing its value surrounded by >>><<<< characters

test_script:
  # NOTE: if you use quotes, they will stay around the variable!
  # https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1

  - set FILE=C:\projects\file-check-win\index.js && node .
  # WTF 1 (extra space at the end)
  #   filename is >>>C:\projects\file-check-win\index.js <<<

  - set FILE="C:\projects\file-check-win\index.js" && node .
  # WTF 2 (extra space at the end AND quotes)
  #   filename is >>>"C:\projects\file-check-win\index.js" <<<

  - set FILE="C:\projects\file-check-win\index.js"
  - node .
  # WTF 3 (double quotes stay)
  #   filename is >>>"C:\projects\file-check-win\index.js"<<<

  - set FILE=C:\projects\file-check-win\index.js
  - node .
  # ok, working as expected
  #   filename is >>>C:\projects\file-check-win\index.js<<<

@Lakitna
Copy link
Contributor Author

Lakitna commented Jun 26, 2019

@bahmutov Whoops, forgetting to escape is a rookie mistake in Windows. When is Windows going to use / like a normal OS?

Here, have another wtf:

λ set LAKITNA_TMP_PATH=C:\\ && node tmp.js
>>>C:\\ <<<
fs.pathExists = false
λ set LAKITNA_TMP_PATH=C:\\&& node tmp.js
>>>C:\\<<<
fs.pathExists = true

Can you trim CYPRESS_INSTALL_BINARY to make this less error prone?

edit: For the sake of clarity. The following both work in fs-extra@latest:

λ set LAKITNA_TMP_PATH=C:/Users/lakit&& node tmp.js
>>>C:/Users/lakit<<<
fs.pathExists = true
λ set LAKITNA_TMP_PATH=C:\\Users\\lakit&& node tmp.js
>>>C:\\Users\\lakit<<<
fs.pathExists = true

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: ready for work The issue is reproducible and in scope and removed stage: work in progress stage: needs review The PR code is done & tested, needs review labels Jun 26, 2019
@bahmutov
Copy link
Contributor

yeah, this is what I want to do in #4579

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 8, 2019

The code for this is done in cypress-io/cypress#4579, 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: ready for work The issue is reproducible and in scope label Jul 8, 2019
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jul 9, 2019

Released in 3.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants