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

Error running SwiftFormat: (RuntimeError) #53

Open
EgaSetya opened this issue Feb 1, 2024 · 4 comments
Open

Error running SwiftFormat: (RuntimeError) #53

EgaSetya opened this issue Feb 1, 2024 · 4 comments

Comments

@EgaSetya
Copy link

EgaSetya commented Feb 1, 2024

Hi @garriguv, I encountered a runtime error like the following when attempting to integrate danger-swiftformat on GitLab.

Error

bundler: failed to load command: danger (/builds/technology/ios/project/.bundle/ruby/2.7.0/bin/danger)
/builds/technology/ios/project/.bundle/ruby/2.7.0/gems/danger-swiftformat-0.9.0/lib/swiftformat/swiftformat.rb:31:in `check_format': \e[31m (Danger::DSLError)
[!] Invalid `Dangerfile` file: Error running SwiftFormat:
Error: \e[0m./swiftformat: line 1: syntax error: unexpected word (expecting ")")\e[0m
 #  from Dangerfile:6
 #  -------------------------------------------
 #  swiftformat.binary_path = "./swiftformat"
 >  swiftformat.check_format
 #  -------------------------------------------
	from /builds/technology/ios/project/.bundle/ruby/2.7.0/gems/danger-swiftformat-0.9.0/lib/swiftformat/plugin.rb:59:in `check_format'
	from Dangerfile:6:in `eval_file'
Screenshot 2024-02-02 at 15 12 09

Dangerfile

require "gitlab-dangerfiles"

Gitlab::Dangerfiles.for_project(self, &:import_defaults)

swiftformat.binary_path = "./swiftformat"
swiftformat.check_format

.swiftformat

# file options

--exclude Tests/XCTestManifests.swift,Tests/BadConfig,Snapshots,Build,PluginTests,Pods

# format options

--guardelse same-line
--lineaftermarks false
--emptybraces spaced
--patternlet inline
--marktypes never
--markextensions never
--redundanttype inferred
--trailingclosures filter,map,compactMap
--commas inline
--stripunusedargs closure-only
--wraparguments before-first
--wrapparameters before-first
--wrapreturntype if-multiline
--wrapconditions after-first
--trimwhitespace nonblank-lines


# rules

--enable spaceAroundBraces
--enable wrapConditionalBodies
--enable redundantOptionalBinding
--disable initCoderUnavailable

What can I do to fix this issue? Is there anything that I missed?

@garriguv
Copy link
Owner

garriguv commented Feb 2, 2024

Hmm, It's hard to say. It

I see that you're running ruby 2.7.0, any change you could upgrade to 3.4.0 or later?

@EgaSetya
Copy link
Author

EgaSetya commented Feb 4, 2024

Hmm, It's hard to say. It

I see that you're running ruby 2.7.0, any change you could upgrade to 3.4.0 or later?

Let me try it first.
I'll get back to you later with the result.

@jsorge
Copy link

jsorge commented Feb 20, 2024

I'm seeing this as well running Ruby 3.2.3 from the Danger action in GitHub Actions.

bundler: failed to load command: danger (/home/runner/work/ensemble-swift/ensemble-swift/vendor/bundle/ruby/3.2.0/bin/danger)
/home/runner/work/ensemble-swift/ensemble-swift/vendor/bundle/ruby/3.2.0/gems/danger-swiftformat-0.8.1/lib/swiftformat/swiftformat.rb:31:in `check_format':  (Danger::DSLError)
[!] Invalid `Dangerfile` file: Error running SwiftFormat:
Error: /home/runner/.local/share/mise/installs/swiftformat/0.52.11/bin/swiftformat: 1: Syntax error: "(" unexpected
 #  from Dangerfile:9
 #  -------------------------------------------
 #  swiftformat.additional_message = 'run `make format` on your branch to fix the SwiftFormat failures.'
 >  swiftformat.check_format(fail_on_error: true)
 #  
 #  -------------------------------------------

@jsorge
Copy link

jsorge commented Feb 24, 2024

As another data point, this action works when running on a Mac, but not on Linux (using ubuntu-latest).

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