Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"git": executable file not found in $PATH #291

Open
air3ijai opened this issue May 17, 2024 · 6 comments
Open

"git": executable file not found in $PATH #291

air3ijai opened this issue May 17, 2024 · 6 comments

Comments

@air3ijai
Copy link
Contributor

I'm trying to follow the guide Generating Common Contracts using Docker image

docker run --rm \
  -v ./web3-data:/data \
  gochain/web3 \
  generate contract erc20 --name "Test Tokens" --symbol TEST

But get the error

2024/05/17 09:29:12 Cloning OpenZeppelin v4.6.0...
ERROR: Cloning finished with error: exec: "git": executable file not found in $PATH

And we can check that git executable is missing in the Docker image

# Check sh
docker run -it --entrypoint /bin/sh gochain/web3 -c "which sh"
/bin/sh

# Check git
docker run -it --entrypoint /bin/sh gochain/web3 -c "which git"

# Check interactively
docker run -it --entrypoint /bin/sh gochain/web3
/app # which git
/app #
/app # git
/bin/sh: git: not found
@air3ijai
Copy link
Contributor Author

air3ijai commented May 17, 2024

Docker builds probably are done via Dockerfile, we can fix that by updating

- RUN apk add --no-cache ca-certificates
+ RUN apk add --no-cache ca-certificates git

@air3ijai
Copy link
Contributor Author

air3ijai commented May 17, 2024

We can use a wrapper Dockerfile as a workaround

FROM gochain/web3
RUN apk add --no-cache git
# Build
docker build -t web3-git .

# Size
docker images -a | grep web3
web3-git       latest   0a9e9c666a5f   44 seconds ago   58MB
gochain/web3   latest   88dded04d5cb   5 months ago     42MB

# Check
docker run -it --entrypoint /bin/sh web3-git -c "which git"
/usr/bin/git

But there is an issue that web3 will clone repository into the local /app directory and will write contract in the same location. In that way we can't mount /app, unless we will copy web3 binary

# Copy binary
docker run --rm \
  -v ./web3-data:/app-data \
  --entrypoint /bin/sh \
  web3-git \
  -c "cp /app/web3 /app-data"

# Generate contract
docker run --rm \
  -v ./web3-data:/app \
  web3-git \
  generate contract erc20 --name "Test Tokens" --symbol TEST

@air3ijai
Copy link
Contributor Author

Looks like we can't build contract inside Docker image as we rely to Docker for that

docker run --rm \
  -v ./web3-data:/app \
  web3-git \
  contract build TEST.sol
ERROR: Failed to compile "TEST_flatten.sol": solc: exec: "docker": executable file not found in $PATH

@treeder
Copy link
Contributor

treeder commented May 17, 2024

To run those commands inside docker, we'd have to have a docker-in-docker build, which we don't have.

Best to run it outside of docker if you can.

@air3ijai
Copy link
Contributor Author

air3ijai commented May 17, 2024

I'm not so familiar with that, but can we create Docker images with solidity compiller?

Installing the Solidity Compiler - Docker

@treeder
Copy link
Contributor

treeder commented May 19, 2024

Ya, that's an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants