Skip to contentSkip to conversation

PREFIX environment variable ignored by git config --system

BUG [email protected] 4 participants 15 messages Jan 29, 2025 – Jan 30, 2025

lore
Share & tools
lore
#0 lore raw

Thank you for filling out a Git bug report!

Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue) export PREFIX=/home/randall
git config --system --list

What did you expect to happen? (Expected behavior)
Git should use ${PREFIX}/etc/gitconfig instead of the build location to locate
System configuration items, per 10.8 in the git-scm website documentation on Environment Variables.
Git should have reported:
fatal: unable to read config file '/home/randall/etc/gitconfig': No such file or directory

What happened instead? (Actual behavior)
git used /usr/local-ssl3.0/etc/gitconfig instead and reported that the file does not exist:
fatal: unable to read config file '/usr/local-ssl3.0/etc/gitconfig': No such file or directory

What's different between what you expected and what actually happened? The directory being used based on the PREFIX variable.

Anything else you want to add:
This appears to be a problem on all platforms.

[System Info]
git version:
git version 2.47.1
cpu: NSV
built from commit: 92999a42db1c5f43f330e4f2bca4026b5b81576f
sizeof-long: 4

[System Info]
git version:
git version 2.45.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8

--
Brief whoami: NonStop&UNIX developer since approximately UNIX(421664400)
NonStop(211288444200000000)
-- In real life, I talk too much.

#1 lore raw
Quoted 10 lines · <[email protected]> writes:

Thank you for filling out a Git bug report!

Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue) export PREFIX=/home/randall
git config --system --list

What did you expect to happen? (Expected behavior)
Git should use ${PREFIX}/etc/gitconfig instead of the build location to

But that is now how PREFIX works, as far as I remember. PREFIX is a build-time thing.

Perhaps you are looking for RUNTIME_PREFIX build-time option? I do not know how well it is maintained these days, and if it allows you to futz with the paths at runtime (without _moving_ the executable and all other installation material en masse), though.

#2 lore raw

On January 29, 2025 11:42 AM, Junio C Hamano. Wrote:

Quoted 6 lines
Quoted 4 lines · <[email protected]> writes:

Thank you for filling out a Git bug report!

Please answer the following questions to help us understand your issue.

Quoted 7 lines
Quoted 5 lines

What did you do before the bug happened? (Steps to reproduce your issue) export PREFIX=/home/randall git config --system --list

What did you expect to happen? (Expected behavior) Git should use ${PREFIX}/etc/gitconfig instead of the build location to

But that is now how PREFIX works, as far as I remember. PREFIX is a

build-time

Quoted 3 lines

thing.

Perhaps you are looking for RUNTIME_PREFIX build-time option? I do not

know

Quoted 1 line

how well it is maintained these days, and if it allows you to futz with the

paths at

Quoted 1 line

runtime (without _moving_ the executable and all other installation

material en

Quoted 1 line

masse), though.

The documentation on the Environment Configuration page seems to imply that these are run-time variables, not build time, which should come from the config.mak.uname. In any event, I'm in a situation where I do not have the security to create the actual ../etc directory so am trying to test an alternate
location. Some of the customers I am supporting have experienced this also.

Any ideas on handling an execution time override of the system location, instead of
just using GIT_CONFIG_NOSYSTEM to turn off --system?

I would gladly add GIT_CONFIG_SYSTEM=path with a little guidance, if that's what it
comes down to.

--Randall

#13 lore raw
In reply to Junio C Hamano
Quoted 6 lines · Junio C Hamano
Quoted 4 lines · <[email protected]> writes:

Thank you for filling out a Git bug report!

Please answer the following questions to help us understand your issue.

Quoted 7 lines
Quoted 5 lines

What did you do before the bug happened? (Steps to reproduce your issue) export PREFIX=/home/randall git config --system --list

What did you expect to happen? (Expected behavior) Git should use ${PREFIX}/etc/gitconfig instead of the build location to

But that is now how PREFIX works, as far as I remember. PREFIX is a

build-time

Quoted 3 lines

thing.

Perhaps you are looking for RUNTIME_PREFIX build-time option? I do not

know

Quoted 1 line

how well it is maintained these days, and if it allows you to futz with the

paths at

Quoted 1 line

runtime (without _moving_ the executable and all other installation

material en

Quoted 1 line

masse), though.

I did try that at runtime. No luck. I think we need to fix this.

#5 lore raw
Quoted 8 lines · <[email protected]> writes:
Quoted 6 lines · Junio C Hamano
Quoted 2 lines · <[email protected]> writes:

The documentation on the Environment Configuration page seems to imply that

Sorry, I am totally lost. Whose documentation on what software are you

referring

Quoted 8 lines
Quoted 5 lines

to?

 $ git grep -i -e 'environment configuration'

comes back empty.

It is here:
https://git-scm.com/book/ms/v2/Git-Internals-Environment-Variables

It is news to me ;-).

    $ git grep '[^_]PREFIX[^_]'

does not have any hits in the source, so I do not see how we _could_ be paying any attention to such a thing.

The description seems to originate at

https://github.com/progit2-ms/progit2/commit/c24f22d6a6b0572f5756afd64f0c2e9fa6f804fa

that was more than 10 years old. I do not know how reliable the description there is.

#14 lore raw
In reply to Junio C Hamano
Quoted 21 lines · Junio C Hamano
Quoted 10 lines · Junio C Hamano
Quoted 8 lines · <[email protected]> writes:

Thank you for filling out a Git bug report!

Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue) export PREFIX=/home/randall
git config --system --list

Quoted 5 lines
Quoted 2 lines

What did you expect to happen? (Expected behavior)
Git should use ${PREFIX}/etc/gitconfig instead of the build location to

But that is now how PREFIX works, as far as I remember. PREFIX is a build-time thing.

Sorry, I misspoke.

I was talking about $(prefix) Makefile macro, that is all lowercase.

#6 lore raw
In reply to Junio C Hamano
Quoted 17 lines · Junio C Hamano
Quoted 15 lines · <[email protected]> writes:
Quoted 7 lines · Junio C Hamano
Quoted 2 lines · <[email protected]> writes:

The documentation on the Environment Configuration page seems to imply that

Sorry, I am totally lost. Whose documentation on what software are you

referring

Quoted 5 lines

to?

 $ git grep -i -e 'environment configuration'

comes back empty.

Quoted 8 lines
Quoted 2 lines

It is here:
https://git-scm.com/book/ms/v2/Git-Internals-Environment-Variables

It is news to me ;-).

   $ git grep '[^_]PREFIX[^_]'

does not have any hits in the source, so I do not see how we _could_ be

paying any

Quoted 8 lines

attention to such a thing.

The description seems to originate at

https://github.com/progit2-
ms/progit2/commit/c24f22d6a6b0572f5756afd64f0c2e9fa6f804fa

that was more than 10 years old. I do not know how reliable the

description there

Quoted 1 line

is.

Those of us who have written documentation for much of our lives, really miss accuracy. There are companies where a wrong bit of documentation is considered as high severity defect. Regardless of that...

t1300-config.sh has the following line in it:

GIT_CONFIG_SYSTEM=write-to-system git config --system config.key value &&

Could it mean that GIT_CONFIG_SYSTEM is actually what I am looking for?

#7 lore raw
Quoted 3 lines · <[email protected]> writes:

Those of us who have written documentation for much of our lives, really miss accuracy. There are companies where a wrong bit of documentation is considered as high severity defect. Regardless of that...

The association with that "book" and those who hang around here is that we could contribute corrections to them, as they are open source and we are friends, but that is about it ;-).

I am reasonably sure that they will appreciate a well researched pull request (and "well reserached" does not mean "somebody says this is incorrect" but needs a bit more than that).

THanks.

#8 lore raw
Quoted 6 lines · Junio C Hamano
Quoted 3 lines · <[email protected]> writes:

Those of us who have written documentation for much of our lives, really miss accuracy. There are companies where a wrong bit of documentation is considered as high severity defect. Regardless of that...

Quoted 7 lines

The association with that "book" and those who hang around here is that we could contribute corrections to them, as they are open source and we are friends, but that is about it ;-).

I am reasonably sure that they will appreciate a well researched pull request (and "well reserached" does not mean "somebody says this is incorrect" but needs a bit more than that).

Well, we are all friends here 😉

Be that as it may, the following seems to work:

$ GIT_CONFIG_SYSTEM=/home/randall/etc/gitconfig git config --system --list
fatal: unable to read config file '/home/randall/etc/gitconfig': No such file or directory

This appears to do exactly what I am looking for. When I create that file, git picks up config values from that file.The question is, is this environment variable actually sanctioned or is it just coincidence? It does exactly what I am looking for.

#9 lore raw
Quoted 3 lines · <[email protected]> writes:

This appears to do exactly what I am looking for. When I create that file, git picks up config values from that file.The question is, is this environment variable actually sanctioned or is it just coincidence? It does exactly what I am looking for.

How about reading "git config --help"?

#10 lore raw
Quoted 5 lines · Junio C Hamano
Quoted 3 lines · <[email protected]> writes:

This appears to do exactly what I am looking for. When I create that file, git picks up config values from that file.The question is, is this environment variable actually sanctioned or is it just coincidence?

It does

Quoted 3 lines

exactly what I am looking for.

How about reading "git config --help"?

Yup. It's there, thanks. So should I figure out how to sync the website with this
or ignore it?

#11 lore raw
Quoted 10 lines · Le 29 janv. 2025 à 19:37, [email protected] a écrit :
Quoted 5 lines · Junio C Hamano
Quoted 3 lines · <[email protected]> writes:

This appears to do exactly what I am looking for. When I create that file, git picks up config values from that file.The question is, is this environment variable actually sanctioned or is it just coincidence?

Quoted 8 lines

It does

Quoted 3 lines

exactly what I am looking for.

How about reading "git config --help"?

Yup. It's there, thanks. So should I figure out how to sync the website with this
or ignore it?

I often link less experienced Git users to git-scm.com, so I appreciate if it is fixed in some way.

#12 lore raw
In reply to [email protected]
Quoted 6 lines · <[email protected]> writes:
Quoted 5 lines · Junio C Hamano
Quoted 3 lines · <[email protected]> writes:

This appears to do exactly what I am looking for. When I create that file, git picks up config values from that file.The question is, is this environment variable actually sanctioned or is it just coincidence?

Quoted 8 lines

It does

Quoted 3 lines

exactly what I am looking for.

How about reading "git config --help"?

Yup. It's there, thanks. So should I figure out how to sync the website with this
or ignore it?

It depends on how good a friend you are to them, right ;-)?

https://github.com/progit/progit2/issues?q=is%3Aissue%20state%3Aopen%20PREFIX

seems to say that the issue has not been reported, and doing so might be a good first step.

We'd probably want a bit of history digging to see if we ever supported "$PREFIX/etc/gitconfig" before opening that issue, though. How to phrase the issue would be different between "we used to but no longer support this since version X" and "we never supported such a variable". This is a #leftoverbit for those without a lot of coding skills but patience, being good at using "git blame", and a good notetaking skills to summarize findings, are needed.

Another good thing to do is to match the environment variables and their descriptions we have in the output from "git help git" with that page. We may have acquired a few more of them since that page of the book was written 10 years ago, for example. This would be a good #leftoverbit for those without any coding experience but want to improve the documentation that exists in the overall ecosystem.

Thanks.