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

Support external git? #49

Open
GunnarFarneback opened this issue Nov 14, 2023 · 13 comments
Open

Support external git? #49

GunnarFarneback opened this issue Nov 14, 2023 · 13 comments

Comments

@GunnarFarneback
Copy link
Contributor

Would it be reasonable to add a Preferences controlled option to call an external git instead of the jll?

Rationale is that I want to use the Git package for LocalRegistry but it would be nice to give the users an option to run their own git (older version, newer version, locally patched version, whatever) if they for some reason should need to.

@giordano
Copy link
Member

@GunnarFarneback
Copy link
Contributor Author

GunnarFarneback commented Nov 14, 2023

That's nice but I have a hard time figuring out how to use it.

I fail to get any effect at all from an Overrides.toml but I guess that's not a viable approach anyway due to

  • The artifact location is held in the artifact_dir variable mentioned above, which is the "prefix" of the installation of the package. Recall the paths of the products in the JLL package is relative to artifact_dir and the files you want to use to override the products of the JLL package must have the same tree structure as the artifact. In our example we need to use /usr to override Fontconfig and /usr/local for Bzip2.

and I can't see that my system git installation matches the directory structure of the artifact.

Doing set_preferences!("LocalPreferences.toml", "Git_jll", "git_path" => "/usr/bin/git") works to an extent. It does run my system git binary, at least the reported version matches, but git --exec-path points into my artifact, which seems less than robust. This is of course related to what goes on in https://github.com/JuliaVersionControl/Git.jl/blob/master/src/git_function.jl#L24-L48 and given the structural discrepancy between the artifact and my system installation I don't see how I could get it to work.

@giordano
Copy link
Member

You need a prefix which has git in $(prefix)/bin/git

@GunnarFarneback
Copy link
Contributor Author

This is my attempt with Overrides:

gunnar@gunnar-ubuntu22:/tmp/test1$ which git
/usr/bin/git
gunnar@gunnar-ubuntu22:/tmp/test1$ git --version
git version 2.34.1
gunnar@gunnar-ubuntu22:/tmp/test1$ cat Overrides.toml 
[f8c6e375-362e-5223-8a59-34ff63f689eb]
Git = "/usr"
gunnar@gunnar-ubuntu22:/tmp/test1$ julia --project=.
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.3 (2023-08-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Git_jll

julia> Git_jll.artifact_dir
"/home/gunnar/.julia/artifacts/8cb25db9a73519e871cc50d6915f8ab2770096f3"

julia> using Git

julia> run(`$(Git.git()) --version`);
git version 2.42.0

and this is the result with preferences:

gunnar@gunnar-ubuntu22:/tmp/test2$ git --exec-path
/usr/lib/git-core
gunnar@gunnar-ubuntu22:/tmp/test2$ cat LocalPreferences.toml 
[Git_jll]
git_path = "/usr/bin/git"
gunnar@gunnar-ubuntu22:/tmp/test2$ julia --project=.
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.9.3 (2023-08-24)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Git

julia> run(`$(Git.git()) --version`);
git version 2.34.1

julia> run(`$(Git.git()) --exec-path`);
/home/gunnar/.julia/artifacts/8cb25db9a73519e871cc50d6915f8ab2770096f3/libexec/git-core

@giordano
Copy link
Member

% julia --project=. -q
shell> cat LocalPreferences.toml
[Git_jll]
git_path = "/usr/bin/git"

shell> cat Project.toml
[deps]
Git_jll = "f8c6e375-362e-5223-8a59-34ff63f689eb"

julia> using Git_jll

julia> git()
setenv(`/usr/bin/git`,[...])

@giordano
Copy link
Member

You need Git_jll explicitly as top-level dependency in your project (I've never got whether that's intentional, or a bug)

@GunnarFarneback
Copy link
Contributor Author

I do have Git_jll as a direct dependency and I do get Git_jll.git() to point to /usr/bin/git but Git.git() sets up environment variables pointing into the artifact.

@giordano
Copy link
Member

Ah, ok, then probably we want to opt out of all the env vars in https://github.com/JuliaVersionControl/Git.jl/blob/259dc047e11ee326b7d2cac63cb09ceeb8f4711b/src/git_function.jl if the product is overridden, as we basically trust the outer environment is appropriately set.

@staticfloat
Copy link
Contributor

I think the issue is that everything is calculated based off of root which is set to artifact_dir, but you're overriding git_path. Perhaps Git.jl should base the locations off of git_path instead.

@GunnarFarneback
Copy link
Contributor Author

What is the preferred way to determine whether it has been overridden?

(Oh, well, all this stuff seems too complicated from a user point of view. It will be less work for me to just add a keyword argument to specify a custom git than to document how people should go about changing it through Git_jll preferences.)

@GunnarFarneback
Copy link
Contributor Author

Perhaps Git.jl should base the locations off of git_path instead.

Still seems tricky to line that up. The artifact has exec-path in ../../libexec/git-core whereas my system git has it in ../../lib/git-core.

@giordano
Copy link
Member

Yeah, that's why I think we should just not do anything here when the artifact is overridden, but I don't know how to test that condition.

@GunnarFarneback
Copy link
Contributor Author

You need Git_jll explicitly as top-level dependency in your project (I've never got whether that's intentional, or a bug)

I followed some bread crumbs and found that it's intentional, see second last section of JuliaLang/julia#37791 (comment).

It is a very annoying limitation.

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

3 participants