GitHub
05/10/2024, 5:39 PMpact-mock-service binary runs and my contracts can be verified.
Actual behaviour
When I try to run my contract suite locally I get the following error:
[2020-03-30T07:29:11.285Z] ERROR: pact-node@10.8.0/43955 on riazor.fritz.box:
Pact Binary Error: standalone/darwin-1.82.1/pact/bin/pact-mock-service: line 19: cd: ./standalone/darwin-1.82.1/pact/bin
/Users/farruco/repos/work/comments-api/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.1/pact/bin: No such file or directory
Notice that the error contains two paths:
• ./standalone/darwin-1.82.1/pact/bin
• /Users/farruco/repos/work/comments-api/node_modules/@pact-foundation/pact-node/standalone/darwin-1.82.1/pact/bin
Steps to reproduce
After some debugging I discovered what the issue is. The error I pasted above is thrown from the script standalone/darwin-1.82.1/pact/bin/pact-mock-service when it tries to get the path to the library dir. This are the relevant lines in that script:
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
# Figure out where this script is located.
LIBDIR="`cd \"$DIR\" && cd ../lib && pwd`"
In my current setup the variable $DIR results in a string which contains the two paths I listed above and that results in an error at the line where the script tries to generate the value for the $LIBDIR variable.
Why does $DIR contains two paths? Because I'm have the $CDPATH env variable set in my shell and that interferes with how cd behaves.
With $CDPATH set the statement cd -P "$( dirname "$SOURCE" )" will echo the path to which it changed the directory (if the path was relative). This echoed path is concatenated to the result from pwd.
With $CDPATH unset the statement cd -P "$( dirname "$SOURCE" )" won't echo anything.
Relevant log files
n/a
pact-foundation/pact-ruby-standaloneGitHub
05/10/2024, 5:39 PM