Skip to content

Commit 4ba476b

Browse files
better error message when dbt executable can't be found (#169)
1 parent 85dbded commit 4ba476b

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ through `{{ ref() }}` and `{{ source() }}` tags.
3939

4040
## Prerequisites
4141
* For IntelliJ users, it is required to have the [**Python**](https://plugins.jetbrains.com/plugin/631-python) plugin installed so that you can configure a venv.
42+
<br>![Set-up venv](./assets/img/settings.jpg)
4243
* I also recommended to have a venv configured and [**dbt-core**](https://pypi.org/project/dbt-core/) with your required adapter installed within the venv: <br>
4344
`File` > `Project Structure` > `SDK` > `Select Python` > `Select New Virtual Environment`. If not it is required to have dbt-core globally installed.
4445
* Supported/Tested dbt versions are: >=1.7.0

assets/img/settings.jpg

22.8 KB
Loading

src/main/kotlin/com/github/ramonvermeulen/dbtToolkit/services/ProcessExecutorService.kt

+15-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.intellij.openapi.components.Service
55
import com.intellij.openapi.components.service
66
import com.intellij.openapi.project.Project
77
import java.io.File
8+
import java.io.IOException
89

910
@Service(Service.Level.PROJECT)
1011
class ProcessExecutorService(project: Project) {
@@ -20,7 +21,20 @@ class ProcessExecutorService(project: Project) {
2021
fun executeCommand(command: List<String>): Process {
2122
val processBuilder = getDbtProcessBuilder(command)
2223
loggingService.log(">>> ${processBuilder.command().joinToString(" ")}\n", ConsoleViewContentType.NORMAL_OUTPUT)
23-
processBuilder.directory(settings.state.settingsDbtProjectDir.let { File(it) })
24+
try {
25+
processBuilder.directory(settings.state.settingsDbtProjectDir.let { File(it) })
26+
return processBuilder.start()
27+
} catch (e: IOException) {
28+
if (e.message?.contains("Cannot run program") == true) {
29+
loggingService.log(
30+
"An error occurred, could not find dbt executable. Please install dbt globally or configure a virtual environment.\n",
31+
ConsoleViewContentType.LOG_ERROR_OUTPUT,
32+
)
33+
loggingService.log(e.message!!, ConsoleViewContentType.LOG_ERROR_OUTPUT)
34+
} else {
35+
throw e
36+
}
37+
}
2438
return processBuilder.start()
2539
}
2640

0 commit comments

Comments
 (0)