goss-org / goss

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

sh: 1: goss: not found #389

Closed slecache closed 4 years ago

slecache commented 5 years ago

Environment:

When I try dgoss edit -p 8080:80 nginx:1.11.1 I get the following error:

INFO: Starting docker container
INFO: Container ID: ffdde748
INFO: Run goss add/autoadd to add resources
# goss
sh: 1: goss: not found
#
edyan commented 5 years ago

Hi, make sure bash is installed (the dgoss interpreter is bash)

Or try to verify : sh dgoss edit -p 8080:80 nginx:1.11.1 and bash dgoss edit -p 8080:80 nginx:1.11.1 from where dgoss script is

slecache commented 5 years ago

Hi,

Bash is installed and it is the default shell interpreter:

$ ps -p $$ | awk '$1 != "PID" {print $(NF)}'
ps -p $$ | awk '$1 != "PID" {print $(NF)}'
bash

$ bash --version
bash --version
GNU bash, version 4.3.48(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Starting with sh failed:

$ cd $(dirname `which dgoss`) && sh dgoss edit -p 8080:80 nginx:1.11.1
dgoss: 71: dgoss: [[: not found
-e ERROR: Couldn't find goss installation, please set GOSS_PATH to it
dgoss: 20: dgoss: [[: not found

And got the same error as before by forcing bash. goss seems to be missing (in the temporary container?):

$ cd $(dirname `which dgoss`) && bash dgoss edit -p 8080:80 nginx:1.11.1
INFO: Starting docker container
INFO: Container ID: a90bac77
INFO: Run goss add/autoadd to add resources
# goss a file /var/log/nginx/access.log /var/log/nginx/error.log
sh: 1: goss: not found
#
edyan commented 5 years ago

Hi, if i run the command under linux I have no problem so I believe it's related to windows.

The only thing I know is that goss is mounted in /goss/goss you can try then /goss/goss a file ...

I personnaly, can't help. Good luck !

justinschmitt commented 5 years ago

I'm experiencing the same issue with the same development environment. I think it's a WSL specific issue.

Edit: I was able to resolve this issue by setting the environment variable: export GOSS_FILES_STRATEGY=cp

SimonBaeumer commented 5 years ago

The problem is that dgoss wants to mount a directory into your container from another container. This gives problems with the filesystem overflayfs used by docker.

You can find a little bit more information in this article in the section the ugly. Using Docker-in-Docker

syednadeembe commented 5 years ago

My environment is linux and i get the same problem.

I'm following along this link: https://medium.com/@aelsabbahy/tutorial-how-to-test-your-docker-image-in-half-a-second-bbd13e06a4a9

goss a file /var/log/nginx/access.log /var/log/nginx/error.log is what I'm pasting in the interactive shell and the following error is displayed

/goss/goss: 1: /goss/goss: Not: not found

aelsabbahy commented 5 years ago

dgoss uses mount by default, but can be changed to cp, you'll lose some functionality, but it's needed in some cases. Try setting GOSS_FILE_STRATEGY to cp.

Also, on non-linux systems you have to define GOSS_PATH pointing it to the full path of the goss executable.

Here's a list of all variables and their defaults, you can also look at dgoss code (~100 lines of bash) to get a closer look at what each of those vars do. Environment vars and defaults

syednadeembe commented 5 years ago

How do I have to set GOSS_FILE_STRATEGY to cp ?

This is how my environment looks like: --I have docker demon running on a linux VM. --On this VM I Installed goss/dgoss --I tried export GOSS_FILES_STRATEGY=cp on the VM --Then executed dgoss edit -p 8080:80 nginx:1.11.10x --Now I'm logged into the interactive shell, writting goss a file /var/log/nginx/access.log /var/log/nginx/error.log gives me the error.

export GOSS_FILES_STRATEGY=cp is what I'm doing on the VM where the docker demon is running but that not resolving the problem,

syednadeembe commented 5 years ago

I also tried to set this value directly in the dgoss file. ( this file on my VM, see above comment for setup details )

Did the following for reference: [saguser@vmmosy08 bin]$ which goss /usr/local/bin/goss [saguser@vmmosy08 bin]$ which dgoss /usr/local/bin/dgoss

[saguser@vmmosy08 bin]$ cat /usr/local/bin/goss Not Found[saguser@vmmosy08 bin]$

[saguser@vmmosy08 bin]$ vi /usr/local/bin/dgoss //Manually set GOSS_FILES_STRATEGY=cp

syednadeembe commented 5 years ago

[Resolved]

A cup of coffee did the trick for me :)

I decided to reinstall goss/dgoss and while deleting I noticed that binaries for the project are stored in two different location. One at the local user level /usr/local/bin/goss another at the root/global level ~/bin/goss

Even if I'm logged in as a local user, the variables are still defaulted to those specified at the root level.

Thank you @aelindeman will try to use this in my project and will send you the feedback