Hello everyone! Im trying to publish pact locally...
# pact-broker
a
Hello everyone! Im trying to publish pact locally in windows using pact-cli image directly:
docker run pactfoundation/pact-cli:latest publish C:\pacts\consumer-provider.json --consumer-app-version 0.0.1 --broker-base-url <http://localhost:9292/>
However, the pact throws this error: Specified pact file 'C:/pacts/consumer-provider.json' does not exist. This sometimes indicates one of the arguments has been specified with the wrong name and has been incorrectly identified as a file path. The file exists and is properly stored in this folder in my windows. Anyone can help me on that? Thanks a lot!
Hi @beth (pactflow.io/Pact Broker/pact-ruby), could you gimme some idea about what can be occurring here at this point? Is stranged because by pactBrokerApi I could publish properly.
y
Hi @Andre Rodrigues, Please don't directly tag maintainers, they will respond if/when they get time
a
Hey, sorry 😕
y
Please see the readme, you need to volume mount your pacts into the docker container
https://github.com/pact-foundation/pact-ruby-cli#publish-pacts you can see the
-v
command being using to mount the working directory, into the container. The files are
$PWD/example/pacts
are being used to publish, assume you are running the docker command from the root of this repo https://github.com/pact-foundation/pact-ruby-cli so you would volume mount to pact directory, or file into the container with regular docker syntax, and then provide the path (to the file in the container) not on your root filesystem
a
ah ok ok, I know about it 🙂 Thanks Yousaf.
y
np, also worth noting that you may need to change the hostname for your local broker, on mac/windows machines in the cli command https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
a
Yeah, great! thanks a lot.
Hi Yousaf. Just to leave it here for other people who eventually had the same question... The final command in windows:
Copy code
docker run --network="host" --rm -it -v ${PWD}/pacts:/example/pacts pactfoundation/pact-cli:latest publish /example/pacts --consumer-app-version 0.0.1 --broker-base-url <http://localhost:9292>
thank you again 🙂
b
How is this for an improved error message?
Copy code
"Specified pact file '#{path}' does not exist. This sometimes indicates one of the arguments has been specified with the wrong name and has been incorrectly identified as a file path. If you are using Docker, check that you have mounted the pact file or directory into the container correctly using `-v`, and have specified the location of the pact file or directory in the *Docker container*, not the *host*."
chefkiss 1
a
Hello Beth, awesome 🙂 It will help a lot !! Thank you for this update!!
🙌 1
y
Indeed nice work Beth and thanks for raising Andre, it will certainly help others, as it's a common gotcha, that gets me when I hop onto another machine every now and then. It has got me thinking, as I have thought this before with our pact-cli commands. it might be useful to show for each command • description • command to run via pact-ruby standalone, pact_broker-client gem or pact broker docker • commands to run via windows / linux / mac ◦ windows might need catering for the various shells (powershell / cmd prompt / git bash ) We have the 3 ways to install it https://docs.pact.io/pact_broker/client_cli/readme#installation We could have a copyable example (without the explanation of the command as part of the copy block) https://docs.pact.io/pact_broker/client_cli/readme#pacts I tried a similar pattern for the introduction of the bi-directional `pactflow publish-provider-contract`command https://docs.pactflow.io/docs/bi-directional-contract-testing/contracts/oas/#publishing
👏 1