{"thread":{"id":"62908","subject":"`git p4` broken on machines which do not have python on path","startedAt":"2025-02-06T01:28:00Z","lastAt":"2025-02-06T23:17:16Z","messageCount":5,"participants":["Kapil Somani","brian m. carlson","Illia Bobyr","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"511917","messageId":"CANF_+=4dG7bVF5n+s4ezHR=HneeMgvYNhsOjsz7e7bFapG2f2w@mail.gmail.com","threadId":"62908","inReplyTo":null,"subject":"`git p4` broken on machines which do not have python on path","fromName":"Kapil Somani","fromEmail":"kmsomani@alumni.ncsu.edu","sentAt":"2025-02-06T01:27:48Z","receivedAt":"2025-02-06T01:28:00Z","isPatch":false,"sender":{"key":"kmsomani@alumni.ncsu.edu","avatar":null},"body":"Thank you for filling out a Git bug report!\nPlease answer the following questions to help us understand your issue.\n\nWhat did you do before the bug happened? (Steps to reproduce your issue)\nRun `git p4 clone //path/to/p4/depot --destination=/tmp/localcopy`\n\n\nWhat did you expect to happen? (Expected behavior)\nThe command should have imported perforce depot to a git repository\n\n\nWhat happened instead? (Actual behavior)\nThe command threw error\nfatal: 'p4' appears to be a git command, but we were not\nable to execute it. Maybe git-p4 is broken?\n\n\nWhat's different between what you expected and what actually happened?\nThe command did not perform desired operation\n\n\nAnything else you want to add:\nThe machine does not have python on path\nI noticed `git-p4`'s shebang line points to python.\nOn my local git installation, i was able to update shebang line on\ngit-p4 to python3 and\nthe command worked as expected.\nWith python3 now being default should be update git-p4 to run using python3 ?\n\n\nPlease review the rest of the bug report below.\nYou can delete any lines you don't wish to share.\n\n\n[System Info]\ngit version:\ngit version 2.30.2\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nuname: Linux 5.10.0-33-amd64 #1 SMP Debian 5.10.226-1 (2024-10-03) x86_64\ncompiler info: gnuc: 10.2\nlibc info: glibc: 2.31\n$SHELL (typically, interactive shell): /bin/tcsh\n\n\n[Enabled Hooks]\nnot run from a git repository - no hooks to show\n"},{"id":"511920","messageId":"Z6QUeaoH_tV2ncwn@tapette.crustytoothpaste.net","threadId":"62908","inReplyTo":"CANF_+=4dG7bVF5n+s4ezHR=HneeMgvYNhsOjsz7e7bFapG2f2w@mail.gmail.com","subject":"Re: `git p4` broken on machines which do not have python on path","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-02-06T01:46:33Z","receivedAt":"2025-02-06T01:46:37Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-02-06 at 01:27:48, Kapil Somani wrote:\n> Thank you for filling out a Git bug report!\n> Please answer the following questions to help us understand your issue.\n> \n> What did you do before the bug happened? (Steps to reproduce your issue)\n> Run `git p4 clone //path/to/p4/depot --destination=/tmp/localcopy`\n> \n> \n> What did you expect to happen? (Expected behavior)\n> The command should have imported perforce depot to a git repository\n> \n> \n> What happened instead? (Actual behavior)\n> The command threw error\n> fatal: 'p4' appears to be a git command, but we were not\n> able to execute it. Maybe git-p4 is broken?\n\nCan you mention where you got your version of Git from?  Is this a\nDebian Git, one you compiled yourself, or another one entirely?\n\n> What's different between what you expected and what actually happened?\n> The command did not perform desired operation\n> \n> \n> Anything else you want to add:\n> The machine does not have python on path\n> I noticed `git-p4`'s shebang line points to python.\n> On my local git installation, i was able to update shebang line on\n> git-p4 to python3 and\n> the command worked as expected.\n> With python3 now being default should be update git-p4 to run using python3 ?\n\nI think if you compiled this yourself, you probably need to set\nPYTHON_PATH to a suitable Python when running the Makefile, and that\nwill rewrite the shebang.  If you got this from another source, then\nthey should have compiled the package with a suitable PYTHON_PATH and\ndepended on an appropriate version of Python.\n\nI realize that Python 3 is now the default, but there were apparently\nstill some people who want to use Python 2.7 last time this came up, so\nthe default shebang hasn't changed. According to Python upstream,\n`python` can be of any version, although for all distros I'm aware of,\n`python` is always version 2.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"},{"id":"511921","messageId":"101b03c5-dfad-41f0-8156-e541b8e6c68f@gmail.com","threadId":"62908","inReplyTo":"Z6QUeaoH_tV2ncwn@tapette.crustytoothpaste.net","subject":"Re: `git p4` broken on machines which do not have python on path","fromName":"Illia Bobyr","fromEmail":"illia.bobyr@gmail.com","sentAt":"2025-02-06T02:16:00Z","receivedAt":"2025-02-06T02:16:02Z","isPatch":false,"sender":{"key":"illia.bobyr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/694419?v=4"},"body":"On 2/5/25 17:46, brian m. carlson wrote:\n> I realize that Python 3 is now the default, but there were apparently\n> still some people who want to use Python 2.7 last time this came up, so\n> the default shebang hasn't changed. According to Python upstream,\n> `python` can be of any version, although for all distros I'm aware of,\n> `python` is always version 2.\n\nI just checked my Ubuntu 24.10 and `python` is `python3`.\n\n❯ python --version\nPython 3.12.7\n\n❯ lsb_release -a\nNo LSB modules are available.\nDistributor ID: Ubuntu\nDescription:    Ubuntu 24.10\nRelease:        24.10\nCodename:       oracular\n\n❯ whereis python\npython: /usr/bin/python\n\n❯ dpkg -S /usr/bin/python\npython-is-python3: /usr/bin/python\n\nThere are both `python-is-python2` and `python-is-python3` packages.\nThey just provide a symlink for convenience.\nAnd one can use Python version managers to manage what `python` means, \nof cause.\n\n"},{"id":"512018","messageId":"Z6U1GoGVA7IiPg3A@tapette.crustytoothpaste.net","threadId":"62908","inReplyTo":"CANF_+=7hM7QqLNE3d4=UO-8erYoeQwYG5SrsDTXtgqZq3AKJwg@mail.gmail.com","subject":"Re: `git p4` broken on machines which do not have python on path","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2025-02-06T22:18:02Z","receivedAt":"2025-02-06T22:18:05Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2025-02-06 at 02:12:02, Kapil Somani wrote:\n> Thanks for quick response Brian\n> \n> Yes, our team compiles git for use within our organization.\n> I'll reach out to them and see if they can provide path during build.\n> \n> Meanwhile, I was able to update copy of the git (compiled by my team) to\n> use python3 on shebang line.\n> It appears that the git-p4 is compatible with Python3. Is git team planning\n> to update it near future?\n\nIt's my understanding that it's designed to work with both Python 2 and\n3.  It's unlikely that the shebang will be updated until it's no longer\nguaranteed to work with Python 2, since `python` is more generic than\n`python3`.  When that is, I don't know, since I don't use Perforce and\ndon't maintain git-p4, which has a separate maintainer.\n-- \nbrian m. carlson (they/them or he/him)\nToronto, Ontario, CA\n"},{"id":"512020","messageId":"xmqqmseyhddy.fsf@gitster.g","threadId":"62908","inReplyTo":"Z6U1GoGVA7IiPg3A@tapette.crustytoothpaste.net","subject":"Re: `git p4` broken on machines which do not have python on path","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-02-06T23:17:13Z","receivedAt":"2025-02-06T23:17:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> On 2025-02-06 at 02:12:02, Kapil Somani wrote:\n>> Thanks for quick response Brian\n>> \n>> Yes, our team compiles git for use within our organization.\n>> I'll reach out to them and see if they can provide path during build.\n>> \n>> Meanwhile, I was able to update copy of the git (compiled by my team) to\n>> use python3 on shebang line.\n>> It appears that the git-p4 is compatible with Python3. Is git team planning\n>> to update it near future?\n>\n> It's my understanding that it's designed to work with both Python 2 and\n> 3.  It's unlikely that the shebang will be updated until it's no longer\n\nCorrect.  The CI has jobs to try git-p4 with both python2 and python3\nsince Mar 2020.\n\n> guaranteed to work with Python 2, since `python` is more generic than\n> `python3`.  When that is, I don't know, since I don't use Perforce and\n> don't maintain git-p4, which has a separate maintainer.\n\nI am not sure what story about shebang is discussed here.\n\nIf the complaint is \"your script says '/usr/bin/env python', but my\nusers don't have 'python' on their $PATH\", I think that is barking\nup a wrong tree.  As a general principle, we try not to rely on\n\"env\".\n\nJust like other scripts, we munge git-p4.py script to replace the\nshebang line to use the path to the python binary specified by the\nbuilder into resulting git-p4 \"executable\" file that is installed.\n\nWe do this (not specifically for git-p4 but as a general principle)\nbecause we do not want to get affected by random customized versions\nof stuff end-users install on their $PATH that overrides the ones\nfrom the system that builders determined to be used by Git.\n\nIs the complaint that \"on my system there are /usr/bin/python2 and\n/usr/bin/python3 but no vanilla /usr/bin/python installed\"?  \n\nSo it is your responsibility to tell the build procedure that you\nwant to use \"/usr/bin/python3\", as the build procedure defaults to\n\"/usr/bin/python\" when you do not specify any.\n"}]}