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

[BUG] Dock run error on windows (Cargo.toml) #74

Closed
ToniBar opened this issue May 25, 2022 · 5 comments
Closed

[BUG] Dock run error on windows (Cargo.toml) #74

ToniBar opened this issue May 25, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@ToniBar
Copy link

ToniBar commented May 25, 2022

Issue description

I try to run npx terrain deploy counter --signer validator in windows. This fails with error message on $(pwd).

Steps to reproduce the issue

  1. Run npx terrain deploy counter --signer validator in windows.
  2. Error message: docker: Error response from daemon: create $(pwd): "$(pwd)" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
    See 'docker run --help'.
    Error: Command failed: docker run --rm -v "$(pwd)":/code --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry
    cosmwasm/rust-optimizer:0.12.5

Tools and operating system versions

Operating system: windows 10

From what I found the error is caused because windows doesn't recognize $(pwd) and it should be %cd% instead. The docker -run call leading to this error can be found under folder /counter in file Cargo.toml. Modifying pwd to cd in this file doesn't work because this file is regenerated after every run. I have for the moment no idea where this generation happens so I am not able to modify pwd.

@ToniBar ToniBar added the bug Something isn't working label May 25, 2022
@emidev98
Copy link
Contributor

Hey, thanks for the bug report, as soon as we get some time we'll check it!

@ToniBar
Copy link
Author

ToniBar commented May 25, 2022

Hey, thanks for the bug report, as soon as we get some time we'll check it!

I managed to find where the code is located. It is located in the deployment.js file in the storeCode function. The following code is called:

child_process_1.execSync(`docker run --rm -v "$(pwd)":/code \
        --mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
        --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
        cosmwasm/rust-optimizer-arm64:0.12.5`, { stdio: "inherit" });

If I remove the second line of the code and replace ¨$(pwd)" with "%cd%", then I get a built and a deployment though not 100 % correct because the second line was removed of course. So what I get is:

child_process_1.execSync(`docker run --rm -v "%cd%":/code \
        --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
        cosmwasm/rust-optimizer:0.12.5`, { stdio: "inherit" });

But the part --mount type=volume,source="$(basename "%cd%")_cache",target=/code/target \ still gives problems. No idea how to solve this. The problem is with "basename".

@ToniBar
Copy link
Author

ToniBar commented May 25, 2022

Hey, thanks for the bug report, as soon as we get some time we'll check it!

I fixed the basename error as well. This is my solution for windows environments:

var filename = path.basename(path.resolve(process.cwd()));
            child_process_1.execSync(`docker run --rm -v "%cd%":/code \
        --mount type=volume,source=${filename}_cache,target=/code/target \
        --mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
        cosmwasm/rust-optimizer:0.12.5`, { stdio: "inherit" });

@emidev98 emidev98 changed the title Dock run error on windows (Cargo.toml)[BUG] [BUG] Dock run error on windows (Cargo.toml) Jun 20, 2022
@octalmage
Copy link
Contributor

Hey @ToniBar,

sorry for the delay here! Have you tried running Terrain with WSL, or is there a reason why you wouldn't be able to use WSL? In our experience using WSL can avoid these types of issues.

@octalmage
Copy link
Contributor

Closing, please reopen if you're still having issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants