Skip to content

Pkg.add HTTPS fails with OS Error 'Paramètre incorrect' (failed to convert string to wide form) on Windows with French Locale #4208

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

Open
mathieu17g opened this issue Apr 4, 2025 · 0 comments

Comments

@mathieu17g
Copy link

mathieu17g commented Apr 4, 2025

Title: Pkg.add HTTPS fails with OS Error 'Paramètre incorrect' (failed to convert string to wide form) on Windows with French Locale

Environment:

  • Julia Version: 1.11.4
    Commit 8561cc3d68 (2025-03-10 11:36 UTC)
    Build Info:
    Official https://julialang.org/ release
    Platform Info:
    OS: Windows (x86_64-w64-mingw32)
    CPU: 20 × 13th Gen Intel(R) Core(TM) i7-13700H
    WORD_SIZE: 64
    LLVM: libLLVM-16.0.6 (ORCJIT, goldmont)
    Threads: 20 default, 0 interactive, 10 GC (on 20 virtual cores)
    Environment:
    JULIA_NUM_THREADS = (8, 1)
    JULIA_SSL_CA_ROOTS_PATH =
  • Pkg Version: v1.11.0
  • Operating System: Windows 10 Pro (64-bit)
  • Windows Display Language/Locale: French (France)

Problem Description:

When trying to add a private package hosted on a private GitLab instance using its HTTPS URL via Pkg.add(url="..."), the operation fails consistently with an operating system error related to string conversion: failed to convert string to wide form: Paramètre incorrect.. This occurs using the default Pkg/LibGit2 pathway.

Steps to Reproduce:

