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

cargo subcommands does not work on Windows when installing those binaries by aqua #2875

Closed
sapphi-red opened this issue May 10, 2024 · 10 comments
Labels
bug Something isn't working

Comments

@sapphi-red
Copy link
Contributor

sapphi-red commented May 10, 2024

aqua info

$ aqua info
{
  "version": "2.27.3",
  "commit_hash": "55503812e74e63a4ea0eeb3860840d7dce3d596d",
  "os": "windows",
  "arch": "amd64",
  "pwd": "C:\\Users\\green",
  "root_dir": "C:\\Users\\green\\AppData\\Local\\aquaproj-aqua",
  "env": {
    "AQUA_GLOBAL_CONFIG": "C:\\Users\\green\\.config\\aquaproj-aqua\\aqua.yaml"
  },
  "config_files": []
}

Overview

cargo allows users to add subcommands by placing cargo-${subcommand-name} binary in PATH env var. On Linux (WSL), this feature works when installing those binaries by aqua.
But on Windows, this feature doesn't work. It doesn't work because cargo only looks for .exe files and aqua places .bat files.

How to reproduce

aqua.yaml

registries:
  - type: standard
    ref: v4.176.0
packages:
- name: crates.io/cargo-expand@1.0.86

Executed command and output

$ cargo expand --version
error: no such command: `expand`

        View all installed commands with `cargo --list`

Debug output

No response

Expected behaviour

$ cargo expand --version
cargo-expand 1.0.86

cargo expand command works without error like on Linux when cargo-expand is installed by aqua.

Actual behaviour

$ cargo expand --version
error: no such command: `expand`

        View all installed commands with `cargo --list`

cargo expand command shows error when cargo-expand is installed by aqua.

Note

I can just run the command with cargo-expand so it's not something urgent.

I read https://zenn.dev/shunsuke_suzuki/scraps/88e008721e748b#comment-725555a2b1b034 and understand that this is a hard problem. I'm not sure how to solve this. 😅

@sapphi-red sapphi-red added the bug Something isn't working label May 10, 2024
@suzuki-shunsuke
Copy link
Member

suzuki-shunsuke commented May 10, 2024

Thank you for your report.
aqua creates shell scripts on bin directory but these scripts don't have file extension.
So maybe we can solve this issue by adding file extension.

if err := is.createBinWindows(filepath.Join(is.rootDir, "bin", binName), scrTemplate, logE); err != nil {

if err := afero.WriteFile(is.fs, proxyPath, []byte(binTxt), proxyPermission); err != nil {

@suzuki-shunsuke suzuki-shunsuke moved this to Todo in main May 10, 2024
@sapphi-red
Copy link
Contributor Author

I had a typo in my original post.

aqua places .bin .bat files.


maybe we can solve this issue by adding file extension.

Just in case, if I simply rename C:\Users\green\AppData\Local\aquaproj-aqua\bin\cargo-expand to C:\Users\green\AppData\Local\aquaproj-aqua\bin\cargo-expand.exe, I get the following error.

cargo expand
error: could not execute process `C:\Users\green\AppData\Local\aquaproj-aqua\bin\cargo-expand.exe expand` (never executed)

Caused by:
  このバージョンの %1 は、実行中の Windows のバージョンと互換性がありません。コンピューターのシステム情報を確認してから 、ソフトウェアの発行元に問い合わせてください。 (os error 216)

I guess cargo runs the file directly (= without shell).

@suzuki-shunsuke
Copy link
Member

suzuki-shunsuke commented May 10, 2024

I see. It's hard to solve this issue.
Generally speaking, there are two approaches of CLI Version Manager.

  1. Use proxies to change tool versions dynamically
  2. Change the environment variable PATH dynamically by shell

aqua adopts the first one, but I think this issue can't be solved by the first one.
The second approach is required to solve this issue.

@suzuki-shunsuke suzuki-shunsuke moved this from Todo to Backlog in main May 10, 2024
@matzeeable
Copy link

@suzuki-shunsuke is this also the case for docker compose? When installing Docker and Docker Compose through aqua, the subcommand compose within docker cannot be found.

@suzuki-shunsuke
Copy link
Member

I think the subcommand of docker has nothing to do with this issue.
Do you use Windows?
Could you tell me versions of aqua and Docker?

aqua info
which docker
aqua which -v docker

@suzuki-shunsuke
Copy link
Member

suzuki-shunsuke commented May 23, 2024

I remembered.
To install Docker Compose v2 by aqua, it's a bit tricky.
Please see the release note.
https://github.com/aquaproj/aqua-registry/releases/tag/v3.13.0

I haven't tested on Windows, so I'm not sure if it works on Windows.

@suzuki-shunsuke
Copy link
Member

Maybe #2918 is helpful for this issue.

@sapphi-red
Copy link
Contributor Author

sapphi-red commented May 31, 2024

Yes, #2918 works for this.

If I run the following command by powershell, then cargo expand --version works.

# make hard link from "aqua which cargo-expand" to "aquaproj-aqua\bin\cargo-expand.exe"
$ New-Item -ItemType HardLink -Path $env:LOCALAPPDATA\aquaproj-aqua\bin\cargo-expand.exe -Value $(aqua which cargo-expand)

@suzuki-shunsuke
Copy link
Member

#2918 was resolved, so maybe this issue was also resolved.

@sapphi-red
Copy link
Contributor Author

Thanks for implementing #2918! Yes, it worked.

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
No open projects
Status: Backlog
Development

No branches or pull requests

3 participants