Opened 5 years ago

Closed 5 years ago

#627 closed defect (fixed)

Git commit hash not found on linux

Reported by: lewis Owned by:
Priority: minor Milestone: SasView 4.0.0
Component: SasView Keywords:
Cc: Work Package: SasView Bug Fixing


Running SasView on linux gives the error:

WARNING:root:Error while determining build number
  Command '['git', 'rev-parse', 'HEAD']' returned non-zero exit status 1

Then when SasView opens, clicking Help→About shows "Build: GIT_COMMIT" instead of the actual commit hash.

I believe this is because on linux, commands executed via subprocess.check_output() aren't ran from the cwd.

Adding something like:

command = 'git rev-parse HEAD'
if sys.platform.count('linux') > 0:
    command = 'cd ' + os.getcwd() + '; ' + command
git_revision = subprocess.check_output(command,

to sasview/ seems to do the job, but seems a bit hacky?

Change History (10)

comment:1 Changed 5 years ago by butler

The git hash is made to ensure that the commit hash for the build being distributed gets placed in the correct variable but should not prevent from running on a system without git. For Linux of course one is building in place I suspect? or is it from the ubuntu egg?

Either way — the point is that the first error is now generated on windows machines as well even when running the windows distributable built on DMSC machines. However it is mostly invisible as it only shows up in the log file (not even in the console). The About box has the last hash put there which is the one put there when built on DMSC machines and so correct.

HOWEVER — loading SasView now seems really slow compared to what it used to be. Suspect these are related?

comment:2 Changed 5 years ago by lewis

I was building in place (running "python" from the sasview repo)

SasView still runs fine, the error message just appears in the terminal

comment:3 Changed 5 years ago by wojciech

The problem also appears on osx and when running from the side effect is that it doesn't log to sasview.log.

The potential fix to the problem may involve pass in expect statement of sasview/ instead of:
import logging
import sys
logging.warning("Error while determining build number\n %s" % sys.exc_value)

comment:4 Changed 5 years ago by ajj

  • Resolution set to fixed
  • Status changed from new to closed

Problem was that the call to subprocess was incorrectly assembled.

Fixed in a3f1c11

comment:5 Changed 5 years ago by krzywon

  • Resolution fixed deleted
  • Status changed from closed to reopened

Windows is now throwing this error:

WARNING:root:Error while determining build number
  Using command:
 ['git describe --tags'] 

comment:6 Changed 5 years ago by krzywon

Changing line 8 of sasview.init fixes the issue on Windows. Subprocess wants each argument as a separate list item. Could someone check this on linux?

git_revision = subprocess.check_output(['git', 'describe', '--tags'],

comment:7 Changed 5 years ago by ajj

That will now break on linux and mac - on those platforms putting the arguments as a list made it fail.

comment:8 Changed 5 years ago by ajj

In commit 654e8e0 line 8 now reads:

git_revision = subprocess.check_output(['git describe', '--tags'],

which works on mac and linux AFAICS. Will close ticket once confirmed that this works on windows.

(Has a single line of code ever been so commented on? )

comment:9 Changed 5 years ago by krzywon

That didn't work so I changed it to be platform dependent. Confirm on Linux and Mac, please.

if platform.system() == "Windows":
    args = ['git', 'describe', '--tags']
    args = ['git describe --tags']
git_revision = subprocess.check_output(args,

comment:10 Changed 5 years ago by ajj

  • Resolution set to fixed
  • Status changed from reopened to closed

Fixed by jkrzywon as above.

For future reference: contains at least the statement that how the arguments to subprocess are marshalled and executed depends on the OS. Next time I'll RTFM properly.

Note: See TracTickets for help on using tickets.