appium / appium

Cross-platform automation framework for all kinds of apps, built on top of the W3C WebDriver protocol
http://appium.io/
Apache License 2.0
18.66k stars 6.06k forks source link

bug: appium server starts with error on starting xcuitest driver #18902

Open bwomsm1 opened 1 year ago

bwomsm1 commented 1 year ago

Do I have the most recent component updates?

Is the component officially supported by the Appium team?

Is there an existing issue for this?

Current Behavior

I have a brand new Mac and I installed appium and appium driver as follow:

  1. npm -g install appium
  2. appium driver install xcuitest

Then I started the appium server as follow: appium --base-path=/wd/hub

But I got the error as below

Expected Behavior

Appium server should start normally when the iOS driver is launched as well.

Minimal Reproducible Example

[Appium] Welcome to Appium v2.0.0 [Appium] Non-default server args: [Appium] { [Appium] basePath: '/wd/hub' [Appium] } [Appium] Attempting to load driver xcuitest... [debug] [Appium] Requiring driver at /Users/mac-auto-04/.appium/node_modules/appium-xcuitest-driver [Appium] Could not load driver 'xcuitest', so it will not be available. Error in loading the driver was: Cannot find module 'appium/driver' [Appium] Require stack: [Appium] - /Users/mac-auto-04/.appium/node_modules/appium-xcuitest-driver/build/lib/driver.js [Appium] - /Users/mac-auto-04/.appium/node_modules/appium-xcuitest-driver/build/index.js [Appium] - /usr/local/lib/node_modules/appium/build/lib/extension/extension-config.js [Appium] - /usr/local/lib/node_modules/appium/build/lib/cli/extension-command.js [Appium] - /usr/local/lib/node_modules/appium/build/lib/cli/driver-command.js [Appium] - /usr/local/lib/node_modules/appium/build/lib/cli/extension.js [Appium] - /usr/local/lib/node_modules/appium/build/lib/main.js [Appium] - /usr/local/lib/node_modules/appium/index.js [debug] [Appium] Error: Cannot find module 'appium/driver' [debug] [Appium] Require stack: [debug] [Appium] - /Users/mac-auto-04/.appium/node_modules/appium-xcuitest-driver/build/lib/driver.js [debug] [Appium] - /Users/mac-auto-04/.appium/node_modules/appium-xcuitest-driver/build/index.js [debug] [Appium] - /usr/local/lib/node_modules/appium/build/lib/extension/extension-config.js [debug] [Appium] - /usr/local/lib/node_modules/appium/build/lib/cli/extension-command.js [debug] [Appium] - /usr/local/lib/node_modules/appium/build/lib/cli/driver-command.js [debug] [Appium] - /usr/local/lib/node_modules/appium/build/lib/cli/extension.js [debug] [Appium] - /usr/local/lib/node_modules/appium/build/lib/main.js [debug] [Appium] - /usr/local/lib/node_modules/appium/index.js [debug] [Appium] at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1028:15) [debug] [Appium] at Function.Module._load (node:internal/modules/cjs/loader:873:27) [debug] [Appium] at Module.require (node:internal/modules/cjs/loader:1100:19) [debug] [Appium] at require (node:internal/modules/cjs/helpers:108:18) [debug] [Appium] at Object. (/Users/mac-auto-04/.appium/node_modules/appium-xcuitest-driver/lib/driver.js:4:1) [debug] [Appium] at Module._compile (node:internal/modules/cjs/loader:1198:14) [debug] [Appium] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10) [debug] [Appium] at Module.load (node:internal/modules/cjs/loader:1076:32) [debug] [Appium] at Function.Module._load (node:internal/modules/cjs/loader:911:12) [debug] [Appium] at Module.require (node:internal/modules/cjs/loader:1100:19) [debug] [Appium] at require (node:internal/modules/cjs/helpers:108:18) [debug] [Appium] at Object. (/Users/mac-auto-04/.appium/node_modules/appium-xcuitest-driver/build/index.js:4:18) [debug] [Appium] at Module._compile (node:internal/modules/cjs/loader:1198:14) [debug] [Appium] at Object.Module._extensions..js (node:internal/modules/cjs/loader:1252:10) [debug] [Appium] at Module.load (node:internal/modules/cjs/loader:1076:32) [debug] [Appium] at Function.Module._load (node:internal/modules/cjs/loader:911:12) [debug] [Appium] at Module.require (node:internal/modules/cjs/loader:1100:19) [debug] [Appium] at require (node:internal/modules/cjs/helpers:108:18) [debug] [Appium] at DriverConfig.require (/usr/local/lib/node_modules/appium/lib/extension/extension-config.js:578:23) [debug] [Appium] at /usr/local/lib/node_modules/appium/lib/extension/index.js:83:46 [debug] [Appium] at Array.map () [debug] [Appium] at getActiveDrivers (/usr/local/lib/node_modules/appium/lib/extension/index.js:80:10) [Appium] Appium REST http interface listener started on http://0.0.0.0:4723/wd/hub [Appium] You can provide the following URLS in your client code to connect to this server: [Appium] http://127.0.0.1:4723/wd/hub (only accessible from the same host) [Appium] http://192.168.97.37:4723/wd/hub [Appium] Available drivers: [Appium] - xcuitest@4.32.23 (automationName 'XCUITest') [Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use. ^C[Appium] Received SIGINT - shutting down

Environment

Link to Appium Logs

No response

Futher Information

No response

bwomsm1 commented 1 year ago

@mykola-mokhnach can you please help me with that issue? this is the second time that I am getting it.

jlipps commented 1 year ago

@bwomsm1 what is the version listed in /usr/local/lib/node_modules/appium/package.json?

bwomsm1 commented 1 year ago

@jlipps it's 2.0.0,

{ "name": "appium", "version": "2.0.0", "description": "Automation for Apps.", "keywords": [ "automation", "javascript", "selenium", "webdriver", "ios", "android", "firefoxos", "testing" ],

bwomsm1 commented 1 year ago

complete file:

{
  "name": "appium",
  "version": "2.0.0",
  "description": "Automation for Apps.",
  "keywords": [
    "automation",
    "javascript",
    "selenium",
    "webdriver",
    "ios",
    "android",
    "firefoxos",
    "testing"
  ],
  "homepage": "https://appium.io",
  "bugs": {
    "url": "https://github.com/appium/appium/issues"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/appium/appium.git",
    "directory": "packages/appium"
  },
  "license": "Apache-2.0",
  "author": "https://github.com/appium",
  "types": "./build/lib/main.d.ts",
  "bin": {
    "appium": "index.js"
  },
  "directories": {
    "lib": "./lib"
  },
  "files": [
    "lib",
    "build",
    "index.js",
    "driver.*",
    "support.*",
    "plugin.*",
    "scripts/autoinstall-extensions.js",
    "types",
    "tsconfig.json",
    "!build/tsconfig.tsbuildinfo"
  ],
  "scripts": {
    "build:docs": "node docs/scripts/build-docs.js",
    "build:docs:preview": "cross-env APPIUM_DOCS_PREVIEW=1 npm run build:docs",
    "build:docs:assets": "node docs/scripts/copy-assets.js",
    "build:docs:cli": "node docs/scripts/gen-cli-args-docs.js",
    "build:docs:reference": "node docs/scripts/build-reference.js",
    "dev:docs": "npm run build:docs:assets && npm run dev:docs:en",
    "dev:docs:en": "appium-docs build --serve --mkdocs-yml ./docs/mkdocs-en.yml",
    "dev:docs:ja": "appium-docs build --serve --mkdocs-yml ./docs/mkdocs-ja.yml",
    "dev:docs:zh": "appium-docs build --serve --mkdocs-yml ./docs/mkdocs-zh.yml",
    "postinstall": "node ./scripts/autoinstall-extensions.js",
    "publish:docs": "cross-env APPIUM_DOCS_PUBLISH=1 npm run build:docs",
    "test": "npm run test:unit",
    "test:e2e": "mocha -p --timeout 1m --slow 30s \"./test/e2e/**/*.spec.js\"",
    "test:smoke": "cross-env APPIUM_HOME=./local_appium_home node ./index.js driver install uiautomator2 && cross-env APPIUM_HOME=./local_appium_home node ./index.js driver list",
    "test:unit": "mocha \"./test/unit/**/*.spec.js\""
  },
  "dependencies": {
    "@appium/base-driver": "^9.3.15",
    "@appium/base-plugin": "^2.2.15",
    "@appium/docutils": "^0.4.4",
    "@appium/schema": "^0.3.1",
    "@appium/support": "^4.1.2",
    "@appium/types": "^0.13.2",
    "@sidvind/better-ajv-errors": "2.1.0",
    "@types/argparse": "2.0.10",
    "@types/bluebird": "3.5.38",
    "@types/fancy-log": "2.0.0",
    "@types/semver": "7.5.0",
    "@types/teen_process": "2.0.0",
    "@types/wrap-ansi": "3.0.0",
    "ajv": "8.12.0",
    "ajv-formats": "2.1.1",
    "argparse": "2.0.1",
    "async-lock": "1.4.0",
    "asyncbox": "2.9.4",
    "axios": "1.4.0",
    "bluebird": "3.7.2",
    "cross-env": "7.0.3",
    "find-up": "5.0.0",
    "glob": "8.1.0",
    "lilconfig": "2.1.0",
    "lodash": "4.17.21",
    "npmlog": "7.0.1",
    "ora": "5.4.1",
    "package-changed": "3.0.0",
    "resolve-from": "5.0.0",
    "semver": "7.5.3",
    "source-map-support": "0.5.21",
    "teen_process": "2.0.2",
    "type-fest": "3.11.1",
    "winston": "3.9.0",
    "wrap-ansi": "7.0.0",
    "yaml": "2.3.1"
  },
  "engines": {
    "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
    "npm": ">=8"
  },
  "publishConfig": {
    "access": "public"
  },
  "gitHead": "3fa73a1d1a95e3868fbceb005f8b1deb4ac53eaf",
  "typedoc": {
    "entryPoint": "./lib/main.js"
  }
}
jlipps commented 1 year ago

OK, go into /Users/mac-auto-04/.appium and run node -e 'require("appium/driver")'. is there any output?

bwomsm1 commented 1 year ago

I get this:

node:internal/modules/cjs/loader:1031
  throw err;
  ^

Error: Cannot find module 'appium/driver'
Require stack:
- /Users/mac-auto-04/.appium/[eval]
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1028:15)
    at Function.Module._load (node:internal/modules/cjs/loader:873:27)
    at Module.require (node:internal/modules/cjs/loader:1100:19)
    at require (node:internal/modules/cjs/helpers:108:18)
    at [eval]:1:1
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:313:38)
    at node:internal/process/execution:79:19
    at [eval]-wrapper:6:22
    at evalScript (node:internal/process/execution:78:60) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/Users/mac-auto-04/.appium/[eval]' ]
}

