Skip to content

deck version fails if no git it is available #105

@georgkrause

Description

@georgkrause

What happened?

I am running deck version on a system without git available:

One thing we might want to do is checking for a git executable as well, since deck version will fail if its not available:

Traceback (most recent call last):
  File "git", line 87, in <module>
  File "git", line 76, in refresh
  File "git.cmd", line 341, in refresh
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "getdeck.__main__", line 114, in main
  File "getdeck.api", line 2, in <module>
  File "getdeck.api.get", line 7, in <module>
  File "getdeck.api.hosts", line 10, in <module>
  File "getdeck.utils", line 10, in <module>
  File "getdeck.deckfile.fetch.deck_fetcher", line 11, in <module>
  File "git", line 89, in <module>
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
    - be included in your $PATH
    - be set via $GIT_PYTHON_GIT_EXECUTABLE
    - explicitly set via git.refresh()

All git commands will error until this is rectified.

This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
    - quiet|q|silence|s|none|n|0: for no warning or exception
    - warn|w|warning|1: for a printed warning
    - error|e|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet

What did you expect to happen?

Since git is only required for a subset of commands, it might be useful to be able to run deck version even if no git is installed and fail as late as possible, eg when I try to execute a command which actually needs git.

How can we reproduce it (as minimally and precisely as possible)?

docker run -it debian bash
apt update
apt install curl sudo unzip
curl -sSL https://raw.githubusercontent.com/getdeck/getdeck/main/install.sh | sh -
deck version

What is the content of the Deckfile you are using?

Doesn't matter

OS version

Details
# On Linux:
$ cat /etc/os-release
# paste output here
$ uname -a
# paste output here

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Anything else we need to know?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions