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!
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?
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
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
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 !