My node version is: v16.20.1.

reminder, the only installs I made where:

  1. npm -g install appium
  2. appium driver install xcuitest

I made the update to your new release (2.0.1) a few minutes ago, but I still get the same output.

jlipps commented 1 year ago

OK, still in that same directory, what is the output of npm ls appium

jlipps commented 1 year ago

and also, which appium

jlipps commented 1 year ago

as well as npm ls -g appium

bwomsm1 commented 1 year ago

@jlipps since my last comment I did a few more actions which eventually solved my problem, but I don't really understand why and I still think that we have an issue here. I upgraded to node 18 and reinstalled appium. after doing these 2 my problem got solved.

Anyhow regarding your question if its solve needed:

 mac-auto-04@qa-eng-00029 .appium % npm ls appium
.appium@ /Users/mac-auto-04/.appium
└── (empty)
mac-auto-04@qa-eng-00029 .appium % which appium
/usr/local/bin/appium
mac-auto-04@qa-eng-00029 .appium % npm ls -g appium
/usr/local/lib
└─┬ appium@2.0.1
  └─┬ @appium/docutils@0.4.5
    └─┬ @appium/typedoc-plugin-appium@0.6.5
      └── appium@2.0.1 deduped
jlipps commented 1 year ago

You ran these commands before or after you solved the problem with a reinstall?

I'm gonna close this for now, but let me know if it happens again and we can reopen. I suspect it was an issue with your node + node modules configuration somehow, and updating node versions fixed it by creating a new npm package setup.

bwomsm1 commented 1 year ago

@jlipps I was first updating from node 16 to 18 and then reinstalling the appium.

bwomsm1 commented 8 months ago

@jlipps I am facing the problem again, but this time I cannot do the node install trick since I already have node 18,

Any idea on that issue? same error logs as above

jlipps commented 8 months ago

OK, try the following and show me any relevant output:

rm -rf ~/.appium
npm uninstall -g appium
npm install -g appium
which appium
npm ls appium
npm ls -g appium

appium driver ls
appium driver install xcuitest
appium driver ls
appium
bwomsm1 commented 8 months ago

