Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stgit doesn't find a locally-installed version of git #56

Closed
chucklever opened this issue Apr 20, 2020 · 3 comments
Closed

stgit doesn't find a locally-installed version of git #56

chucklever opened this issue Apr 20, 2020 · 3 comments

Comments

@chucklever
Copy link
Contributor

I pulled the latest version of stgit this morning and tried to install it:

[cel@klimt stgit]$ sudo python setup.py install
Traceback (most recent call last):
  File "setup.py", line 66, in <module>
    __check_git_version()
  File "setup.py", line 54, in __check_git_version
    gitver = Run('git', '--version').output_one_line().split()[2]
  File "/home/cel/src/stgit/stgit/run.py", line 262, in output_one_line
    outlines = self.output_lines(sep)
  File "/home/cel/src/stgit/stgit/run.py", line 253, in output_lines
    outdata = self._run_io()
  File "/home/cel/src/stgit/stgit/run.py", line 151, in _run_io
    raise self.exc('%s failed: %s' % (self._cmd[0], e))
stgit.run.RunException: git failed: [Errno 2] No such file or directory
[cel@klimt stgit]$ echo $PATH
/home/cel/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
[cel@klimt stgit]$ which git
/usr/local/bin/git
[cel@klimt stgit]$ git --version
git version 2.25.2
[cel@klimt stgit]$
@jpgrayson
Copy link
Collaborator

I was unable to reproduce this problem.

You are running with sudo. Is /usr/local/bin in the path when running with sudo?

Also, which version of Python are you running? I verified with several versions.

Could you add a line to __check_git_version() to print-out PATH as setup.py sees it? I.e.:

def __check_git_version():
    ...
    print('PATH:', os.environ['PATH'])
    ...

If all that doesn't reveal the root cause, could you bisect to figure out which commit introduced the problem?

@chucklever
Copy link
Contributor Author

[cel@klimt stgit]$ sudo python setup.py install
PATH: /sbin:/bin:/usr/sbin:/usr/bin
Traceback (most recent call last):
  File "setup.py", line 67, in <module>
    __check_git_version()
  File "setup.py", line 55, in __check_git_version
    gitver = Run('git', '--version').output_one_line().split()[2]
  File "/home/cel/src/stgit/stgit/run.py", line 262, in output_one_line
    outlines = self.output_lines(sep)
  File "/home/cel/src/stgit/stgit/run.py", line 253, in output_lines
    outdata = self._run_io()
  File "/home/cel/src/stgit/stgit/run.py", line 151, in _run_io
    raise self.exc('%s failed: %s' % (self._cmd[0], e))
stgit.run.RunException: git failed: [Errno 2] No such file or directory
[cel@klimt stgit]$ sudo echo $PATH
/home/cel/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
[cel@klimt stgit]$ sudo su
[root@klimt stgit]# echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin
[root@klimt stgit]#

It appears that /usr/local/bin is not in root's path.

@jpgrayson
Copy link
Collaborator

Note that sudo echo $PATH is not telling you the effective PATH used by sudo since $PATH is expanded using your regular user's environment before sudo is run.

Instead, use sudo env | grep PATH or sudo $SHELL -c 'echo $PATH' (with single-quotes so that $PATH is not expanded early).

One possible solution: try sudo -E which preserves your user environment in the sudo environment. Although the sudo man page indicates that PATH is already transferred, unchanged, into the sudo environment. You can test whether sudo -E env | grep PATH produces a different path than without -E.

Since this problem appears to be outside StGit's control, I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants