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

WDIO Configuration Helper fails to create configuration file #2218

Closed
jtheodore-rent opened this issue Aug 1, 2017 · 7 comments
Closed

WDIO Configuration Helper fails to create configuration file #2218

jtheodore-rent opened this issue Aug 1, 2017 · 7 comments

Comments

@jtheodore-rent
Copy link

The problem

I'm having the same issue that was reported in #1568

WDIO Configuration Helper
=========================

? Where do you want to execute your tests? On my local machine
? Which framework do you want to use? mocha
? Shall I install the framework adapter for you? Yes
? Where are your test specs located? ./test/specs/**/*.js
? Which reporter do you want to use?  dot - https://github.com/webdriverio/wdio-dot-reporter,  spec - https://github.com/webdriverio/wdio-spec-reporter,  json - https://github.com/fijijavis/wdio-json-re
porter
? Shall I install the reporter library for you? Yes
? Do you want to add a service to your test setup?  sauce - https://github.com/webdriverio/wdio-sauce-service,  appium - https://github.com/rhysd/wdio-appium-service,  selenium-standalone - https://gith
ub.com/webdriverio/wdio-selenium-standalone-service
? Shall I install the services for you? Yes
? Level of logging verbosity verbose
? In which directory should screenshots gets saved if a command fails? ./errorShots/
? What is the base url? http://localhost:9460

Installing wdio packages:

Packages installed successfully, creating configuration file...
fs.js:651
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/Users/jtheodore/source/rent-js/node_modules/webdriverio/build/lib/helpers/wdio.conf.ejs'
    at Object.fs.openSync (fs.js:651:18)
    at Object.fs.readFileSync (fs.js:553:33)
    at renderConfigurationFile (/Users/jtheodore/source/rent-js/node_modules/webdriverio/build/lib/cli.js:292:28)
    at /Users/jtheodore/source/rent-js/node_modules/webdriverio/build/lib/cli.js:282:17
    at /Users/jtheodore/source/rent-js/node_modules/npm-install-package/index.js:31:5
    at ChildProcess.exithandler (child_process.js:262:7)
    at emitTwo (events.js:125:13)
    at ChildProcess.emit (events.js:213:7)
    at maybeClose (internal/child_process.js:897:16)
    at Socket.stream.socket.on (internal/child_process.js:340:11)```

## Environment

* WebdriverIO version: 4.6.2
* Node.js version: 8.1.2
* [Standalone mode or wdio testrunner](http://webdriver.io/guide/getstarted/modes.html): wdio
* if wdio testrunner, running synchronous or asynchronous tests: N/A
* Additional wdio packages used (if applicable): N/A

@christian-bromann
Copy link
Member

Please see the solution that was posted for this issue: #2215 (comment)

@jtheodore-rent
Copy link
Author

@christian-bromann I just reinstalled node, and I'm getting the same failure - we use yarn rather than npm - do you think that might be related?

When I look in my node_modules/webdriverio folder, there is no lib folder there at all

@christian-bromann
Copy link
Member

Sorry but I can't reproduce this with yarn too.

@dashmug
Copy link

dashmug commented Aug 3, 2017

I have the same error when using yarn. It's not a problem when using npm install though.

@codewithcats
Copy link

This issue also happened with me when using yarn. Removing node_modules and reinstall using npm is the workaround.

@zmorris
Copy link

zmorris commented Mar 16, 2018

@christian-bromann I had the same issue today so it might be worth trying again at your convenience. I did brew install node then brew postinstall node to get npm. Then with my package.json:

"devDependencies": {
    "wdio": "^1.0.3"
}

when I run yarn I get an empty node_modules/webdriverio/node_modules folder. Even if I add "webdriverio": "^4.12.0" to package.json, it still doesn't populate the node_modules/webdriverio folder.

npm install works fine. So does running yarn from that point forward. Weird!


Actually to continue with this, I think the above issue was due to having multiple versions of yarn and/or node installed.

I tried brew remove --force yarn && brew remove --force node then ran brew install node and that fixed npm so that I didn't need to call brew postinstall node (see https://stackoverflow.com/a/36631430/539149). Then I called brew install yarn.

Then calling yarn resulted in:

$ ls -al node_modules/wdio node_modules/webdriverio
node_modules/wdio:
total 56
drwxr-xr-x    9 zackmorris  staff   288 Mar 16 13:42 .
drwxr-xr-x  191 zackmorris  staff  6112 Mar 16 13:42 ..
-rw-r--r--    1 zackmorris  staff    19 Sep  8  2017 .npmignore
-rw-r--r--    1 zackmorris  staff  1106 Aug 23  2017 LICENSE
-rw-r--r--    1 zackmorris  staff  4245 Sep 13  2017 README.md
-rw-r--r--    1 zackmorris  staff  1844 Aug 23  2017 example.js
drwxr-xr-x    3 zackmorris  staff    96 Mar 16 13:42 node_modules
-rw-r--r--    1 zackmorris  staff   697 Sep 13  2017 package.json
-rw-r--r--    1 zackmorris  staff  3984 Sep  8  2017 wdio.js

node_modules/webdriverio:
total 1008
drwxr-xr-x   15 zackmorris  staff     480 Mar 16 13:42 .
drwxr-xr-x  191 zackmorris  staff    6112 Mar 16 13:42 ..
-rw-r--r--    1 zackmorris  staff   21013 Mar  7 05:58 CHANGELOG.md
-rw-r--r--    1 zackmorris  staff    4485 Jun 19  2017 CONDUCT.md
-rw-r--r--    1 zackmorris  staff    7369 Nov  2 18:56 CONTRIBUTING.md
-rw-r--r--    1 zackmorris  staff    5572 Mar  6 06:23 GOVERNANCE.md
-rw-r--r--    1 zackmorris  staff    1075 Sep 27 15:37 LICENSE-MIT
-rw-r--r--    1 zackmorris  staff    4790 Aug 18  2017 README.md
drwxr-xr-x    3 zackmorris  staff      96 Mar 16 13:42 bin
drwxr-xr-x    5 zackmorris  staff     160 Mar 16 13:42 build
drwxr-xr-x    6 zackmorris  staff     192 Mar 16 13:42 docs
drwxr-xr-x    4 zackmorris  staff     128 Mar 16 13:42 lib
drwxr-xr-x    4 zackmorris  staff     128 Mar 16 13:42 node_modules
-rw-r--r--    1 zackmorris  staff  443899 Feb 27 10:08 package-lock.json
-rw-r--r--    1 zackmorris  staff    4879 Mar  7 06:22 package.json

But when I ran ./node_modules/.bin/wdio config I saw the files disappear after the last step:

$ ./node_modules/.bin/wdio config

=========================
WDIO Configuration Helper
=========================

? Where do you want to execute your tests? On my local machine
? Which framework do you want to use? mocha
? Shall I install the framework adapter for you? Yes
? Where are your test specs located? ./test/specs/**/*.js
? Which reporter do you want to use?  spec - https://github.com/webdriverio/wdio-spec-reporter
? Shall I install the reporter library for you? Yes
? Do you want to add a service to your test setup?  appium - https://github.com/rhysd/wdio-appium-service
? Shall I install the services for you? Yes
? Level of logging verbosity silent
? In which directory should screenshots gets saved if a command fails? ./errorShots/
? What is the base url? http://localhost

Installing wdio packages:

^^^ that's where node_modules's wdio and webdriverio got emptied. Then it could no longer find wdio.conf.ejs:

Packages installed successfully, creating configuration file...
fs.js:667
  return binding.open(pathModule.toNamespacedPath(path),
                 ^

Error: ENOENT: no such file or directory, open '/Users/zackmorris/Projects/Testing/webdriverio-mocha-bdd-appium/node_modules/webdriverio/build/lib/helpers/wdio.conf.ejs'
    at Object.fs.openSync (fs.js:667:18)
    at Object.fs.readFileSync (fs.js:572:33)
    at renderConfigurationFile (/Users/zackmorris/Projects/Testing/webdriverio-mocha-bdd-appium/node_modules/webdriverio/build/lib/cli.js:304:28)
    at /Users/zackmorris/Projects/Testing/webdriverio-mocha-bdd-appium/node_modules/webdriverio/build/lib/cli.js:294:17
    at /Users/zackmorris/Projects/Testing/webdriverio-mocha-bdd-appium/node_modules/npm-install-package/index.js:31:5
    at ChildProcess.exithandler (child_process.js:265:7)
    at ChildProcess.emit (events.js:180:13)
    at ChildProcess.emit (domain.js:421:20)
    at maybeClose (internal/child_process.js:936:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)

Using npm install, I never see the contents of node_modules's wdio or webdriverio get emptied.

My best guess at this point is that wdio is relying on something present with npm that isn't present with yarn, that causes it to try to repopulate node_modules's wdio and/or webdriverio. I've played around with having other things in package.json like:

  "devDependencies": {
    "wdio": "^1.0.3",
    "wdio-appium-service": "^0.2.3",
    "wdio-mocha-framework": "^0.5.13",
    "wdio-spec-reporter": "^0.1.4"
  }

before running yarn but ./node_modules/.bin/wdio config always fails the same way.

macOS 10.13.3 (17D102)

$ brew -v
Homebrew 1.5.10
Homebrew/homebrew-core (git revision a1696; last commit 2018-03-16)
$ node -v
v9.8.0
$ npm -v
5.6.0
$ yarn -v
1.5.1

Hopefully this helps you reproduce the issue!

@zmorris
Copy link

zmorris commented Mar 22, 2018

If you just need a quick fix or have no control over which package manager will be used for your project, here is a workaround that tells yarn to run npm install internally that you can add to package.json:

"scripts": {
  "preinstall": "if node -e \"process.exitCode=!/yarn\\.js$/.test(process.env.npm_execpath)\" ; then npm install --ignore-scripts ; fi"
}

Note that this obviously pretty slow the first time and also probably shouldn't be used in production. I don't know if this works on Windows because I haven't tested it, so if someone has working code for that I'll update my answer to be cross-platform. More info at https://stackoverflow.com/a/49438180/539149

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

No branches or pull requests

5 participants