kylef / swiftenv

Swift Version Manager
https://swiftenv.fuller.li/
BSD 2-Clause "Simplified" License
1.98k stars 94 forks source link

no such command: swift-format #176

Open MPLew-is opened 4 years ago

MPLew-is commented 4 years ago

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?

kylef commented 4 years ago

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.

MPLew-is commented 4 years ago

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.

kylef commented 4 years ago

Does this work by any chance?

$ swiftenv rehash
$ env SWIFT_VERSION=system swift format
MPLew-is commented 4 years ago

Unfortunately not:

$ swiftenv rehash && env SWIFT_VERSION=system swift format; echo $PATH
no such command: swift-format
/Users/mplewis/.swiftenv/shims:/usr/local/bin:...