What I am trying to do: I am trying to install ktlint on windows locally
What I tried:
Used below command in command prompt
curl -sSLO https://github.com/pinterest/ktlint/releases/download/0.38.1/ktlint && chmod a+x ktlint
Also tried above command by using in below steps in link
https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/
What is happening: Not able to install in windows.
I was having trouble installing ktlint for Windows 10. What worked for me was going to the Releases page, downloading the
ktlint
file, renaming thektlint
file toktlint.jar
and adding it inside my Android project root folder (in reference to this GitHub issue) (Note: Java must be installed so that the file extension can be recognized), then runningjava -jar ktlint.jar --apply-to-idea-project
(in the command line, from the Android project root directory). Then finally I was able to get it to work, resulting in the following text:Without updating the file to have the
.jar
extension and adding.jar
to the filename command line parameter, I kept getting the following error:Error: Unable to access jarfile ktlint
To run ktlint immediately, run
java -jar ktlint.jar
in the command line (in the directory where the ktlint.jar file resides).You can install a git hook to automatically check files for style violations on commit by entering the following command in the Command Line (run "ktlint installGitPrePushHook" if you wish to run ktlint on push instead):
java -jar ktlint.jar installGitPreCommitHook
But this will only allow you to set hook for your current command line session. If you close out of Command Prompt, the settings will be reset. If you want to have the ktlinter run on every session for your project, you have to add the
java -jar ktlint.jar
command to your project's.git/hook/pre-commit
file and paste the ktlint.jar file into the.git/hook
folder as well.