@jlipps like last time, I cannot tell exactly what solved it but eventually after lots of deletions of .appium and node_modules I managed to complete the install. I do think that we have here some issue, but currently I cannot reproduce it. I am sure I will be able to, I have 5 mac machines which are running appium and I need to update them all in some point

bwomsm1 commented 8 months ago

Tried with one of the mac machines, this is the outputs:

boazwarshawsky@boaz-mac-book ~ % rm -rf ~/.appium
npm uninstall -g appium
npm install -g appium
which appium
npm ls appium
npm ls -g appium

appium driver ls
appium driver install xcuitest
appium driver ls
appium

removed 449 packages in 1s

added 449 packages in 5s

55 packages are looking for funding
  run `npm fund` for details
/usr/local/bin/appium
boazwarshawsky@ /Users/boazwarshawsky
└── (empty)

/usr/local/lib
└── appium@2.4.0

✔ Listing available drivers
- uiautomator2@2.34.2 [installed (npm)]
- xcuitest@5.11.8 [installed (npm)]
- mac2 [not installed]
- espresso [not installed]
- safari [not installed]
- gecko [not installed]
- chromium [not installed]
Error: ✖ A driver named "xcuitest" is already installed. Did you mean to update? Run "appium driver update". See installed drivers with "appium driver list --installed".
✔ Listing available drivers
- uiautomator2@2.34.2 [installed (npm)]
- xcuitest@5.11.8 [installed (npm)]
- mac2 [not installed]
- espresso [not installed]
- safari [not installed]
- gecko [not installed]
- chromium [not installed]
[Appium] Welcome to Appium v2.4.0
[Appium] The autodetected Appium home path: /Users/boazwarshawsky
[Appium] Attempting to load driver uiautomator2...
[Appium] Attempting to load driver xcuitest...
[Appium] Could not load driver 'uiautomator2', so it will not be available. Error in loading the driver was: Could not find a driver installed at /Users/boazwarshawsky/node_modules/appium-uiautomator2-driver
[Appium] ReferenceError: Could not find a driver installed at /Users/boazwarshawsky/node_modules/appium-uiautomator2-driver
[Appium]     at DriverConfig._resolveExtension (/usr/local/lib/node_modules/appium/lib/extension/extension-config.js:570:13)
[Appium]     at DriverConfig.requireAsync (/usr/local/lib/node_modules/appium/lib/extension/extension-config.js:592:34)
[Appium]     at /usr/local/lib/node_modules/appium/lib/extension/index.js:53:26
[Appium] Could not load driver 'xcuitest', so it will not be available. Error in loading the driver was: Could not find a driver installed at /Users/boazwarshawsky/node_modules/appium-xcuitest-driver
[Appium] ReferenceError: Could not find a driver installed at /Users/boazwarshawsky/node_modules/appium-xcuitest-driver
[Appium]     at DriverConfig._resolveExtension (/usr/local/lib/node_modules/appium/lib/extension/extension-config.js:570:13)
[Appium]     at DriverConfig.requireAsync (/usr/local/lib/node_modules/appium/lib/extension/extension-config.js:592:34)
[Appium]     at /usr/local/lib/node_modules/appium/lib/extension/index.js:53:26
[Appium] Appium REST http interface listener started on http://0.0.0.0:4723
[Appium] You can provide the following URLs in your client code to connect to this server:
[Appium]    http://127.0.0.1:4723/ (only accessible from the same host)
[Appium]    http://10.0.0.64:4723/
[Appium]    http://10.212.134.36:4723/
[Appium]    http://169.254.61.228:4723/
[Appium] Available drivers:
[Appium]   - uiautomator2@2.34.2 (automationName 'UiAutomator2')
[Appium]   - xcuitest@5.11.8 (automationName 'XCUITest')
[Appium] No plugins have been installed. Use the "appium plugin" command to install the one(s) you want to use.
jlipps commented 8 months ago

this output is strange. do you have APPIUM_HOME set to anything? you can do echo $APPIUM_HOME to see

bwomsm1 commented 8 months ago

this output is strange. do you have APPIUM_HOME set to anything? you can do echo $APPIUM_HOME to see

Nothing, its empty

bwomsm1 commented 8 months ago

@jlipps any news about this issue? I am still getting the following error:

