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

Open
sapphi-red opened this issue May 10, 2024 · 3 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 {

@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.

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

No branches or pull requests

2 participants