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

gitops: TypeError: no implicit conversion of Hash into String #36

Closed
mjtrangoni opened this issue Dec 5, 2023 · 11 comments · Fixed by #37
Closed

gitops: TypeError: no implicit conversion of Hash into String #36

mjtrangoni opened this issue Dec 5, 2023 · 11 comments · Fixed by #37

Comments

@mjtrangoni
Copy link

Hi,

I am facing this issues while trying to install the gitops Formula in a zsh shell, and the following error appears.
Is it something already known?

  • macOS version
sw_vers
ProductName:            macOS
ProductVersion:         14.1.2
BuildVersion:           23B92
  • brew install
brew install -v -d weaveworks/tap/gitops
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::TapLoader): loading /opt/homebrew/Library/Taps/weaveworks/homebrew-tap/Formula/gitops.rb
/opt/homebrew/Library/Homebrew/brew.rb (Cask::CaskLoader::FromTapLoader): loading weaveworks/tap/gitops
==> Fetching weaveworks/tap/gitops
==> Downloading https://github.com/weaveworks/weave-gitops/releases/download/v0.37.0/gitops-Darwin-arm64.tar.gz
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/4.1.23\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 14.1.2\)\ curl/8.1.2 --header Accept-Language:\ en --retry 3 --fail --location --silent --head https://github.com/weaveworks/weave-gitops/releases/download/v0.37.0/gitops-Darwin-arm64.tar.gz
Already downloaded: /Users/mtrangoni/Library/Caches/Homebrew/downloads/f49ca5e63c0ea4f1046fd40ca231f45d388b354026cdc60fdf251d2191f7c850--gitops-Darwin-arm64.tar.gz
==> Verifying checksum for 'f49ca5e63c0ea4f1046fd40ca231f45d388b354026cdc60fdf251d2191f7c850--gitops-Darwin-arm64.tar.gz'
==> Installing gitops from weaveworks/tap
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/git --version
/usr/bin/env tar --extract --no-same-owner --file /Users/mtrangoni/Library/Caches/Homebrew/downloads/f49ca5e63c0ea4f1046fd40ca231f45d388b354026cdc60fdf251d2191f7c850--gitops-Darwin-arm64.tar.gz --directory /private/tmp/d20231205-75988-fc3215
/usr/bin/env cp -pR /private/tmp/d20231205-75988-fc3215/LICENSE /private/tmp/gitops-20231205-75988-vybtx9/LICENSE
/usr/bin/env cp -pR /private/tmp/d20231205-75988-fc3215/README.md /private/tmp/gitops-20231205-75988-vybtx9/README.md
/usr/bin/env cp -pR /private/tmp/d20231205-75988-fc3215/gitops /private/tmp/gitops-20231205-75988-vybtx9/gitops
/opt/homebrew/Library/Homebrew/ignorable.rb:29:in `block in raise'
ErrorDuringExecution: Failure while executing; `\{\"SHELL\"=\>\"bash\"\} /opt/homebrew/Cellar/gitops/0.37.0/bin/gitops\ completion\ bash\ --no-analytics \{:err=\>:err\}` exited with 1. Here's the output:
==> Temporary files retained at:
/private/tmp/gitops-20231205-75988-vybtx9
1. raise
2. ignore
3. backtrace
4. irb
5. shell
Choose an action: 2
/opt/homebrew/Library/Homebrew/ignorable.rb:29:in `block in raise'
ErrorDuringExecution: Failure while executing; `\{\"SHELL\"=\>\"zsh\"\} /opt/homebrew/Cellar/gitops/0.37.0/bin/gitops\ completion\ zsh\ --no-analytics \{:err=\>:err\}` exited with 1. Here's the output:
==> Temporary files retained at:
/private/tmp/gitops-20231205-75988-vybtx9
1. raise
2. ignore
3. backtrace
4. irb
5. shell
Choose an action: 2
/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/git --version
Error: An exception occurred within a child process:
  TypeError: no implicit conversion of Hash into String
/opt/homebrew/Library/Homebrew/utils/popen.rb:55:in `exec'
/opt/homebrew/Library/Homebrew/utils/popen.rb:55:in `block in popen'
/opt/homebrew/Library/Homebrew/utils/popen.rb:47:in `popen'
/opt/homebrew/Library/Homebrew/utils/popen.rb:47:in `popen'
/opt/homebrew/Library/Homebrew/utils/popen.rb:9:in `popen_read'
/opt/homebrew/Library/Homebrew/utils/popen.rb:16:in `safe_popen_read'
/opt/homebrew/Library/Taps/weaveworks/homebrew-tap/Formula/gitops.rb:18:in `install'
/opt/homebrew/Library/Homebrew/debrew.rb:17:in `block in install'
/opt/homebrew/Library/Homebrew/debrew.rb:88:in `debrew'
/opt/homebrew/Library/Homebrew/debrew.rb:17:in `install'
/opt/homebrew/Library/Homebrew/build.rb:177:in `block (3 levels) in install'
/opt/homebrew/Library/Homebrew/extend/kernel.rb:499:in `with_env'
/opt/homebrew/Library/Homebrew/build.rb:139:in `block (2 levels) in install'
/opt/homebrew/Library/Homebrew/formula.rb:1419:in `block in brew'
/opt/homebrew/Library/Homebrew/formula.rb:2903:in `block (2 levels) in stage'
/opt/homebrew/Library/Homebrew/extend/kernel.rb:499:in `with_env'
/opt/homebrew/Library/Homebrew/formula.rb:2902:in `block in stage'
/opt/homebrew/Library/Homebrew/resource.rb:129:in `block (2 levels) in unpack'
/opt/homebrew/Library/Homebrew/download_strategy.rb:121:in `chdir'
/opt/homebrew/Library/Homebrew/download_strategy.rb:113:in `stage'
/opt/homebrew/Library/Homebrew/resource.rb:125:in `block in unpack'
/opt/homebrew/Library/Homebrew/mktemp.rb:75:in `block in run'
/opt/homebrew/Library/Homebrew/mktemp.rb:75:in `chdir'
/opt/homebrew/Library/Homebrew/mktemp.rb:75:in `run'
/opt/homebrew/Library/Homebrew/resource.rb:226:in `stage_resource'
/opt/homebrew/Library/Homebrew/resource.rb:124:in `unpack'
/opt/homebrew/Library/Homebrew/resource.rb:98:in `stage'
/opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/3.1.0/forwardable.rb:238:in `stage'
/opt/homebrew/Library/Homebrew/formula.rb:2882:in `stage'
/opt/homebrew/Library/Homebrew/formula.rb:1412:in `brew'
/opt/homebrew/Library/Homebrew/build.rb:133:in `block in install'
/opt/homebrew/Library/Homebrew/extend/kernel.rb:499:in `with_env'
/opt/homebrew/Library/Homebrew/build.rb:128:in `install'
/opt/homebrew/Library/Homebrew/build.rb:229:in `<main>'
@bigkevmcd
Copy link
Contributor

Hello @mjtrangoni this looks like you're running this on an old version of Ruby?

The signature for the exec function changed between the now EOL Ruby 2 and Ruby 3.

Might want to upgrade to a newer version of Ruby?

@mjtrangoni
Copy link
Author

Hi @bigkevmcd,

Indeed, I was running ruby 2.6 and upgraded to ruby 3.1, but without any change. See,

ruby --version
ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [arm64-darwin23]
brew link --overwrite --force ruby
Linking /opt/homebrew/Cellar/ruby/3.2.2_1... 4185 symlinks created.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/opt/homebrew/opt/ruby/bin:$PATH"' >> ~/.zshrc
brew install gitops
==> Fetching weaveworks/tap/gitops
==> Downloading https://github.com/weaveworks/weave-gitops/releases/download/v0.37.0/gitops-Darwin-arm64.tar.gz
Already downloaded: /Users/mtrangoni/Library/Caches/Homebrew/downloads/f49ca5e63c0ea4f1046fd40ca231f45d388b354026cdc60fdf251d2191f7c850--gitops-Darwin-arm64.tar.gz
==> Installing gitops from weaveworks/tap
Error: An exception occurred within a child process:
  TypeError: no implicit conversion of Hash into String

@bigkevmcd
Copy link
Contributor

@mjtrangoni I think this is a change in Homebrew https://github.com/Homebrew/brew/releases/tag/4.1.23

@Bo98
Copy link

Bo98 commented Dec 5, 2023

Ruby 3 is stricter about kwargs: https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/

The way to fix it is:

diff --git a/Formula/gitops.rb b/Formula/gitops.rb
index 0ba1055..059fbe4 100644
--- a/Formula/gitops.rb
+++ b/Formula/gitops.rb
@@ -30,11 +30,11 @@ class Gitops < Formula
       def install
         bin.install "gitops"
         # Install bash completion
-        output = Utils.safe_popen_read({ "SHELL" => "bash" }, "#{bin}/gitops completion bash --no-analytics", { :err => :err })
+        output = Utils.safe_popen_read({ "SHELL" => "bash" }, "#{bin}/gitops completion bash --no-analytics", err: :err)
         (bash_completion/"gitops").write output
 
         # Install zsh completion
-        output = Utils.safe_popen_read({ "SHELL" => "zsh" }, "#{bin}/gitops completion zsh --no-analytics", { :err => :err })
+        output = Utils.safe_popen_read({ "SHELL" => "zsh" }, "#{bin}/gitops completion zsh --no-analytics", err: :err)
         (zsh_completion/"_gitops").write output
       end
     end

(As a side note: is there a reason the install code is copy-pasted 4 times?)

@bigkevmcd
Copy link
Contributor

@Bo98 Thanks for that, I'll get a change made and hopefully that'll fix it!

@enekofb
Copy link
Contributor

enekofb commented Dec 6, 2023

thanks @Bo98 for the suggestion 🙏

@mjtrangoni could you give it a try now?

@mjtrangoni
Copy link
Author

@enekofb it is working now. Thank you!

brew install gitops
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 1 tap (weaveworks/tap).

==> Fetching weaveworks/tap/gitops
==> Downloading https://github.com/weaveworks/weave-gitops/releases/download/v0.37.0/gitops-Darwin-arm64.tar.gz
Already downloaded: /Users/mtrangoni/Library/Caches/Homebrew/downloads/f49ca5e63c0ea4f1046fd40ca231f45d388b354026cdc60fdf251d2191f7c850--gitops-Darwin-arm64.tar.gz
==> Installing gitops from weaveworks/tap
==> Caveats
zsh completions have been installed to:
  /opt/homebrew/share/zsh/site-functions
==> Summary
🍺  /opt/homebrew/Cellar/gitops/0.37.0: 7 files, 65.3MB, built in 2 seconds
==> Running `brew cleanup gitops`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

@enekofb
Copy link
Contributor

enekofb commented Dec 6, 2023

Nice, thanks for reporting it!

@mjtrangoni
Copy link
Author

@enekofb @bigkevmcd it seems the new release reverted your fix, see here

Would it make sense to add a CI test for this?

@enekofb
Copy link
Contributor

enekofb commented Dec 6, 2023

raised weaveworks/weave-gitops#4161

enekofb added a commit to weaveworks/weave-gitops that referenced this issue Dec 6, 2023
@enekofb
Copy link
Contributor

enekofb commented Dec 6, 2023

both CI and formula updated after v0.38 release

@enekofb enekofb closed this as completed Dec 6, 2023
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

Successfully merging a pull request may close this issue.

4 participants