The use of a private server makes exact reproduction difficult for others, but here are the steps:

  1. Have access to a private repository on a GitLab instance requiring authentication (e.g., GitLab Enterprise). Let's call the host <private-gitlab-hostname> and the repo <group>/<project>.git.
  2. On a Windows 10 machine configured with French locale/language settings, install Julia (e.g., 1.11.4).
  3. Install Git for Windows and configure the credential manager: git config --global credential.helper manager.
  4. Ensure credentials for the GitLab instance are cached (e.g., by successfully running git clone https://<private-gitlab-hostname>/<group>/<project>.git once from Git Bash).
  5. In Julia, attempt to add the private package using its HTTPS URL (ensure ENV["JULIA_PKG_USE_CLI_GIT"] is not set or is false):
    using Pkg
    pkg_url = "https://<private-gitlab-hostname>/<group>/<project>.git"
    Pkg.add(url=pkg_url)

Observed Behavior:

The Pkg.add command fails during the Updating git-repo or Cloning git-repo phase with the following error and stack trace:

julia> Pkg.add(url="https://<private-gitlab-hostname>/<group>/<project>.git")
    Updating git-repo `https://<private-gitlab-hostname>/<group>/<project>.git`
ERROR: failed to fetch from https://<private-gitlab-hostname>/<group>/<project>.git, error: GitError(Code:ERROR, Class:OS, failed to convert string to wide form: Paramètre incorrect.
)
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Types.jl:68
  [2] fetch(io::IOContext{…}, repo::LibGit2.GitRepo, remoteurl::String; header::Nothing, credentials::Nothing, refspecs::Vector{…}, kwargs::@Kwargs{})
    @ Pkg.GitTools C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\GitTools.jl:189
  [3] (::Pkg.Types.var"#58#59"{Pkg.Types.Context, Pkg.Types.PackageSpec, String})(repo::LibGit2.GitRepo)
    @ Pkg.Types C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Types.jl:815
  [4] with(f::Pkg.Types.var"#58#59"{Pkg.Types.Context, Pkg.Types.PackageSpec, String}, obj::LibGit2.GitRepo)
    @ LibGit2 C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LibGit2\src\types.jl:1166
  [5] handle_repo_add!(ctx::Pkg.Types.Context, pkg::Pkg.Types.PackageSpec)
    @ Pkg.Types C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Types.jl:790
  [6] handle_repos_add!(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.Types C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Types.jl:860
  [7] add(ctx::Pkg.Types.Context, pkgs::Vector{…}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, target::Symbol, allow_autoprecomp::Bool, kwargs::@Kwargs{})
    @ Pkg.API C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:291
  [8] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::IOContext{IO}, kwargs::@Kwargs{})
    @ Pkg.API C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:159
  [9] add(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:148
 [10] add
    @ C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:146 [inlined]
 [11] add(; name::Nothing, uuid::Nothing, version::Nothing, url::String, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::@Kwargs{})
    @ Pkg.API C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:176
 [12] top-level scope
    @ REPL[4]:1

caused by: GitError(Code:ERROR, Class:OS, failed to convert string to wide form: Paramètre incorrect.
)
Stacktrace:
  [1] macro expansion
    @ C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LibGit2\src\error.jl:115 [inlined]
  [2] fetch(rmt::LibGit2.GitRemote, refspecs::Vector{String}; options::LibGit2.FetchOptions, msg::String)
    @ LibGit2 C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LibGit2\src\remote.jl:312
  [3] fetch
    @ C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LibGit2\src\remote.jl:307 [inlined]
  [4] fetch(repo::LibGit2.GitRepo; remote::String, remoteurl::SubString{…}, refspecs::Vector{…}, credentials::Nothing, callbacks::Dict{…})
    @ LibGit2 C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LibGit2\src\LibGit2.jl:295
  [5] fetch
    @ C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LibGit2\src\LibGit2.jl:272 [inlined]
  [6] fetch(io::IOContext{…}, repo::LibGit2.GitRepo, remoteurl::String; header::Nothing, credentials::Nothing, refspecs::Vector{…}, kwargs::@Kwargs{})
    @ Pkg.GitTools C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\GitTools.jl:182
  [7] (::Pkg.Types.var"#58#59"{Pkg.Types.Context, Pkg.Types.PackageSpec, String})(repo::LibGit2.GitRepo)
    @ Pkg.Types C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Types.jl:815
  [8] with(f::Pkg.Types.var"#58#59"{Pkg.Types.Context, Pkg.Types.PackageSpec, String}, obj::LibGit2.GitRepo)
    @ LibGit2 C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\LibGit2\src\types.jl:1166
  [9] handle_repo_add!(ctx::Pkg.Types.Context, pkg::Pkg.Types.PackageSpec)
    @ Pkg.Types C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Types.jl:790
 [10] handle_repos_add!(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.Types C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\Types.jl:860
 [11] add(ctx::Pkg.Types.Context, pkgs::Vector{…}; preserve::Pkg.Types.PreserveLevel, platform::Base.BinaryPlatforms.Platform, target::Symbol, allow_autoprecomp::Bool, kwargs::@Kwargs{})
    @ Pkg.API C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:291
 [12] add(pkgs::Vector{Pkg.Types.PackageSpec}; io::IOContext{IO}, kwargs::@Kwargs{})
    @ Pkg.API C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:159
 [13] add(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:148
 [14] add
    @ C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:146 [inlined]
 [15] add(; name::Nothing, uuid::Nothing, version::Nothing, url::String, rev::Nothing, path::Nothing, mode::Pkg.Types.PackageMode, subdir::Nothing, kwargs::@Kwargs{})
    @ Pkg.API C:\Users\<username>\.julia\juliaup\julia-1.11.4+0.x64.w64.mingw32\share\julia\stdlib\v1.11\Pkg\src\API.jl:176
 [16] top-level scope
    @ REPL[4]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia>

This error occurs consistently, even when the credential manager is properly configured and has cached credentials. The credential manager prompt is never reached. Further investigation suggests the failure might originate specifically within the libgit2 C function git_utf8_to_16_alloc, aligning with the "failed to convert string to wide form" error message.

Expected Behavior:

Pkg.add should successfully clone/fetch the repository using the cached credentials from the Git Credential Manager, mirroring the behavior of command-line Git. It should not fail with the OS-level Paramètre incorrect error during the HTTPS fetch/clone operation.

Workarounds and Contrasting Behavior (Evidence that the core issue is likely within Pkg/LibGit2):

  1. Command-line git clone https://.../ works perfectly using the exact same URL (https://<private-gitlab-hostname>/<group>/<project>.git) and successfully uses the Git Credential Manager without error.
  2. Setting the environment variable ENV["JULIA_PKG_USE_CLI_GIT"]=true makes Pkg.add(url="https://.../") work correctly within Julia. This forces Pkg to use the external git.exe and successfully bypasses the error.
  3. Other tools (like VS Code extensions) interacting with the same repository over HTTPS also work correctly on the same machine.

Additional Context:

The error message Paramètre incorrect. is the French translation for "Invalid parameter." This might suggest the issue is related to how LibGit2 interacts with Windows APIs concerning string handling or parameters (specifically UTF-8 to UTF-16 conversion via git_utf8_to_16_alloc), potentially influenced by the system's locale settings, when establishing the HTTPS connection to this specific server type.

Request:

Could this potential issue within Pkg/LibGit2.jl on Windows with non-English locales be investigated? Relying on the JULIA_PKG_USE_CLI_GIT workaround requires installing command-line Git, which negates some of the benefits of Julia's self-contained package management for end-users.

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

1 participant