Skip to content

Commit

Permalink
Fix checking whether tar is available
Browse files Browse the repository at this point in the history
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 nim-lang#127
  • Loading branch information
bobeff authored and CyberTailor committed Dec 12, 2021
1 parent 6c63691 commit b9b3abe
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/nimblepkg/download.nim
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,12 @@ proc hasTar: bool =
## Checks whether a `tar` external tool is available.
var hasTar {.global.} = false
once:
# Try to execute `tar` to ensure that it is available.
let (_, exitCode) = execCmdEx(getTarExePath() & " --version")
hasTar = exitCode == QuitSuccess
try:
# Try to execute `tar` to ensure that it is available.
let (_, exitCode) = execCmdEx(getTarExePath() & " --version")
hasTar = exitCode == QuitSuccess
except OSError:
discard
return hasTar

proc isGitHubRepo(url: string): bool =
Expand Down

0 comments on commit b9b3abe

Please sign in to comment.