Skip to content

Conversation

@Managor
Copy link
Member

@Managor Managor commented Jan 3, 2026

As was requested in tldr-pages/tldr#19775

The method I implemented this with feels stupid but I guess it works.

@Managor Managor marked this pull request as draft January 3, 2026 03:08
@Managor
Copy link
Member Author

Managor commented Jan 3, 2026

Gotta write documentation before merging this

@Managor Managor marked this pull request as ready for review January 3, 2026 03:43
Copy link
Member

@acuteenvy acuteenvy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who is this for if we aren't going to include /usr/share/tldr in the client spec? I think a configuration option to change the cache location would be much more useful. /usr/share/tldr won't exist 99% of the time, because the user has to create that directory and extract the pages archive there. If someone is willing to do that, setting a config option shouldn't be a problem at all.

@Managor
Copy link
Member Author

Managor commented Jan 3, 2026

In my opinion just having the files exist would be less friction for the user or the deployer. Both cases would require /usr/share/tldr to exist, but the other one would need an extra step.

@acuteenvy
Copy link
Member

just having the files exist would be less friction for the user

I'm not sure I understand what you're saying. How are these files going to exist? Do you want Linux distributions to package /usr/share/tldr?

@Managor
Copy link
Member Author

Managor commented Jan 3, 2026

A distribution can, but I'm not insisting on it. Personally it'll help me make easily copyable containers with a cache pre-downloaded.

Also as @SpikeTheDragon40k said here, it'll be great for airgapped systems. tldr-pages/tldr#19775 (comment)

@acuteenvy
Copy link
Member

A distribution can, but I'm not insisting on it

I doubt anyone will if we keep this as a client-specific feature. And if it isn't standardized, why force users to use /usr/share/tldr?

I don't want to block this though, maybe it's just me. But if it's going to be client-specific, I'd personally rather have an environment variable to configure the location.

@SpikeTheDragon40k
Copy link
Member

Could we use opt/tldr?

@Managor
Copy link
Member Author

Managor commented Jan 3, 2026

Possibly. Can you run me through the conceptual differences between using these directories? I always forget them.

@Managor
Copy link
Member Author

Managor commented Jan 3, 2026

I doubt anyone will if we keep this as a client-specific feature. And if it isn't standardized, why force users to use /usr/share/tldr?

I was thinking something similar, but @niklasmohrin convinced me otherwise that it would be too big of a shift in the goals of the spec. tldr-pages/tldr#19775 (comment)

We'll just have to rely on organic co-ordination instead of top-down dictating.

@SpikeTheDragon40k
Copy link
Member

SpikeTheDragon40k commented Jan 3, 2026

Possibly. Can you run me through the conceptual differences between using these directories? I always forget them.

Used Ai just to help me put the thought in words:

/usr/share is the standard spot for read-only, architecture-independent system data like docs and pages managed by your distro's package manager, think tldr pages installed via apt that auto-update and serve all users.

/opt is for optional, third-party or manually installed software packages kept in self-contained subdirs (like /opt/tldr) to avoid messing with the core system files.

The big diff: /usr/share stays pristine under OS control; /opt gives you isolation for custom stuff without conflicts.

@Managor
Copy link
Member Author

Managor commented Jan 3, 2026

Oh wait, wouldn't /usr/local/share drive the same purpose. If I remember correctly while testing different ways of implementing this, it was part of $XDG_DATA_DIRS. Maybe I should refactor this patch to loop through all of the entries in that variable.

@Managor Managor changed the title check /usr/share/tldr for a cache when user cache misses check $XDG_DATA_DIRS for a cache when user cache misses Jan 4, 2026
@Managor
Copy link
Member Author

Managor commented Jan 4, 2026

Man the code is so goddamn inefficient. There's so many repeated operations. Complete rewrite would be great.

Co-authored-by: Sebastiaan Speck <12570668+sebastiaanspeck@users.noreply.github.com>
@Managor Managor merged commit 9110b6d into main Jan 7, 2026
64 checks passed
@Managor Managor deleted the system branch January 7, 2026 04:52
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

Successfully merging this pull request may close these issues.

4 participants