swiftenv
swiftenv copied to clipboard
no such command: swift-format
I'm not sure if this is just a user error or not, but I get the following error attempting to use swift-format
alongside swiftenv
:
$ swift format
no such command: swift-format
$ which -a swift-format
/Users/mplewis/.swiftenv/shims/swift-format
/usr/local/bin/swift-format
As potentially indicated above, this is using the homebrew-installed version of swift-format
. Is this a bug, or simply something I've configured or set up wrong?
I think you need to invoke it as swift-format
not swift format
. All the examples in https://github.com/apple/swift-format use swift-format
.
They do, but it is very possible to call using just swift format
without swiftenv
:
$ swift format --help
OVERVIEW: Format or lint Swift source code
USAGE: swift-format [--version] <subcommand>
OPTIONS:
-v, --version Print the version and exit
-h, --help Show help information.
SUBCOMMANDS:
dump-configuration Dump the default configuration in JSON format to standard output
format Format Swift source code
lint Diagnose style issues in Swift source code
It would be nice for both of these to be able to coexist out of the box, but I did manage to find a workaround for now: making sure /usr/local/bin
is ahead of the swiftenv
shims directory in my PATH
.
Does this work by any chance?
$ swiftenv rehash
$ env SWIFT_VERSION=system swift format
Unfortunately not:
$ swiftenv rehash && env SWIFT_VERSION=system swift format; echo $PATH
no such command: swift-format
/Users/mplewis/.swiftenv/shims:/usr/local/bin:...