boazwarshawsky@boaz-mac-book ~ % appium driver update xcuitest
✔ Checking if driver 'xcuitest' is updatable
✔ Checking if driver 'xcuitest' needs an update
✖ Installing 'xcuitest' using NPM install spec 'appium-xcuitest-driver@5.13.1'
✖ Updating driver 'xcuitest' from 5.11.8 to 5.13.1
ℹ Update report:
✖   - 'xcuitest' failed to update: Error: ✖ Encountered an error when installing package: npm command 'install --save-dev --no-progress --no-audit appium-xcuitest-driver@5.13.1 --json' failed with code 1.

STDOUT:
{
  "error": {
    "code": 1,
    "summary": "command failed",
    "detail": "sh -c node ./scripts/autoinstall-extensions.js\nnode:internal/modules/cjs/loader:998\n  throw err;\n  ^\n\nError: Cannot find module './promise'\nRequire stack:\n- /Users/boazwarshawsky/node_modules/bluebird/js/release/bluebird.js\n- /Users/boazwarshawsky/node_modules/appium/scripts/autoinstall-extensions.js\n    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)\n    at Module._load (node:internal/modules/cjs/loader:841:27)\n    at Module.require (node:internal/modules/cjs/loader:1061:19)\n    at require (node:internal/modules/cjs/helpers:103:18)\n    at Object.<anonymous> (/Users/boazwarshawsky/node_modules/bluebird/js/release/bluebird.js:9:16)\n    at Module._compile (node:internal/modules/cjs/loader:1159:14)\n    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)\n    at Module.load (node:internal/modules/cjs/loader:1037:32)\n    at Module._load (node:internal/modules/cjs/loader:878:12)\n    at Module.require (node:internal/modules/cjs/loader:1061:19) {\n  code: 'MODULE_NOT_FOUND',\n  requireStack: [\n    '/Users/boazwarshawsky/node_modules/bluebird/js/release/bluebird.js',\n    '/Users/boazwarshawsky/node_modules/appium/scripts/autoinstall-extensions.js'\n  ]\n}\n\nNode.js v18.12.1"
  }
}

STDERR:
npm WARN deprecated typedoc-plugin-resolve-crossmodule-references@0.3.3: Upgrade to typedoc >= 0.24 and remove typedoc-plugin-resolve-crossmodule-references from your dependencies
npm ERR! code 1
npm ERR! path /Users/boazwarshawsky/node_modules/appium
npm ERR! command failed
npm ERR! command sh -c node ./scripts/autoinstall-extensions.js
npm ERR! node:internal/modules/cjs/loader:998
npm ERR!   throw err;
npm ERR!   ^
npm ERR!
npm ERR! Error: Cannot find module './promise'
npm ERR! Require stack:
npm ERR! - /Users/boazwarshawsky/node_modules/bluebird/js/release/bluebird.js
npm ERR! - /Users/boazwarshawsky/node_modules/appium/scripts/autoinstall-extensions.js
npm ERR!     at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:841:27)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1061:19)
npm ERR!     at require (node:internal/modules/cjs/helpers:103:18)
npm ERR!     at Object.<anonymous> (/Users/boazwarshawsky/node_modules/bluebird/js/release/bluebird.js:9:16)
npm ERR!     at Module._compile (node:internal/modules/cjs/loader:1159:14)
npm ERR!     at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
npm ERR!     at Module.load (node:internal/modules/cjs/loader:1037:32)
npm ERR!     at Module._load (node:internal/modules/cjs/loader:878:12)
npm ERR!     at Module.require (node:internal/modules/cjs/loader:1061:19) {
npm ERR!   code: 'MODULE_NOT_FOUND',
npm ERR!   requireStack: [
npm ERR!     '/Users/boazwarshawsky/node_modules/bluebird/js/release/bluebird.js',
npm ERR!     '/Users/boazwarshawsky/node_modules/appium/scripts/autoinstall-extensions.js'
npm ERR!   ]
npm ERR! }
npm ERR!
npm ERR! Node.js v18.12.1

npm ERR! A complete log of this run can be found in: /Users/boazwarshawsky/.npm/_logs/2024-01-08T12_27_29_833Z-debug-0.log

for running the following command:

appium driver update xcuitest
jlipps commented 8 months ago

I'm not sure. Something seems quite odd on your system. I can't reproduce this issue. Maybe there is some environment config on your system that is causing this problem. We can keep this issue open and see if anyone else reports it though.

bwomsm1 commented 8 months ago

thanks, I am facing the issue with 2 different mac stations, my own laptop and another mac mini. that would be great if you will have an option for screen sharing. I will try to see what I can do and share if I manage to solve the problem