Skip to content

Correct paths for utop-history, utoprc: in utop subdirs of XDG base dirs - #484

Merged
Octachron merged 2 commits into
ocaml-community:masterfrom
tuohy:xdgpaths
Jul 22, 2025
Merged

Correct paths for utop-history, utoprc: in utop subdirs of XDG base dirs#484
Octachron merged 2 commits into
ocaml-community:masterfrom
tuohy:xdgpaths

Conversation

@tuohy

@tuohy tuohy commented Apr 3, 2024

Copy link
Copy Markdown
Contributor

Issue #481 described failure to load utoprc from its stated location
PR #475 misidentified the issue as an incorrect README

In fact the paths were pointing to files within the XDG base directories themselves rather than in a subdirectory for the utop application.

This patch simply changes $XDG_STATE_HOME/utop-history to $XDG_STATE_HOME/utop/utop-history and $XDG_CONFIG_HOME/utoprc to $XDG_CONFIG_HOME/utop/utoprc

@tuohy
tuohy requested a review from rgrinberg as a code owner April 3, 2024 08:50
@tuohy

tuohy commented Apr 4, 2024

Copy link
Copy Markdown
Contributor Author

Added check & creation of history file's parent directory, fixing #478

This was exacerbated with the first patch because XDG_STATE_HOME/utop was extremely unlikely to exist on any system

@mmottl

mmottl commented Feb 8, 2025

Copy link
Copy Markdown

I believe this should be the proper place since init.ml is also in .config/utop, and it's already documented like that in the README.

@Octachron

Copy link
Copy Markdown
Member

I also agree that this is more standard location. I am planning to merge if there are no objections.

Comment thread src/lib/uTop_main.ml
(fun () -> LTerm_history.load UTop.history fn)
(fun () ->
let dn = Filename.dirname fn in
if not (Sys.file_exists dn) then Unix.mkdir dn 0o700;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Isn't 700 a bit strict for permissions on a directory? I would expect 755 (possibly lowered by the user umask)

@Octachron
Octachron merged commit 0cbe54e into ocaml-community:master Jul 22, 2025
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit to Octachron/opam-repository that referenced this pull request Jul 25, 2025
CHANGES:

* Add support for OCaml 5.4 (ocaml-community/utop#500, @Octachron, @anmonteiro)
* restore backtrace (ocaml-community/utop#503, fixes ocaml-community/utop#501, @ysalmon)
* support camlp$n preprocessor (ocaml-community/utop#486, fixes ocaml-community/utop#485, @aqjune)
* utop configuration and state files (utoprc, utop-history) are now always in the relevant
  utop subdirectory (ocaml-community/utop#484, fixes ocaml-community/utop#478, ocaml-community/utop#481 and ocaml-community/utop#499, @tuohy).
* fix emacs completion for qualified paths (Module.M.some_name) (ocaml-community/utop#497, fix ocaml-community/utop#455, @juergenhoetzel, @bbatsov)
* implicit bindings for emacs mode (ocaml-community/utop#465, fix ocaml-community/utop#412, @bencef)
Octachron added a commit that referenced this pull request Aug 12, 2025
fix utoprc templates to mention the correct path (changed by #484)
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.

3 participants