Skip to content

Commit

Permalink
better error message when dbt executable can't be found (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonvermeulen authored Oct 4, 2024
1 parent 85dbded commit 4ba476b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ through `{{ ref() }}` and `{{ source() }}` tags.

## Prerequisites
* 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.
<br>![Set-up venv](./assets/img/settings.jpg)
* 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>
`File` > `Project Structure` > `SDK` > `Select Python` > `Select New Virtual Environment`. If not it is required to have dbt-core globally installed.
* Supported/Tested dbt versions are: >=1.7.0
Expand Down
Binary file added assets/img/settings.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import java.io.File
import java.io.IOException

@Service(Service.Level.PROJECT)
class ProcessExecutorService(project: Project) {
Expand All @@ -20,7 +21,20 @@ class ProcessExecutorService(project: Project) {
fun executeCommand(command: List<String>): Process {
val processBuilder = getDbtProcessBuilder(command)
loggingService.log(">>> ${processBuilder.command().joinToString(" ")}\n", ConsoleViewContentType.NORMAL_OUTPUT)
processBuilder.directory(settings.state.settingsDbtProjectDir.let { File(it) })
try {
processBuilder.directory(settings.state.settingsDbtProjectDir.let { File(it) })
return processBuilder.start()
} catch (e: IOException) {
if (e.message?.contains("Cannot run program") == true) {
loggingService.log(
"An error occurred, could not find dbt executable. Please install dbt globally or configure a virtual environment.\n",
ConsoleViewContentType.LOG_ERROR_OUTPUT,
)
loggingService.log(e.message!!, ConsoleViewContentType.LOG_ERROR_OUTPUT)
} else {
throw e
}
}
return processBuilder.start()
}

Expand Down

0 comments on commit 4ba476b

Please sign in to comment.