Search code examples
kotlinintellij-ideazsh

How do I fix permission to allow IntelliJ IDEA to run a Kotlin script?


I am trying to run the below Kotlin script from IntelliJ IDEA 2020.3.1 on Mac OS 10.15.7. The script runs fine from terminal, but when I hit the 'run' button inside of IntelliJ, I get the following error:

zsh: permission denied: /Users/*****/scripts/first.main.kts

What would be the right way to fix this permission issue?

#!/usr/bin/env kotlin

@file:Repository("https://jcenter.bintray.com")
@file:DependsOn("org.http4k:http4k-bom:4.1.1.2")
@file:DependsOn("org.http4k:http4k-core:4.1.1.2")
@file:DependsOn("org.http4k:http4k-client-apache:4.1.1.2")
@file:DependsOn("org.http4k:http4k-server-netty:4.1.1.2")


import org.http4k.client.ApacheClient
import org.http4k.core.Method
import org.http4k.core.Request


val client = ApacheClient()

val request = Request(Method.GET, "https://api.kanye.rest/").query("format", "text")

println(client(request))

Solution

  • You must make the file executable: chmod +x first.main.kts