Skip to content

Commit 95ce15b

Browse files
committed
Fix checking whether tar is available
When trying to execute `tar` to determine whether it is available catch an `OSError` raised when the path to the `tar` is invalid. Related to #127
1 parent e4fcbd0 commit 95ce15b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/nimblepkg/download.nim

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,12 @@ proc hasTar: bool =
175175
## Checks whether a `tar` external tool is available.
176176
var hasTar {.global.} = false
177177
once:
178-
# Try to execute `tar` to ensure that it is available.
179-
let (_, exitCode) = execCmdEx(getTarExePath() & " --version")
180-
hasTar = exitCode == QuitSuccess
178+
try:
179+
# Try to execute `tar` to ensure that it is available.
180+
let (_, exitCode) = execCmdEx(getTarExePath() & " --version")
181+
hasTar = exitCode == QuitSuccess
182+
except OSError:
183+
discard
181184
return hasTar
182185

183186
proc isGitHubRepo(url: string): bool =

0 commit comments

Comments
 (0)