Cannot execute Appium tests on Bitrise. Invalid Server Instance there are no installed Nodes

Bitrise Build Issue Report template

Description of the issue

I cannot execute my Appium tests on Bitrise. I receive an error stating: Invalid Server Instance there are no installed Nodes.

Environment:

If on Bitrise.io: which stack? If not on Bitrise.io: on what operating system? (Plus any other information you can share)

Stack: Android & Docker on Ubuntu 16.04

Which build Step causes the issue and which version of the step?

Script (Do anything) step

#!/usr/bin/env bash
# fail if any commands fails
set -e
# debug log
set -x


#Install prerequisite software to run automation tests
apt-cache search maven
sudo apt-get install maven
mvn -version

npm install -g npm
npm -v

npm install -g n
n 6.3.0

node -v
echo $NODE_PATH
export NODE_PATH=$NODE_PATH:/usr/local/bin/node
echo $NODE_PATH

echo $NODE
export NODE=$NODE:/usr/local/bin/node
echo $NODE

#Configure node
which node

echo $PATH
export PATH=$PATH:/usr/local/bin/node

echo $PATH

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=${PATH}:${JAVA_HOME}/bin

echo $JAVA_HOME
echo $PATH

npm install -g appium@1.7.2
appium -v

npm uninstall -g appium
npm install -g npm@4.0.5
npm install -g appium@1.6.3


npm install -g appium-doctor
 
appium-doctor


#appium &>/dev/null &

#Run appium automation tests via maven
mvn -X verify

Error message:
io.appium.java_client.service.local.InvalidServerInstanceException: Invalid server instance exception has occured: There is no installed nodes! Please install node via NPM (appium - npm) or download and install Appium app (Appium: Mobile App Automation Made Awesome.)

Reproducibility

  • Does a “Rebuild” help? (You can trigger a rebuild from the Build’s page, by clicking the “Rebuild” button in the top right corner of a finished build) : NO
  • Does a rebuild without caches help? (You can remove the Cache:Pull and Cache:Push steps temporarily to not to use the cache, or you can delete all the caches on the Settings tab of the app. : NO
  • Does the issue happen sporadically, or every time? : every time
  • Does upgrading the build Step to the latest version help? : NO
  • When did the issue start? : From the beginning

Local reproduction

_Can it be reproduced on your own Mac/PC by following our local debug guide? Please follow at least the first section (“Testing with a full clean git clone”) to make sure to test the state of the code what bitrise.io will get when it does a git clone in the clean environment! If possible please note which sections you tried._NO

Local reproduction: Linux / Android (docker based) stack builds

Can it be reproduced by running the build locally, after doing a new git clone of the repository into the /tmp directory and running the build from there with the Bitrise CLI ( Bitrise CLI )? If no, can it be reproduced with Docker (using the same docker images / environment we use on bitrise.io)? Related guide: Redirecting… .

Build log

Please copy paste the build’s bitrise.io URL here (or if the issue happens somewhere else then the full logs), or if you can’t share the url / log here then send the url or full log through a private channel (e.g. email - Contact us ), with a link to the related Discuss issue.

Hi there,
We are looking into it and will get back to you here as soon as possible!

Hi @barthur1234,

Did you try to run this on your own development Linux box, using our CLI? How to experiment with Bitrise configs locally, on your Mac/Linux

Or maybe even in the bitrise docker environment ( https://devcenter.bitrise.io/docker/run-your-build-locally-in-docker/ ), which is the exact same environment your build is running in.

Running these locally can definitely help a lot with debugging issues quickly! :wink:

Please let us know how it goes or if you’d have any questions!

Just a note: NodeJS as well as NVM are installed & available on that stack - you can find the full system report of the Ubuntu 16.04 stack at: https://github.com/bitrise-io/bitrise.io/blob/master/system_reports/linux-docker-android.log

E.g. the pre-installed NodeJS version right now is v8.11.1 - https://github.com/bitrise-io/bitrise.io/blob/master/system_reports/linux-docker-android.log#L33

Do you need Node v6 specifically?

Hi @viktorbenei, could you please confirm how node was installed. Was Node installed via sudo? The reason I ask is according to “https://github.com/appium/appium/blob/HEAD/docs/en/about-appium/getting-started.md” it says make sure you have not installed Node or Appium with sudo, otherwise you’ll run into problems. Thanks

Hi @viktorbenei, in response to your question, “Do you need Node v6 specifically?” the answer is no but I do need to set npm to version 4.0.5 or 3.10.3 in order to be able to install Appium via npm as there is a bug of npm “Cannot install appium on Android, Ubuntu stack

Hi @barthur1234,
we use the following commands to install node on Android & Docker on Ubuntu 16.04 stack:

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

Hi @godreikrisztian, thanks for your reply. If I wanted to remove node and re-install node via npm, how would I go about that? Thank you.

@barthur1234 you can uninstall via apt remove:

sudo apt-get remove -y nodejs

then just install any version (e.g. the way @godreikrisztian mentioned ).

Hi @viktorbenei, thanks for that. The command to remove NodeJS worked really well!! I now need to setup NodeJS the same way that is outlined in this article: “https://medium.com/testcult/configuring-appium-in-ubuntu-from-scratch-a9f8edc02d13” (because if I install NodeJS via sudo I will run into problems again)

Download latest nodejs linux binaries from https://nodejs.org/download/release/latest/
into a folder for example /home/superman/Downloads (where superman is your username and you have downloaded the file in Downloads)
Now install it under /usr/local using

cd /usr/local
tar --strip-components 1 -xzf /home/superman/Downloads/node-v8.2.1-linux-x64.tar.gz

Is there a command line way of doing the above without using sudo apt-get?

I found the command line approach:

cd /usr/local
curl -O https://nodejs.org/download/release/latest/node-v10.1.0-linux-x64.tar.gz
tar --strip-components 1 -xzf node-v10.1.0-linux-x64.tar.gz

It installs, however, I still run into problems with Invalid server instance: No installed nodes.

In reference to this article: “https://github.com/appium/appium/blob/HEAD/docs/en/about-appium/getting-started.md” it says to use nvm, n, or brew install node to install Node.js. Make sure you have not installed Node or Appium with sudo, otherwise you’ll run into problems.

I will attempt to install Node via nvm next. My Script currently looks like this:

set -e
set -x

sudo apt-get remove -y nodejs

cd /usr/local
curl -O https://nodejs.org/download/release/latest/node-v10.1.0-linux-x64.tar.gz

tar --strip-components 1 -xzf node-v10.1.0-linux-x64.tar.gz

which node
node -v

cd /bitrise/src

npm install -g npm@3.10.3

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=${PATH}:${JAVA_HOME}/bin

echo $JAVA_HOME
echo $PATH

npm install -g appium
appium -v

npm install -g appium-doctor

appium-doctor

#Run appium automation tests via maven
mvn verify

Hi @viktorbenei,

My script is as follows after trying to install NodeJS via nvm

set -e
set -x

sudo apt-get remove -y nodejs

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

export NVM_DIR="$HOME/.nvm"
[ -s “$NVM_DIR/nvm.sh” ] && . “$NVM_DIR/nvm.sh” # This loads nvm
[ -s “$NVM_DIR/bash_completion” ] && . “$NVM_DIR/bash_completion” # This loads nvm bash_completion

source ~/.bashrc

nvm --version

nvm install stable

which node
node -v

nvm run node --version

npm install -g npm@4.0.5

export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=${PATH}:${JAVA_HOME}/bin

echo $JAVA_HOME
echo $PATH

npm install -g appium
appium -v

npm install -g appium-doctor

appium-doctor

#Run appium automation tests via maven
mvn verify

However, at the line where I try to install Appium I get the following error message

  • npm install -g appium
    /root/.nvm/versions/node/v10.1.0/bin/appium -> /root/.nvm/versions/node/v10.1.0/lib/node_modules/appium/build/lib/main.js

appium-chromedriver@3.5.2 install /root/.nvm/versions/node/v10.1.0/lib/node_modules/appium/node_modules/appium-chromedriver
node install-npm.js
sh: 1: node: Permission denied
/root/.nvm/versions/node/v10.1.0/lib
└── (empty)
npm ERR! Linux 4.4.0-57-generic
npm ERR! argv “/root/.nvm/versions/node/v10.1.0/bin/node” “/root/.nvm/versions/node/v10.1.0/bin/npm” “install” “-g” “appium”
npm ERR! node v10.1.0
npm ERR! npm v4.0.5
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! appium-chromedriver@3.5.2 install: node install-npm.js
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the appium-chromedriver@3.5.2 install script ‘node install-npm.js’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the appium-chromedriver package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install-npm.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs appium-chromedriver
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls appium-chromedriver
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /bitrise/src/npm-debug.log

Please could you advise.

Also, here is the log file: https://www.bitrise.io/build/08aa095c2d5dfeb7

Thank you.

I managed to solve the permission error by:

npm config set user 0
npm config set unsafe-perm true

npm install -g appium
appium -v

This installs Appium, however when I run mvn verify I run into the same Invalid Server Instance error there are no installed nodes.

I am now attempting the following:

  • Uninstall NodeJS
  • Create username
  • Switch to username
  • Install linux-brew
  • Install Node
  • Install Appium
  • mvn verify

I’m currently having problems with switching to username (su - ). When I switch to username I stay logged in as root, why is this happening? and is there a way that I can switch user? Thanks

Why do you need to switch user? :thinking:

Also, did you try to run it locally as I originally mentioned?

There is no /home/superman user in our system unless you create it somehow.

Re: https://github.com/appium/appium/blob/HEAD/docs/en/about-appium/getting-started.md

Did you try not to install anything else other than npm install -g appium? I might be wrong but the scripts you included here seem way too over complicated. It definitely should not require switching user :thinking:

Hi @viktorbenei,
I was trying to switch user so that I could install linux-brew (as linux-brew can not be installed as root user) this is to assist with installing nodejs, without sudo rights as appium and nodejs require to be installed without using sudo. I am no longer pursuing that path because it is impossible to switch user in Bitrise.

Regarding running locally, I have Ubuntu setup in VMWare and have setup most of my development environment only problem is that I can’t create a virtual device in Android Studio (because this would be an emulation within a virtual machine). I could however, very quick and easily setup the Bitrise CLI. The steps you gave were excellent.

I have tried to keep the script very simple as well just npm install -g appium but the original problem comes back to the fact that nodejs was installed via sudo and that causes problems with appium.

This script below installs Appium but when maven verify runs I get an invalid server instance: no installed nodes error message.

set -e
set -x

npm install -g npm@4.0.5
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=${PATH}:${JAVA_HOME}/bin
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/tools/bin
export PATH=${PATH}:/usr/bin/node

npm install -g appium
mvn verify

In the docker container you’re signed in as the root user. When the build runs you’re still that root user. So it’s basically we install the preinstalled tools with the same user (the root user) which then runs the builds too. There’s no separate user for preinstalling tools & running the build, both are the root user right now in the docker container (mostly because that was the only was in docker for a long time - if you ran a docker build or container you were always the root user inside the container.)

Hi @viktorbenei,

I’ve solved the problem, my Appium tests now run on Bitrise.

I had to change the stack from “Android & Docker on Ubuntu 16.04” to “Previous Visual Studio for Mac, installed on macOS 10.12 (Sierra), set to the Stable channel” and I modified my do anything script to:

#!/usr/bin/env bash
#fail if any commands fails
set -e
#debug log
set -x

#Install node
npm install npm@5.6.0 -g
npm install node@8.11.1 --save-exact

#Install Appium
npm install -g appium

#Install Maven
curl -O http://mirrors.ibiblio.org/apache/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
sudo tar xzf apache-maven-3.2.5-bin.tar.gz -C /usr/local
cd /usr/local
sudo ln -s apache-maven-3.2.5 maven

cd /Users/vagrant/git

export JAVA_HOME=/Library/Java/Home
export PATH=${PATH}:${JAVA_HOME}/bin
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/tools/bin
export PATH=${PATH}:/usr/bin/node

export M2_HOME=/usr/local/maven
export M2=$M2_HOME/bin
export PATH=$M2:$PATH

#Run appium automation tests
mvn verify

Thanks for sharing the script @barthur1234! I’m sure it’ll help others in the future :wink:

I’m still not sure why it did not work on the Linux stack… Do you have the last build URL which you ran on the Linux stack, right before you switched to the macOS stack? I’d love to check it and see if I can figure out why it did not work there - it definitely should!

Hi @viktorbenei,

Here is a build URL ran against the Linux stack (this was the code that I used before the switch to MacOSX stack)

It still has the problem with Node.

If there’s anything else you need, let me know.

Cheers

Thanks for all the details @barthur1234 ! :slight_smile: