How to install ktlint properly

1.3k views Asked by At

I am trying to install to ktlint. I did it with the following line of code on present on their website

curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.39.0/ktlint && chmod a+x ktlint && sudo mv ktlint /usr/local/bin/

but when i tried ktlint --version i got an error saying usr/local/bin/ktlint: 3: exec: java: not found Can someone please help me fix this Thank you :)

1

There are 1 answers

0
turbidwater On

I ran into this issue as well. My solution was to add the jdk bin to my system path. I also had to use Git Bash as my CLI

  1. Close any CLI windows
  2. Edit your Path system variable and add a new entry for a path pointing to the jdk bin in your Android Studio install. For me this was C:\Program Files\Android\Android Studio\jre\bin. This dir has the java.exe in it on Windows
  3. Save your path variable and reopen your CLI
  4. Try java --version. You should get the version of your java install
  5. Retry ktlint --version. You should get the version of your ktlint install (Note: this assumes you already added ktlint to your system path as well, or are in the ktlint install dir)