use Node path from config file to run plugins#4436
use Node path from config file to run plugins#4436jennifer-shehane merged 61 commits intodevelopfrom
Conversation
|
hmm, maybe it is better to find Node using https://github.com/npm/node-which |
|
@bahmutov you should use this module: https://github.com/sindresorhus/run-node If Cypress is run in global "double click" mode then |
|
I looked at that module and I am not sure it will work on Windows at all
…Sent from my iPhone
On Jun 12, 2019, at 11:40, Brian Mann ***@***.***> wrote:
@bahmutov you should use this module: https://github.com/sindresorhus/run-node
If Cypress is run in global "double click" mode then $PATH will not be available. Sindre's package will effectively always find the correct node version correctly - and it's used by things like husky git hooks which work in git gui apps.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
plus |
|
Example (after building and opening Electron binary on Mac) local modeThen use Node 6 global modefirst open Finder click on Mac app and start it in "global" mode. Running the project finds the OS Node |
|
before I go to write some tests, is this ok for this feature? seems to be enough to control the Node version. @brian-mann |
|
Can we rename Another idea: we could automatically detect if you're using a Why? Because if you're running on multiple projects you may switch the node version between shells, which would then cause Cypress to pick the "last one". Ideally if there's something in your project that specifies it, that would be the best way for us to know which one to switch to. Another idea: provide us the actual version like |
|
Beyond the use of plugins - the big win of this is that when we process your spec files, that we use your version of I believe so far you've demonstrated switching node only for plugins but not for spec processing. |
|
Thinking about this a bit more... I actually dont think we should support absolute paths to the node version. Nothing in I guess we could still allow for it but maybe display a warning. A better approach is anchoring ourselves to something in the project files, or the user providing a specific node version so we know when it's correct and when it's not correct. |
|
Bleh... I guess this would likely making running in CI more difficult, which is why the Maybe something like how heroku does it - enabling you to pass in a node version like |
|
so I would love to specify Node version (and read it from Then the second iteration could be "find specific version of Node" I will look into bundling now |
|
I think the challenge here is that whatever they specify may be problematic when running in CI, etc. Could we just download that version of node if we can't find it locally and like... cache it in the Cypress cache folder for future use? I'm also imagining a UI in the config area that gives you a series of radios to help you pick the node version, and whether or not it was found on your system. Honestly downloading the specific version of node would be a pretty failsafe way of always having it in all environments and users. |
|
Automatic downloading to me looks almost magical, even if we cache it into |
|
I have checked the bundling of files - it uses the found Node version, just like processing of plugins file. In the log below, the first Node version if the Cypress Test Runner own code (Node 8) and then the bundling prints its Node version (12) |
|
Ok, after thinking some more, I believe the great majority of issues related to the built-in Node version can be solved by loading system Node. For this I think we should allow just two options in
I think any more features (like UI drop-down, auto-installing Node, trying to read |
|
You are probably right... but maybe there is some middle ground. At the very least we need to:
The property for this should likely be:
|
|
yeah, agree that we need to show it in the |
|
@mpahuja, unfortunately, the change is inside the Cypress compiled binary code, so we cannot even release NPM package fix. For me the work here is done, it is up to @brian-mann to review and merge it (soon) |
|
I am sure and also hopeful that he will get to it as soon as he can. |
|
@bahmutov what do you think about using this https://github.com/electron/electron-rebuild as a workaround in the meantime? |
Try it! It didn't work consistently for me whilst trying to get the Oracle Node driver working on Windows. Seems to depend on exact set-up. |
|
yeah @mpahuja I think just updating our code by merging this pull request is a lot better way than rebuilding native modules. |
|
completely understand Gleb, just curious on the timeline for this to be merged so that I can make an informed decision about whether i need to use the workaround or not. |
# Conflicts: # packages/desktop-gui/cypress/integration/settings_spec.js # packages/desktop-gui/src/projects/projects-api.js # packages/server/lib/config.coffee
|
This test is failing because when run locally - the node version is 8.0.0 then in CI it is 12.0.0, but we are blindly replacing |
Changes were addressed as asked
Description of change
Added a config option
nodeVersionthat will be used to determine which version of Node Cypress is run within. Users can use thebundledversion that comes with Cypress (which is the default) or override it with thesystemNode version installed on their machine.How to use the feature
In configuration file (cypress.json by default), to use the bundled version of Node with Cypress.
defaultorbundled= use the Node that comes with Cypress Test Runner{ "nodeVersion": "bundled" }In configuration file (cypress.json by default), to use the system version of Node with Cypress.
system= tries to find system Node using cross-platform https://github.com/npm/node-which from NPM. If fails to find, tries again but first fixing path using https://github.com/sindresorhus/fix-path{ "nodeVersion": "system" }How the design has changed
cypress runmode to indicate the system version of node (likely in the table header at the top of a run shown below)To demo / test this, I made a branch
external-node-for-plugins-4432in https://github.com/cypress-io/cypress-test-tiny/tree/external-node-for-plugins-4432 that runscy.taskthat prints Node version. To execute from the repo root run (assuming the test project is in~/git/cypress-test-tiny/). Example output from the terminal running Node 12New Node Version panel in Desktop GUI
Using node version bundled with Cypress
Using node version from your system
Pre-merge Tasks