17

I am trying to fix this error:

Error: swiftlint does not have a version "0.11.1" in the Cellar.

by running this:

brew install swiftlint-0.11.1

however this doesn't work, then I tried "brew search swiftlint", but nothing showed up.

Can anyone point to me the correct way to install swiftlint with a specific version?

bfontaine
  • 18,169
  • 13
  • 73
  • 107
RainCast
  • 4,134
  • 7
  • 33
  • 47
  • 1
    Unless you need the specific version from any reason other than the error, try `brew rm swiftlint && brew install swiftlint`. – equal-l2 Jan 26 '17 at 03:40
  • 1
    I need the version... see my question title – RainCast Jan 26 '17 at 05:15
  • 4
    In general, with the new Homebrew, one would install a specific version by doing brew install swiftlint@version, so would be brew install swiftlint@0.11.1. The problem I see is that there's only one version defined in that Formula so I don't think can deal with it. An alternative would be to use the Homebrew versions tap, but that one is deprecated and I didn't see swiftlint formula in there (https://github.com/Homebrew/homebrew-versions/pull/1512). In this case probably one will have to code it unless someone else prepared. It's not much effort, but still. – fedepad Jan 26 '17 at 06:52
  • 1
    @fedepad is right; you can’t install an arbitrary version if nobody wrote the formula for it. – bfontaine Jan 27 '17 at 13:14
  • Got it, thanks @fedepad and bfontaine. – RainCast Jan 29 '17 at 04:05

6 Answers6

11

Go to /usr/local/Cellar/swiftlint you will see all installed switflint version.
Copy swiftlint version folder from other Mac then paste into /usr/local/Cellar/swiftlint

You could check all versions in your Mac by brew info swiftlint

Switch to version you need by brew switch swiftlint x.xx.x

I uploaded some version ==> here

Update: Now you could use pods for this.

My project is using swift2.2 with SwiftLint 0.12.0 installed via brew.

And I decided to change to Pod. There are many changes and errors in each versions. My project is too big, and it's take time to fix all the error and warning (it may effect to current features also...).

Finally I choose pod 'SwiftLint', '0.16.0' and. disable_rules then I don't need to fix any warning nor error.

  • type_name
  • shorthand_operator
  • unused_closure_parameter
eric long
  • 640
  • 5
  • 16
  • This worked for me thanks, i had to copy 0.18.1 foler into that directory and it worked. Thanks. – Rifinio Jul 21 '17 at 09:29
8

This involves a lot of steps, but anyway:

Find the Brew Formula for Swiftlint. It's here.

Now you'll need an older commit of Swift Lint, so you would normally click on the History tab and get to an older commit. However, GitHub might tell you that you need to clone the repo (git@github.com:Homebrew/homebrew-core.git) and then use git log master -- Formula/swiftlint.rb to find your older commit. I'll spare you the details of that.

Now you need a raw URL for an older commit. So the raw URL for the latest commit is https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/swiftlint.rb, but you would use https://github.com/Homebrew/homebrew-core/blob/COMMIT/Formula/swiftlint.rb

Now you can do a brew install directly using this older Swift Lint. In my case, I needed 0.15, so I used:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/864095ea97b6d7dc88c772c7f9f36521cf81a77e/Formula/swiftlint.rb
Dan Rosenstark
  • 68,471
  • 58
  • 283
  • 421
  • 4
    Maaaan! I think I spent like 30 mins before learning how to install a specific version of a Formula... why is it so difficult??? – Islam Aug 23 '18 at 14:35
  • This no longer works, I get the following message: Invalid usage: Installation of swiftlint from a GitHub commit URL is unsupported! `brew extract swiftlint` to a stable tap on GitHub instead. (UsageError) – martinmose Oct 05 '21 at 14:28
  • @martinmose what other steps I have to do after brew extract. Can you help. I need to install swiftlint 0.47.0 on M1 pro mac – sachuverma Nov 03 '22 at 11:22
  • 1
    @sachuverma see the following post: https://stackoverflow.com/questions/62785290/installing-previous-versions-of-a-formula-with-brew-extract I'm pretty sure that's the one I looked at back then – martinmose Nov 07 '22 at 12:55
4

The following worked for me to downgrade from the latest version of swiftlint (0.50.3 at time of posting) to 0.50.1:

  1. brew unlink swiftlint

  2. brew extract --version=0.50.1 swiftlint homebrew/cask

  3. brew install swiftlint@0.50.1

To switch between your installed versions, simply unlink from one version and link the other. We can switch back to the most recent installed version below:

  1. brew unlink swiftlint@0.50.1
  2. brew link swiftlint

Verify the correct swiftlint version by running swiftlint version.

mattol
  • 41
  • 3
2

Just go to Swiftlint release page and select the appropriate version.

Download it and extract it.

You should be able to see an executable and a licence txt file.

Now go to /usr/local/Cellar/swiftlint and create a folder with the version (for ex. 0.35.0).

Create a bin folder inside it and paste the swiftlint executable that you have downloaded.

Brew now shows the custom version that you have downloaded . You can check by typing brew info swiftlint in cmd you can switch by brew switch swiftlint version_number

Haseeb Mohamed
  • 1,459
  • 1
  • 11
  • 15
2

With mint, which I personally prefer, you can do:

mint install realm/SwiftLint@0.46.2
tomasyany
  • 1,132
  • 3
  • 15
  • 32
-1

Go to the SwiftLint's releases section and find the version you're looking for. Then download its installer (.pkg, .zip, etc), and run it.

Alchi
  • 799
  • 9
  • 19
  • this is only part of the process if you have older version it is not working == Error: No formulae found in taps. – Marina Nov 10 '22 at 09:25