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

Ruby 3.0 issue - wrong number of arguments (given 2, expected 1) #4

Closed
ptfly opened this issue Jul 28, 2021 · 11 comments
Closed

Ruby 3.0 issue - wrong number of arguments (given 2, expected 1) #4

ptfly opened this issue Jul 28, 2021 · 11 comments
Labels

Comments

@ptfly
Copy link

ptfly commented Jul 28, 2021

I'm having a crash when trying to use the plugin:

/usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-plugin-slack_bot-1.0.0/lib/fastlane/plugin/slack_bot/helper/slack_bot_link_formatter_helper.rb:41:in `initialize': \e[31m[!] wrong number of arguments (given 2, expected 1)\e[0m (ArgumentError)
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-plugin-slack_bot-1.0.0/lib/fastlane/plugin/slack_bot/helper/slack_bot_link_formatter_helper.rb:35:in `new'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-plugin-slack_bot-1.0.0/lib/fastlane/plugin/slack_bot/helper/slack_bot_link_formatter_helper.rb:35:in `format'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-plugin-slack_bot-1.0.0/lib/fastlane/plugin/slack_bot/actions/post_to_slack.rb:15:in `run'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/runner.rb:263:in `block (2 levels) in execute_action'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/actions/actions_helper.rb:69:in `execute_action'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/runner.rb:229:in `chdir'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/runner.rb:229:in `execute_action'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
        from Fastfile:94:in `block in parsing_binding'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/lane.rb:33:in `call'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/commands_generator.rb:109:in `block (2 levels) in run'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/commander-4.6.0/lib/commander/command.rb:187:in `call'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/commander-4.6.0/lib/commander/command.rb:157:in `run'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/commander-4.6.0/lib/commander/runner.rb:444:in `run_active_command'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in `run!'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/commander-4.6.0/lib/commander/delegates.rb:18:in `run!'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/commands_generator.rb:353:in `run'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/commands_generator.rb:42:in `start'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/fastlane/lib/fastlane/cli_tools_distributor.rb:122:in `take_off'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/gems/fastlane-2.188.0/bin/fastlane:23:in `<top (required)>'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/bin/fastlane:23:in `load'
        from /usr/local/Cellar/fastlane/2.188.0/libexec/bin/fastlane:23:in `<main>'

Awesome plugin btw, thanks for sharing!!!

@crazymanish
Copy link
Owner

Hi @ptfly

Can you share with me how you are calling the post_to_slack action, so I can debug...it should not raise exception, nothing breaking was release in v2.188.0 🤔

@ptfly
Copy link
Author

ptfly commented Jul 29, 2021

Nothing special, it was working before, may be some other dependency. Here is the implementation on my side:

    messageInstance = post_to_slack(
        channel: slackChannel,
        api_token: slackToken,
        username: slackUsername,
        icon_url: slackAvatar,
        pretext: "New App version is available for testing!",
        default_payloads: [:git_branch, :number_of_commits, :last_git_commit],
        payload: {
            "iOS:" => iosStoreLink,
            "Android:" => androidStoreLink,
            "Build Details:" => appPackage[:version] +" / "+ appPackage[:build],
        }
    )

@crazymanish
Copy link
Owner

Hi @ptfly

Just tested with one message will all the above params, It is working for me...
I am requesting you to try one test slack message i.e see below

post_to_slack(
        channel: slackChannel,
        api_token: slackToken,
        pretext: "This is a testing slack message", # testing slack message
        default_payloads: [:git_branch, :number_of_commits, :last_git_commit],
        payload: {
            "iOS:" => "iosStoreLink",
            "Android:" => "androidStoreLink",
            "Build Details:" => "appPackage[:version]" +" / "+ "appPackage[:build]",
        }
    )

@ptfly
Copy link
Author

ptfly commented Jul 29, 2021

The exact same error. I even tried with just this:

    post_to_slack(
        channel: slackChannel,
        api_token: slackToken,
        pretext: "This is a testing slack message",
    )

No difference at all :(

If I comment out this line:
options[:message] = Helper::SlackBotLinkFormatterHelper.format(options[:message]) from post_to_slack.rb action, I can send the message.

Also, I have to remove the payload object in order to succeed. Nomatter the content of the payload, when used, it fails.

Ruby version:ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin20]

@ptfly
Copy link
Author

ptfly commented Jul 29, 2021

Ok, here is the fix, replacing this:

        # def initialize string, formats: %i[html markdown]
        #   @formats = formats
        #   @orig    = string.respond_to?(:scrub) ? string.scrub : string
        # end

        # This one works at least on my setup
        def initialize string, opts = {}
          @formats = opts[:formats] || %i[html markdown]
          @orig    = string.respond_to?(:scrub) ? string.scrub : string
        end

Found the fix here: slack-notifier/slack-notifier#124 (comment)

@crazymanish
Copy link
Owner

Ok, here is the fix, replacing this:

        # def initialize string, formats: %i[html markdown]
        #   @formats = formats
        #   @orig    = string.respond_to?(:scrub) ? string.scrub : string
        # end

        # This one works at least on my setup
        def initialize string, opts = {}
          @formats = opts[:formats] || %i[html markdown]
          @orig    = string.respond_to?(:scrub) ? string.scrub : string
        end

Found the fix here: slack-notifier/slack-notifier#124 (comment)

Cool, but that is Ruby 3.0.0 issue 🤔 and you are using Ruby2.6.3
Anyways, I am applying this patch, will release soon 😊

Screenshot 2021-07-29 at 20 02 32

@ptfly
Copy link
Author

ptfly commented Jul 29, 2021

Yes, its 3.0 but have no idea why its working. Probably fastlane is using another ruby in a different context which I might have installed with something else. Have to check this thing out :)

@crazymanish
Copy link
Owner

Hi @ptfly

Push the fix and release the new version 1.1.0...
https://rubygems.org/gems/fastlane-plugin-slack_bot/versions/1.1.0

You may need to run bundle update fastlane-plugin-slack_bot to use the latest version.
can you please test once? After your confirmation, I will close this bug. Thanks for finding the issue 👏

@ptfly
Copy link
Author

ptfly commented Jul 29, 2021

Cant right now, not in front of a computer. Will test tmr and report back. Thanks for your cooperation!

@crazymanish crazymanish changed the title Latest fastlane 2.188 - wrong number of arguments (given 2, expected 1) Ruby 3.0 issue - wrong number of arguments (given 2, expected 1) Jul 29, 2021
@ptfly
Copy link
Author

ptfly commented Aug 2, 2021

Works, thanks for the update!

@crazymanish
Copy link
Owner

Thanks, Closing this issue with git-commit 54b0af0 & release version v1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants