Bitbucket pipeline Your system is missing the dependency: Xvfb - testing

I'm trying to add cypress to the bitbucket pipeline but it tells me that I need to install Xvfb and I don't know how to keep going. This is my bitbucket.pipelines.yml
# Template NodeJS build
# This template allows you to validate your NodeJS code.
# The workflow allows running tests and code linting on the default branch.
image: node:14.15.4
pipelines:
default:
- step:
name: Build
script:
- npm install
- npm run lint
- npm run cypress:run
This is my package.json scripts
"scripts": {
"cypress:open": "cypress open",
"cypress:run": "npx cypress run --record --key xxxxxxxxxxxx"
}
and the test are running fine locally
But in the pipeline I'm getting this error:
+ npm run cypress:run
> wallet-frontend#0.1.0 cypress:run /opt/atlassian/pipelines/agent/build
> npx cypress run --record --key 70004462-62d4-42ce-b359-5bff73d8b001
It looks like this is your first time using Cypress: 6.5.0
[16:30:09] Verifying Cypress can run /root/.cache/Cypress/6.5.0/Cypress [started]
[16:30:09] Verifying Cypress can run /root/.cache/Cypress/6.5.0/Cypress [failed]
Your system is missing the dependency: Xvfb
Install Xvfb and run Cypress again.
Read our documentation on dependencies for more information:
https://on.cypress.io/required-dependencies
If you are using Docker, we provide containers with all required dependencies installed.
----------
Error: spawn Xvfb ENOENT
----------
Platform: linux (Debian - 9.13)
Cypress Version: 6.5.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wallet-frontend#0.1.0 cypress:run: `npx cypress run --record --key xxxxxxxxx`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the wallet-frontend#0.1.0 cypress:run script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Xvfb is an in-memory display server for a UNIX-like operating system, in your case Linux (Debian - 9.13). This is a system-level dependency that cypress assumes is installed beforehand. In the case of bitbucket env, this is not installed and hence this error. This is primarily used for Display (UI) in case of headed browsers while running cypress.
There are few easy workarounds here:
Installing the dependency manually: I won't suggest this as you might miss out few more dependencies unless you thoroughly look into all the dependencies.
Run headless browsers:: Headless browsers don't use Xvfb, so won't be facing this exact error but as I said in point 1, there can be other issues. Command will become cypress run --headless
Use Cypress provided Docker images (Suggested): I can see that you are using the node:14.15.4 image for this build. Instead of that, use a cypress provided official base images for whatever node version you want to run (Look for different node version in tags). If you look into the Dockerfile, you will see that they have taken an effort to install the dependencies needed to run Cypress inside the docker (You can see Xvfb there).
Also, look for already open issues when you get stuck in cypress-related issues, they have a very active and helpful issues section. I found this same issue in there: https://github.com/cypress-io/cypress/issues/14457

Cypress provides the dependencies for CI.
Linux
Ubuntu/Debian
apt-get install libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
CentOS
yum install -y xorg-x11-server-Xvfb gtk2-devel gtk3-devel libnotify-devel GConf2 nss libXScrnSaver alsa-lib
reference: https://docs.cypress.io/guides/continuous-integration/introduction#Dependencies

Related

How can I set the npm version in gitlab CI?

I have a gitlab pipeline for an Angular project with the image in .gitlab-ci.yml
image: node:16
build:
stage: build
script:
- npm ci
- nodejs -v
- npm -v
- npm run build:prod
- npm doctor
When the pipeline reaches the npm doctor it fails with the following error on npm version:
$ npm doctor
Check Value Recommendation/Notes
npm ping ok
npm -v not ok Use npm v7.24.0
node -v ok current: v16.9.1, recommended: v16.9.1
npm config get registry ok using default registry (https://registry.npmjs.org/)
which git ok /usr/bin/git
Perms check on cached files ok
Perms check on local node_modules ok
Perms check on global node_modules ok
Perms check on local bin folder ok
Perms check on global bin folder ok
Verify cache contents ok verified 1361 tarballs
How can I solve this?
In my machine I have the npm version v7.24.0 and the command succeeds.
Install npm before you do anything else, specifying a version, i.e. npm install npm#version -g.
For completeness, if you can't update the global npm, you can do so locally, by replacing npm with npx npm#latest or npx npm#7.24.0. npx will install npm if it needs to, locally, and then run the local installation.
Lastly you can install locally with npm install npm#latest and then run it with $(npm bin)/npm, but this is what npx is for.
Note that I don't understand why you're running npm doctor after a build. Presumably if you care about npm thining it's set up properly you should run it before the build, so the pipeline fails early.
P.S. I stupidly read 'github' as 'gitlab'. If you were using github I would recommend using
setup-node if only for dependency caching, which can seriously speed up pipelines. I don't know if gitlab does anything similar.

Cypress cannot run because this binary file does not have executable permissions

I was trying to create a new project in cypress and I got the following strange error message.
Steps:
npm init -y
npm install cypress --save-dev
I then did npx open cypress and I got the following message from my console
How do I fix this?
Cypress cannot run because this binary file does not have executable permissions here:
/Users/myName/Library/Caches/Cypress/7.5.0/Cypress.app/Contents/MacOS/Cypress
Reasons this may happen:
- node was installed as 'root' or with 'sudo'
- the cypress npm package as 'root' or with 'sudo'
Please check that you have the appropriate user permissions.
You can also try clearing the cache with 'cypress cache clear' and reinstalling.
----------
Platform: darwin (20.5.0)
Cypress Version: 7.5.0
You can do two things:
Run the command npm cypress cache clear and then again install cypress npm install cypress --save-dev and check.
Or, install npm globally without sudo using the command npm install -g. Then create a new folder and then run npm init, npm install cypress --save-dev and npx cypress open.
Do navigate to the cache directory by doing
cd /Users/myName/Library/Caches/
Here you have to delete Cypress directory completely by running the command
rm -rf Cypress
Now head over to your project directory and run the command
npx install cypress
Cypress will be installed in your system again. Next time you won't get any errors.
So, I had a chat with the dev team at Cypress and got the following answer. After reading the logs I had a feeling this might be the root cause. So please check you have the most up to date version of Node.js

Yocto recipe fails to install npm package

I have a recipe that installed some NPM packages that worked on an older version of Yocto.
After upgrading to sumo, the recipe fails with the following error:
installnpmpackages/0.0.1-r0/temp/run.do_compile.7272: npm: not found
| WARNING: exit code 127 from a shell command.
I tried using the developer shell and NPM does work in that case.
The do_compile from the recipe:
do_compile() {
# Create a working directory
mkdir -p ${WORKDIR}/scratch
# changing the home directory to the working directory, the .npmrc will be created in this directory
export HOME=${WORKDIR}/scratch
# configure cache to be in working directory
npm set cache ${WORKDIR}/scratch/npm_cache
# clear local cache prior to each compile
npm cache clear
# compile and install node modules in source directory
cd ${WORKDIR}/scratch
npm --arch=${TARGET_ARCH} --verbose install node-gyp
npm --arch=${TARGET_ARCH} --verbose install connect
npm --arch=${TARGET_ARCH} --verbose install socket.io
#npm --arch=${TARGET_ARCH} --verbose install sqlite3
#npm --arch=${TARGET_ARCH} --verbose install serialport
npm --arch=${TARGET_ARCH} --verbose install express
npm --arch=${TARGET_ARCH} --verbose install csv
npm --arch=${TARGET_ARCH} --verbose install md5
# clear local cache before we package. No need to copy over all this cache stuff; just need the modules.
npm cache clear
}
Note sqlite3 and serialport are commented out as they did not work on the previous version.
What needs to be changed with sumo (vs morty) for NPM to function in a recipe?
Thank you in advance!
I found a simple solution.
I created individual recipes using devtool add.
Here is the command used to create a recipe for the serialport npm module:
devtool add "npm://registry.npmjs.org;name=serialport;version=7.1.4"
I'm answering to #Hsn comment as my account is new and I don't have 50 reputation.
If you are able to add a recipe with devtool and it worked, you can use devtool as well to finish working on the recipe and tell devtool in which meta you want to put the recipe like :
devtool finish recipe_name meta-destination
And in order to put it into your final OS rootfs, you need to add it to your image bb file, for example : image-dev.bb :
IMAGE_INSTALL_append += "recipe_name"
Make sure also that the meta which holds your recipe is present in your bblayers.conf.

electron install error : Generated checksum for "electron-v2.0.2-win32-x64.zip" did not match expected checksum

I want to install latest electron version in my existing angular application.So I followed npm command to install it.
Command : npm i electron#latest
Expected Behavior
Electron should installed successfully.
Actual Behavior
So, Whenever I tried to install electron, after downloading zip file and SAMSUN.txt file , it is throwing below error....
Error: Generated checksum for "electron-v2.0.2-win32-x64.zip" did not match expected checksum.
at ChecksumMismatchError.ErrorWithFilename (E:\CityLawElectron\node_modules\electron-download\node_modules\sumchecker\build.js:41:124)
at new ChecksumMismatchError (E:\CityLawElectron\node_modules\electron-download\node_modules\sumchecker\build.js:56:133)
at Hash. (E:\CityLawElectron\node_modules\electron-download\node_modules\sumchecker\build.js:203:22)
at emitNone (events.js:106:13)
at Hash.emit (events.js:208:7)
at emitReadable_ (_stream_readable.js:513:10)
at emitReadable (_stream_readable.js:507:7)
at addChunk (_stream_readable.js:274:7)
at readableAddChunk (_stream_readable.js:250:11)
at Hash.Readable.push (_stream_readable.js:208:10)
Please note that I have tried to clear my npm cache using npm cache clean --force command and tried to install. but it didn't work.
I also tried to install electron globally using npm i -g electron#latest, but that approach also didn't work.
Please provide solution as soon as possible because I m really stuck at this problem.
Electron Version: 2.0.2
Operating System : windows
node version : 8.11.2
npm version : 6.1.0
Last known working Electron version:
We can solve this issue by using following steps (OS - Windows 10)
Delete "SHASUMS256.txt-x.x.xx" file from "C:\Users{{UserName}}.electron".
Delete Cache folder from "C:\Users{{UserName}}\AppData\Local\electron".
Delete electron from node_modules folder.
Then install electron globally and locally by using following commands -
npm init -y //Note: The -y flag provides default options automatically
npm install electron -g //install electron globally
npm install electron --save-dev --save-exact //install electron as devdependencies
If you are using typescript then install it as global using below command-
npm install -g typescript
Above steps may help you.

Cannot install phantomJS in Karma

WARN [config]: config.configure() is deprecated, please use config.set() instead.
WARN [plugin]: Cannot find plugin "karma-phantomjs".
Did you forget to install it ?
npm install karma-phantomjs --save-dev
INFO [karma]: Karma v0.10.2 server started at http://localhost:9018/
WARN [launcher]: Can not load "PhantomJS", it is not registered!
Perhaps you are missing some plugin?
Getting this error. When running npm install karma-phantomjs --save-dev I get an error.
npm ERR! 404 'karma-phantomjs' is not in the npm registry.
I installed karma-phantomjs-launcher --save-dev but i still get an error when running grunt watch.
Anyone else run into this issue?
npm install karma-jasmine --save-dev
npm install karma-phantomjs-launcher --save-dev
Then add the following line to karma.config.js
plugins : ['karma-jasmine', 'karma-phantomjs-launcher']
I got tripped up by this today running
karma: 0.13.7
karma-phantomjs-launcher: 1.0.0
What isn't very obvious is that the launcher has a dependency on:
phantomjs-prebuilt
So if you, install this locally everything should run fine, eg:
npm install phantomjs-prebuilt --save-dev
After some research I realized that I needed to run:
npm install -g karma#canary phantomjs karma-phantomjs-launcher
Once I ran that I went back into my karma-unit.tpl.js file and instead of karma-phantomjs, I changed this to karma-phantomjs-launcher.
Now when I execute a command like grunt build, I get no error regarding phantomJS
This is an issue still open on the repo: #31
Strangely enough the following worked for my Debian based system:
apt-get install libfontconfig
How did I get into this? Reading a comment from the ticket. Hope this will help for others too :-)
I'm running in a CentOS 7 Docker container. Had similar issue.
Had to:
yum install -y tar bzip2 freetype fontconfig
Then
npm install phantomjs --save-dev
worked without errors, which allowed
npm install karma-phantomjs-launcher --save-dev
and that allowed
gulp test
to run without Karma or PhantomJS errors.
Today I had the same. I deleted all the temporary directories and, after rerun it worked.
Before that i also reinstalled phantomjs but without success. It's possible that this influenced, anyway (but i think deleting the temporary directories did the job). Anyway, after deleting temporary folders you can try, if it didn't work you can reinstall phantomjs and also other stuff as other users already wrote.