Skip to content

curl tool won't search for curlrc (no leading dot) in XDG_CONFIG_HOME #12129

Description

@jay

I did this

@b-jazz reported in #8208 (comment) that when curl is searching for the .curlrc file, it searches XDG_CONFIG_HOME for .curlrc but does not search it for curlrc (no leading dot).

The original reporter of #8208 reported that as well. When that issue was fixed by 764e4f0 it did not fix that part of the issue. Instead it was written in a specific way to not do that. findfile will search for curlrc (no leading dot) in $CURL_HOME/.config/curlrc and $HOME/.config/curlrc, but only if XDG_CONFIG_HOME is not set and .curlrc has not been found anywhere else.

Here's two typical setups and how curl currently behaves:

If CURL_HOME is not set, and XDG_CONFIG_HOME is set, and HOME is set, then the order is:

  • $XDG_CONFIG_HOME/.curlrc
  • $HOME/.curlrc
  • pw_dir/.curlrc

If CURL_HOME is not set, and XDG_CONFIG_HOME is not set, and HOME is set, then the order is:

  • $HOME/.curlrc
  • $HOME/.config/curlrc (this path is checked because XDG_CONFIG_HOME is not set)
  • pw_dir/.curlrc

Note pw_dir is usually the same as $HOME.

Note for brevity I've excluded how we also search for _curlrc when .curlrc is not found, since that logic just complicates understanding this and AFAICT it's not relevant here.

I expected the following

I'm not sure if this is a bug or not since the commit was written specifically not to strip the dot from curlrc when checking XDG_CONFIG_HOME, and I can't figure from the discussion why it was done that way.

curl/libcurl version

curl 8.4.0

operating system

Linux

Activity

  1. jay commented on Oct 15, 2023

    @jay
    MemberAuthor

    -K, --config doc says it should be doing $XDG_CONFIG_HOME/curlrc so then is there not supposed to be any $XDG_CONFIG_HOME/.curlrc? If that's the case fixing it won't be as simple as turning on withoutdot member for XDG_CONFIG_HOME because there's logic that skips XDG_CONFIG_HOME in that case.

  2. b-jazz commented on Oct 15, 2023

    @b-jazz

    Other applications that put stuff in ~/.config usually have no leading dot in that top level since the work of hiding all these configs is done at the top level itself. But whatever the outcome is, the real bug might be that the man page doesn’t match the implementation in the current version and that will cause confusion.

  3. jay commented on Oct 15, 2023

    @jay
    MemberAuthor

    Well on further thought I think the ship has sailed so to speak, as it's likely that users are already using .curlrc in XDG_CONFIG_HOME since that's all that has worked, however we can add another ship for curlrc in XDG_CONFIG_HOME. It's too late now to recall it. Again I don't know why this wasn't done if it was a bug or what but I'm going to treat it as one and write up a PR

  4. bagder commented on Oct 16, 2023

    @bagder
    Member

    I think it is a bug.

  5. sukanto-earth commented on Jul 26, 2024

    @sukanto-earth

    Hi everyone,

    I'm new to contributing to libcurl, and I'd like to work on this issue. I'll start investigating and update here with my progress. Any guidance or tips would be greatly appreciated.

    Thanks,
    Sukanto

  6. bagder commented on Aug 9, 2024

    @bagder
    Member

    @sukanto-earth I believe the core of this logic is in src/tool_findfile.c:findfile()

  7. added a commit that references this issue on Aug 20, 2024
    26e9d3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions