nicklockwood / SwiftFormat

A command-line tool and Xcode Extension for formatting Swift code
MIT License
7.63k stars 623 forks source link

warning: Failed to write cache file at ..swiftformat.cache. #1651

Closed JulesMoorhouse closed 3 months ago

JulesMoorhouse commented 3 months ago

Hey,

I'm getting this error.

Running SwiftFormat...
(lint mode - no files will be changed.)
warning: Failed to write cache file at /Users/Jules/Library/Caches/com.charcoaldesign.swiftformat/swiftformat.cache.
SwiftFormat completed in 0.13s.
0/138 files require formatting, 1 file skipped.
/bin/bash: line 1: --cache: command not found

I've tried changing the --cache command, I've tried different path, also clear and ignore. Also I've removed the --cache command. But the error doesn't change...

I've tried v 0.53.2 and 0.53.5 (just now) But I'm still getting the same error..

swiftformat
--lint
--config myfolder/.swiftformat
--swiftversion 5.9
--cache myfolder

Any ideas ?

Thanks in advance,

Jules.

nicklockwood commented 3 months ago

Placing --cache in the .swiftformat file is not supported I think - it has to be specified via command line

nicklockwood commented 3 months ago

As for why it's failing in the first place, that's a bit of a mystery. Does the /Users/Jules/Library/Caches/com.charcoaldesign.swiftformat/ folder exist? Does it have correct permissions? What happens if you delete it?

JulesMoorhouse commented 3 months ago

No those commands aren't in the .swiftformat file, I've formatting it above.

Yes it exits... perms seem fine.

If you delete the folder, no it doesn't get re-created.

The error doesn't make sense, it looks like a catch all.

nicklockwood commented 3 months ago

The --cache: command not found error doesn't look like it's coming from SwiftFormat at all, it's a bash error. Is it possible you've got a linebreak in your command before the --cache argument?

JulesMoorhouse commented 3 months ago

Thanks, I'm actually building up a script and there was a line character after the swift version number. Which I read in from the .swift-version file.