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

Support autocompletions #55

Open
maslyankov opened this issue Feb 12, 2024 · 12 comments
Open

Support autocompletions #55

maslyankov opened this issue Feb 12, 2024 · 12 comments

Comments

@maslyankov
Copy link
Contributor

maslyankov commented Feb 12, 2024

Hello! I am facing the following issue. Any idea what might be the cause of it?

 ~ % brew install talosctl                           
==> Fetching siderolabs/tap/talosctl
==> Downloading https://github.com/siderolabs/talos/releases/download/v1.6.4/talosctl-darwin-arm64
Already downloaded: /Users/maslyankov/Library/Caches/Homebrew/downloads/485b9ad5cac364a22d306b8aec2e873157cfde360ccac1576ee4e4dfae896eb1--talosctl-darwin-arm64
==> Installing talosctl from siderolabs/tap
brew: exec failed: {"SHELL"=>"bash"}
Error: Failure while executing; `\{\"SHELL\"=\>\"bash\"\} /opt/homebrew/Cellar/talosctl/1.6.4/bin/talosctl completion bash` exited with 1. Here's the output:
@frezbo
Copy link
Member

frezbo commented Feb 12, 2024

@onedr0p seems to be the recent change. any ideas?

@onedr0p
Copy link
Contributor

onedr0p commented Feb 12, 2024

I am taking a look now, most of the other CLI apps I see doing this are doing it the same way as I added it here. Maybe there's a strange edge-case I am not seeing.

@maslyankov
Copy link
Contributor Author

After the failed install, I checked if there is a file installed and:

 ~ % /opt/homebrew/Cellar/talosctl/1.6.4/bin/talosctl
zsh: no such file or directory: /opt/homebrew/Cellar/talosctl/1.6.4/bin/talosctl

My idea is that maybe there might be some file copy issue.

@onedr0p
Copy link
Contributor

onedr0p commented Feb 12, 2024

Yeah there's a strange issue where the that command runs from /opt/homebrew/Cellar/talosctl/1.6.4/bin/talosctl but /opt/homebrew/bin/talosctl is symlinked to it.

@onedr0p
Copy link
Contributor

onedr0p commented Feb 12, 2024

I suggest we revert this change until I can sort it out on my end and hopefully get it working

@maslyankov
Copy link
Contributor Author

When I change:

def install
  if OS.mac? && Hardware::CPU.intel?
    bin.install "talosctl-darwin-amd64" => "talosctl"
  elsif OS.mac? && Hardware::CPU.arm?
    bin.install "talosctl-darwin-arm64" => "talosctl"
  elsif OS.linux? && Hardware::CPU.intel?
    bin.install "talosctl-linux-amd64" => "talosctl"
  elsif OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
    bin.install "talosctl-linux-armv7" => "talosctl"
  elsif OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
    bin.install "talosctl-linux-arm64" => "talosctl"
  end
  generate_completions_from_executable(bin/"talosctl", "completion")
end

to :

def install
  if OS.mac? && Hardware::CPU.intel?
    bin.install "talosctl-darwin-amd64" => "talosctl"
  elsif OS.mac? && Hardware::CPU.arm?
    bin.install "talosctl-darwin-arm64" => "talosctl"
  elsif OS.linux? && Hardware::CPU.intel?
    bin.install "talosctl-linux-amd64" => "talosctl"
  elsif OS.linux? && Hardware::CPU.arm? && !Hardware::CPU.is_64_bit?
    bin.install "talosctl-linux-armv7" => "talosctl"
  elsif OS.linux? && Hardware::CPU.arm? && Hardware::CPU.is_64_bit?
    bin.install "talosctl-linux-arm64" => "talosctl"
  end
end
   
def post_install
  generate_completions_from_executable(bin/"talosctl", "completion")
end

It installs as expected. Not sure if the completitions work though.

@onedr0p
Copy link
Contributor

onedr0p commented Feb 12, 2024

@maslyankov nice find! It works here:

❯ brew install siderolabs/tap/talosctl
==> Fetching siderolabs/tap/talosctl
==> Downloading https://github.com/siderolabs/talos/releases/download/v1.6.4/talosctl-darwin-arm64
...
fish completions have been installed to:
  /opt/homebrew/share/fish/vendor_completions.d
...

Do you want to PR that change, or want me to?

@maslyankov
Copy link
Contributor Author

@maslyankov nice find! It works here:

❯ brew install siderolabs/tap/talosctl
==> Fetching siderolabs/tap/talosctl
==> Downloading https://github.com/siderolabs/talos/releases/download/v1.6.4/talosctl-darwin-arm64
...
fish completions have been installed to:
  /opt/homebrew/share/fish/vendor_completions.d
...

Do you want to PR that change, or want me to?

I will do a PR, I have it locally.

@maslyankov
Copy link
Contributor Author

#56

@onedr0p
Copy link
Contributor

onedr0p commented Feb 12, 2024

Well interesting, even though it says the completions were installed I do not see them in /opt/homebrew/share/fish/vendor_completions.d so this isn't fixed unfortunately.

@maslyankov maslyankov reopened this Feb 12, 2024
@onedr0p
Copy link
Contributor

onedr0p commented Feb 12, 2024

I am completely lost to why it's not working the way it was before...

I don't see how what we are doing here is really any different than ...
https://github.com/fluxcd/homebrew-tap/blob/master/Formula/flux.rb

Here's the full debug log

✖ brew install -vd siderolabs/tap/talosctl
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/siderolabs/homebrew-tap/Formula/talosctl.rb
/opt/homebrew/Library/Homebrew/brew.rb (Cask::CaskLoader::FromTapLoader): loading siderolabs/tap/talosctl
==> Fetching siderolabs/tap/talosctl
==> Downloading https://github.com/siderolabs/talos/releases/download/v1.6.4/talosctl-darwin-arm64
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.2.7\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 14.3.1\)\ curl/8.4.0 --header Accept-Language:\ en --retry 3 --fail --location --silent --head https://github.com/siderolabs/talos/releases/download/v1.6.4/talosctl-darwin-arm64
Already downloaded: /Users/devin/Library/Caches/Homebrew/downloads/485b9ad5cac364a22d306b8aec2e873157cfde360ccac1576ee4e4dfae896eb1--talosctl-darwin-arm64
==> Verifying checksum for '485b9ad5cac364a22d306b8aec2e873157cfde360ccac1576ee4e4dfae896eb1--talosctl-darwin-arm64'
==> Installing talosctl from siderolabs/tap
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/git --version
/usr/bin/env hdiutil imageinfo -format /Users/devin/Library/Caches/Homebrew/downloads/485b9ad5cac364a22d306b8aec2e873157cfde360ccac1576ee4e4dfae896eb1--talosctl-darwin-arm64
cp -p /Users/devin/Library/Caches/Homebrew/downloads/485b9ad5cac364a22d306b8aec2e873157cfde360ccac1576ee4e4dfae896eb1--talosctl-darwin-arm64 /private/tmp/talosctl-20240212-37030-ufp5en/talosctl-darwin-arm64
brew: exec failed: {"SHELL"=>"bash"}
/opt/homebrew/Library/Homebrew/ignorable.rb:29:in `block in raise'
ErrorDuringExecution: Failure while executing; `\{\"SHELL\"=\>\"bash\"\} /opt/homebrew/Cellar/talosctl/1.6.4/bin/talosctl completion bash` exited with 1.

@onedr0p
Copy link
Contributor

onedr0p commented Feb 12, 2024

We should rename this issue to "Support autocompletions" or something similar, I am at my wits end trying to get it to work though 😄

@maslyankov maslyankov changed the title Install issue Support autocompletions Feb 12, 2024
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

3 participants