Gitea ignores path to git binary #4168

Closed
opened 2025-11-02 05:40:59 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @rmbleeker on GitHub (Oct 23, 2019).

  • Gitea version (or commit ref): 1.9.4
  • Git version: 1.8.3.1
  • Operating system: RHEL 7
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:
    N/A

Description

The current version of Git in the RHEL 7 repositories is 1.8.3.1. This version is quite old so I would like to use one of the more recent versions available in the SCL repository. However, SCL packages install everything outside of the regular directories, in /opt/rh. I've set the PATH in the [git] section of my gitea.ini file to point to the git binary (/opt/rh/rh-git218/root/usr/bin/git) but gitea seems to completely ignore this option and keeps using the git version that it finds in it's PATH environment variable, which is /usr/bin/git

Originally created by @rmbleeker on GitHub (Oct 23, 2019). <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.9.4 - Git version: 1.8.3.1 - Operating system: RHEL 7 - Database (use `[x]`): - [ ] PostgreSQL - [ ] MySQL - [ ] MSSQL - [x] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: N/A ## Description The current version of Git in the RHEL 7 repositories is 1.8.3.1. This version is quite old so I would like to use one of the more recent versions available in the SCL repository. However, SCL packages install everything outside of the regular directories, in `/opt/rh`. I've set the `PATH` in the `[git]` section of my `gitea.ini` file to point to the git binary (`/opt/rh/rh-git218/root/usr/bin/git`) but gitea seems to completely ignore this option and keeps using the git version that it finds in it's `PATH` environment variable, which is `/usr/bin/git`
Author
Owner

@rmbleeker commented on GitHub (Oct 23, 2019):

As a work-around I currently set Environment=PATH= in the systemd unit file for gitea to include /opt/rh/rh-git218/root/usr/bin/

@rmbleeker commented on GitHub (Oct 23, 2019): As a work-around I currently set `Environment=PATH=` in the systemd unit file for gitea to include `/opt/rh/rh-git218/root/usr/bin/`
Author
Owner

@zeripath commented on GitHub (Oct 23, 2019):

OK, so looking at this - master and 1.9 don't use "git" directly except in one place as a fallback in git.Init and in the install page.

Do you have any more information about when the wrong git is used?

Is it when you're pushing/pulling over SSH because that's the only place I can think that won't use the correct git necessarily?

@zeripath commented on GitHub (Oct 23, 2019): OK, so looking at this - master and 1.9 don't use "git" directly except in one place as a fallback in git.Init and in the install page. Do you have any more information about when the wrong git is used? Is it when you're pushing/pulling over SSH because that's the only place I can think that won't use the correct git necessarily?
Author
Owner

@rmbleeker commented on GitHub (Oct 23, 2019):

@zeripath that's a good question, how can I check? I just went with the information I found on the Configuration page in the site settings, it said "git version 1.8.3.1" there even though I had configured the path to point to the newer version.

@rmbleeker commented on GitHub (Oct 23, 2019): @zeripath that's a good question, how can I check? I just went with the information I found on the Configuration page in the site settings, it said "git version 1.8.3.1" there even though I had configured the path to point to the newer version.
Author
Owner

@zeripath commented on GitHub (Oct 23, 2019):

oh that's interesting... Let me have a look again...

@zeripath commented on GitHub (Oct 23, 2019): oh that's interesting... Let me have a look again...
Author
Owner

@zeripath commented on GitHub (Oct 23, 2019):

Ah. Found this out - although we use GitExecutable throughout our code, the code to use [git] PATH= is in 1.10 not 1.9.4.

If you cannot use 1.10-rc or master but can recompile gitea you would be able to change the default value from the linker using LDFLAGS="-X "code.gitea.io/gitea/modules/git.GitExecutable=YOUR_PATH""

@zeripath commented on GitHub (Oct 23, 2019): Ah. Found this out - although we use GitExecutable throughout our code, the code to use `[git]` `PATH=` is in 1.10 not 1.9.4. If you cannot use 1.10-rc or master but can recompile gitea you would be able to change the default value from the linker using LDFLAGS="-X \"code.gitea.io/gitea/modules/git.GitExecutable=YOUR_PATH\""
Author
Owner

@zeripath commented on GitHub (Oct 23, 2019):

FYI #6772 is the PR that provided this function. It would likely be possible to cherry-pick it on to 1.9.4 too.

@zeripath commented on GitHub (Oct 23, 2019): FYI #6772 is the PR that provided this function. It would likely be possible to cherry-pick it on to 1.9.4 too.
Author
Owner

@zeripath commented on GitHub (Oct 23, 2019):

As this feature is implemented but not planned to be backported I will close this issue.

@zeripath commented on GitHub (Oct 23, 2019): As this feature is implemented but not planned to be backported I will close this issue.
Author
Owner

@rmbleeker commented on GitHub (Oct 23, 2019):

I have it fixed with the work-around right now and can wait for the proper release of 1.10, so no problem.

@rmbleeker commented on GitHub (Oct 23, 2019): I have it fixed with the work-around right now and can wait for the proper release of 1.10, so no problem.
Author
Owner

@zeripath commented on GitHub (Oct 23, 2019):

Sorry about that! There's definitely an issue with ssh though - I think that needs some more thought. We might have to be putting git on the executable path etc.

@zeripath commented on GitHub (Oct 23, 2019): Sorry about that! There's definitely an issue with ssh though - I think that needs some more thought. We might have to be putting git on the executable path etc.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#4168