Mink > Zombie.js Can't Start Session - mink

I am trying to create a Mink Connection With the Zombie Driver But I am Getting an Error. All ports are open and I have tried using my servers IP.
My Code:
$driver = new \Behat\Mink\Driver\ZombieDriver('127.0.0.1');
$zombieSession = new \Behat\Mink\Session($driver);
$zombieSession->start();
Error:
Fatal error: Uncaught exception 'RuntimeException' with message 'Server process has
been terminated: (127) [sh: node: command not found ]' in /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php:406
Stack trace: #0 /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php(302):
Behat\Mink\Driver\NodeJS\Server->checkAvailability() #1 /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/ZombieDriver.php(107):
Behat\Mink\Driver\NodeJS\Server->start() #2 /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink/src/Behat/Mink/Session.php(62):
Behat\Mink\Driver\ZombieDriver->start() #3 /home/runniog5/public_html/subdomains/testing4/test.php(114):
Behat\Mink\Session->start() #4 {main} thrown in /home/runniog5/public_html/subdomains/testing4/vendor/behat/mink-zombie-driver/src/Behat/Mink/Driver/NodeJS/Server.php
on line 406

Make sure you have Node installed and it's functional. Server process has
been terminated: (127) [sh: node: command not found ] tells you that shell cannot find node command. To verify you've got it run node -v it should print the current installed version.

The problem is that the ZombieServer doesn't know the path to the binary of your node. To solve this, use this code:
$zombieServer = new ZombieServer($host, $port, $pathToYourNodeBinary, $serverPath, $threshold, $pathToYourNodeModules);
$zombieDriver = new ZombieDriver($zombieServer);
$session = new Session($zombieDriver);
$mink = new Mink(array('zombie' => $session));
In my case, $pathToYourNodeBinary and $pathToYourNodeModules are:
$pathToYourNodeBinary = '/usr/local/bin/node';
$pathToYourNodeModules = '/usr/local/lib/node_modules/';
You can get to know what are your paths using these commands (in case you are running Mac with OSX):
which node
which npm
Of course you need to set up the rest of the ZombieServer constructor variables. To get to know the default values just have a look on its implementation in your vendor library or at github.com

Related

installation error in shopware-pwa initialization

I am trying to install shopware-pwa. I am following the steps in https://github.com/vuestorefront/shopware-pwa
But at the first step while initializing the project npx #shopware-pwa/cli init
While installing I used default option:
* Shopware instance address: · https://shopware6-demo.vuestorefront.io
* Shopware instance access token: · SWSCVJJET0RQAXFNBMTDZTV1OQ
* Which version you'd like to use: latest stable (recommended)
Error: Command failed: npx --ignore-existing create-nuxt-app#3.2.0 --answers "{\"name\":\"shopware-pwa-project\",\"description\":\"shopware-pwa-project description\",\"author\":\"Vue Storefront\",\"pm\":\"yarn\",\"ui\":\"none\",\"language\":\"js\",\"server\":\"none\",\"features\":[\"axios\",\"pwa\"],\"linter\":[\"prettier\",\"lintStaged\"],\"test\":\"jest\",\"mode\":\"universal\",\"target\":\"server\",\"devTools\":[],\"gitUsername\":\"\",\"ci\":\"none\"}"
npx: the --ignore-existing argument has been removed.
See `npm help exec` for more information
Trace: Error: Answers JSON could not be parsed (Unexpected token n in JSON at position 1)
at SAO.runGenerator (/home/user/.npm/_npx/059d932392171cf4/node_modules/sao/lib/index.js:126:15)
at SAO.run (/home/user/.npm/_npx/059d932392171cf4/node_modules/sao/lib/index.js:101:16)
at /home/user/.npm/_npx/059d932392171cf4/node_modules/create-nuxt-app/lib/cli.js:51:17
Does anybody come up with the issue?
I found issue #612 in the create-nuxt-app GitHub repository.
It seems that after the --answers argument you'd have to start with a sinqle quote (') and then paste your configuration as a JSON. The JSON must not contain any linefeeds/carriage returns and there must not be any whitespaces ( ) between the properties.
So in your case your bash command should look like this:
npx --ignore-existing create-nuxt-app#3.2.0 --answers '{"name":"shopware-pwa-project","description":"shopware-pwa-project description","author":"Vue Storefront","pm":"yarn","ui":"none","language":"js","server":"none","features":["axios","pwa"],"linter":["prettier","lintStaged"],"test":"jest","mode":"universal","target":"server","devTools":[],"gitUsername":"","ci":"none"}'
I've tried it on my machine just now and it worked. I only got a warning becausethe --ignore-existing argument has been removed.
hope that this solves your problem!
greetings

Postgresql 11.1: "Problem running post-install step. Installation may not complete correctly. Error with configuration or permissions."

I checked the log file and I think this is the part that caused the problem:
Setting up database
[15:30:54] Configuring pg11 to point to existing data dir D:\John's Files\My Documents\Code\Databases\PostgreSQL\data\pg11
Setting PostgreSQL port
= 5432
Executing C:\Installed Software\Developer Software\PostgreSQLv11.1/pgc config pg11 --datadir "D:\John's Files\My Documents\Code\Databases\PostgreSQL\data\pg11"
Script exit code: 1
Script output: ################################################
# FATAL SQL Error in check_release
# SQL Message = near "s": syntax error
# SQL Statement = SELECT r.component FROM releases r, versions v
WHERE r.component = v.component
AND r.component LIKE '%D:\John's Files\My Documents\Code\Databases\PostgreSQL\data\pg11%' AND v.is_current = 1
################################################
Script stderr: Program ended with an error exit code
Error with configuration or permissions. Please see log file for more information.
Problem running post-install step. Installation may not complete correctly
Error with configuration or permissions. Please see log file for more information.
I think the problem is the apostrophe in "John's". Does anyone know if that's right? Is there a fix to this problem? I don't want to rename my directory because Postgresql can't handle apostrophes.

Opening a DGRAM socket from within a docker container fails (permission denied)

I'm running an application which builds and sends ICMP ECHO requests to a few different ip addresses. The application is written in Crystal. When attempting to open a socket from within the crystal docker container, Crystal raises an exception: Permission Denied.
From within the container, I have no problem running ping 8.8.8.8.
Running the application on macos, I have no problem.
Reading the https://docs.docker.com/engine/security/apparmor/ and https://docs.docker.com/engine/security/seccomp/ pages on apparmor and seccomp I was sure I'd found the solution, but the problem remains unresolved, even when running as docker run --rm --security-opt seccomp=unconfined --security-opt apparmor=unconfined socket_permission
update/edit: After digging into capabilities(7), I added the following line to my dockerfile: RUN setcap cap_net_raw+ep bin/ping trying to let the socket get opened but without change.
Thanks!
Relevant crystal socket code, full working code sample below:
# send request
address = Socket::IPAddress.new host, 0
socket = IPSocket.new Socket::Family::INET, Socket::Type::DGRAM, Socket::Protocol::ICMP
socket.send slice, to: address
Dockerfile:
FROM crystallang/crystal:0.23.1
WORKDIR /opt
COPY src/ping.cr src/
RUN mkdir bin
RUN crystal -v
RUN crystal build -o bin/ping src/ping.cr
ENTRYPOINT ["/bin/sh","-c"]
CMD ["/opt/bin/ping"]
Running the code, first native, then via docker:
#!/bin/bash
crystal run src/ping.cr
docker build -t socket_permission .
docker run --rm --security-opt seccomp=unconfined --security-opt apparmor=unconfined socket_permission
And finally, a 50 line crystal script which fails to open a socket in docker:
require "socket"
TYPE = 8_u16
IP_HEADER_SIZE_8 = 20
PACKET_LENGTH_8 = 16
PACKET_LENGTH_16 = 8
MESSAGE = " ICMP"
def ping
sequence = 0_u16
sender_id = 0_u16
host = "8.8.8.8"
# initialize packet with MESSAGE
packet = Array(UInt16).new PACKET_LENGTH_16 do |i|
MESSAGE[ i % MESSAGE.size ].ord.to_u16
end
# build out ICMP header
packet[0] = (TYPE.to_u16 << 8)
packet[1] = 0_u16
packet[2] = sender_id
packet[3] = sequence
# calculate checksum
checksum = 0_u32
packet.each do |byte|
checksum += byte
end
checksum += checksum >> 16
checksum = checksum ^ 0xffff_ffff_u32
packet[1] = checksum.to_u16
# convert packet to 8 bit words
slice = Bytes.new(PACKET_LENGTH_8)
eight_bit_packet = packet.map do |word|
[(word >> 8), (word & 0xff)]
end.flatten.map(&.to_u8)
eight_bit_packet.each_with_index do |chr, i|
slice[i] = chr
end
# send request
address = Socket::IPAddress.new host, 0
socket = IPSocket.new Socket::Family::INET, Socket::Type::DGRAM, Socket::Protocol::ICMP
socket.send slice, to: address
# receive response
buffer = Bytes.new(PACKET_LENGTH_8 + IP_HEADER_SIZE_8)
count, address = socket.receive buffer
length = buffer.size
icmp_data = buffer[IP_HEADER_SIZE_8, length-IP_HEADER_SIZE_8]
end
ping
It turns out the answer is that Linux (and by extension docker) does not give the same permissions that macOS does for DGRAM sockets. Changing the socket declaration to socket = IPSocket.new Socket::Family::INET, Socket::Type::RAW, Socket::Protocol::ICMP allows the socket to connect under docker.
A little more still is required to run the program in a non-root context. Because raw sockets are restricted to root, the binary must also be issued the correct capability for access to a raw socket, CAP_NET_RAW. However, in docker, this isn't necessary. I was able to get the program to run outside of super-user context by running sudo setcap cap_net_raw+ep bin/ping. This is a decent primer on capabilities and the setpcap command
MacOS doesn't use the same system of permissions, so setcap is just an unrecognized command. As a result, to get the above code to compile and run successfully on macOS without super-user context, I changed the socket creation code to:
socket_type = Socket::Type::RAW
{% if flag?(:darwin) %}
socket_type = Socket::Type::DGRAM
{% end %}
socket = IPSocket.new Socket::Family::INET, socket_type, Socket::Protocol::ICMP
Applying the CAP_NET_RAW capability for use in linux happens elsewhere in the build process if needed.
With those changes, I'm not seeing any requirement for changes to seccomp or apparmor from the default shipped with Docker in order to run the program.

Error while connecting to sybase database using dbd:sybase

I have compiled dbd-sybase module(1.07) to add it to my perl(5.12.3) on windows. However, when I trying to use it using following script:
use DBI;
DBD::Sybase;
$ENV{SYBASE} = 'E:\Sybase';
$ENV{SYBASE_OCS} = 'OCS-15_0';
$ENV{SYBASE_ASE} = 'ASE-15_0';
$SERVER="ABC";
$DATABASE="dadw";
$USER_NAME="";
$PASSWORD="";
$dbh = DBI->connect("dbi:Sybase:server=$SERVER;databse=$DATABASE",$USER_NAME, $PASSWORD);
I am getting following error message:
install_driver(Sybase) failed: DBD::Sybase initialize: cs_ctx_alloc(113) failed
at c:/perl/lib/DynaLoader.pm line 223.
Compilation failed in require at (eval 4) line 3.
at b.pl line 11
Can someone help in solving this error message.
It appears that the driver is using CT-Connect libraries, so I would guess it needs to have valid server information in the interfaces file.
On windows the file is usually located in C:/sybase/interfaces.ini
Check this answer for more details on creating interface file entries.
Using Sybase ASE BCP to a Remote Server
In Sybase, the interfaces file in Windows is called sql.ini and it is located in the c:Sybase/ini/ folder.

Calling Openoffice from Perl throws NoSuchElementexception

I try to convert odt-Files to doc-Files using OpenOffice. Installed Version is 3.1.1 and can't be changed at the moment. Perl Version is 5.18.
The Perl-module OpenOffice::UNO is used for this conversion. Unfortunately in newer Versions of OpenOffice/LibreOffice do not support Perl anymore.
The Script calls OpenOffice headless using xvfb.
Here is the code used:
`# Launch OpenOffice.org as a server
$ ooffice \
"-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"
use OpenOffice::UNO;
# connect to the OpenOffice.org server
$uno = OpenOffice::UNO->new;
$cxt = $uno->createInitialComponentContext('file:///.../path/perluno');
$sm = $cxt->getServiceManager;
$resolver = $sm->createInstanceWithContext
("com.sun.star.bridge.UnoUrlResolver", $cxt);
$rsm = $resolver->resolve
("uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager");
# get an instance of the Desktop service
$rc = $rsm->getPropertyValue("DefaultContext");
$desktop = $rsm->createInstanceWithContext("com.sun.star.frame.Desktop", $rc);
.....`
On the last included line to create $desktop i get following Error message:
terminate called after throwing an instance of 'com::sun::star::container::NoSuchElementException'
Is there any way to fix this problem? Tried to understand the Code of the UNO-interface, especially UNO.xs but there has not been any information about the call "createInstanceWithContext".
Looking through the OpenOffice-documentation does not provide any information about this either.
It would also help just to get the complete java error message, to make sure what element is missing.
The file "perluno" has the content:
[Bootstrap]
UNO_TYPES=/usr/lib64/openoffice.org//program/types.rdb
UNO_SERVICES=/usr/lib64/openoffice.org//program/services.rdb