goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.5k stars 470 forks source link

What could be causing `unexpected word (expecting ")")`? #823

Closed mdb closed 11 months ago

mdb commented 11 months ago

👋 Hello - thanks for your work on goss! I'm attempting to use dgoss (at 54a77a9) and consistently runing up against a /goss/goss: line 2: syntax error: unexpected word (expecting ")") error. I can reproduce this error across multiple Docker images, and it occurs in scenarios where I expect passing tests as well as in scenarios where I expect failing tests. For example...

A simple goss.yaml file:

---
file:
  /bin/hugo:
    exists: true

...used with an example dgoss invocation:

dgoss run --tty --entrypoint sh klakegg/hugo
INFO: Starting docker container
INFO: Container ID: 263917ca
INFO: Sleeping for 0.2
INFO: Container health
INFO: Running Tests
H__PAGEZEROx__TEXTǐ__text__TEXT: not found
/goss/goss: line 2: syntax error: unexpected word (expecting ")")
INFO: Deleting container

This is occurring on an Apple M1 Pro running macOS Ventura 13.4.1 using Docker version 20.10.23, build 7155243. Am I overlooking something obvious? Thanks!

aelsabbahy commented 11 months ago

Hello, thank you for opening this. My guess would be you may be attempting to run a Mac binary in Linux.

Download the proper Goss binary somewhere on your Mac. Set GOSS_PATH env var to that binary.

For debugging, you can just manually copy the Goss binary you have today into the container and run it to see if it gives the same error.

My guess is you need the Linux-amd64 or Linux-arm* versions.. to be honest, I'm not up to date on the latest m1/m2 Mac docker story.

If you find a binary that works, can you report back on this issue.. I'd love to update the docs for others.. m1/m2+ chips seem like they'll be a common developer setup for the future.

mdb commented 11 months ago

Thanks @aelsabbahy - That clarifies a lot. Admittedly, I wasn't expecting dgoss to rely on a goss binary living on the host; I was expecting its sole dependency to essentially be docker itself.

So, to resolve the error I describe above, I first downloaded a goss-linux-amd64:

curl \
  --fail \
  --silent \
  --show-error \
  --location \
  "https://github.com/goss-org/goss/releases/download/v0.3.23/goss-linux-amd64" \
  --output goss

Then, I used this goss as the value of GOSS_PATH when running dgoss:

$ GOSS_PATH=goss dgoss run --tty --entrypoint sh klakegg/hugo
INFO: Starting docker container
INFO: Container ID: 7f820b06
INFO: Sleeping for 0.2
INFO: Container health
INFO: Running Tests
File: /bin/hugo: exists: matches expectation: [true]

Total Duration: 0.015s
Count: 1, Failed: 0, Skipped: 0
INFO: Deleting container
aelsabbahy commented 11 months ago

Feel free to submit a PR updating the documentation if you feel it would help the next person.

Thank you for validating this!