Skip to content

Commit

Permalink
config: fix system paths when relocating aerc
Browse files Browse the repository at this point in the history
The following error occurs when packaging aerc for Conda:

 $ aerc
 /home/conda/.config/aerc/aerc.conf not found, installing the system default
 error: open /usr/share/aerc/aerc.conf: no such file or directory

Conda installs aerc to a custom $PREFIX, so the config files will not be
available in /usr/share/aerc. The above error occurs because aerc
searches multiple paths for config paths and /usr/share/aerc happens to
be the last path. The $PREFIX is first in the search list, so we would
expect it to find the Conda installed files.

By dumping out the contents of the search paths, I observed the $PREFIX
paths are being searched but they are corrupted because their strings
end with embedded NULLs (\x00).

Conda builds aerc with a $PREFIX that is extremely long. Then when
installing aerc, it does relocation by replacing the build $PREFIX with
the final install $PREFIX, appending NULLs to fill out the string.

go-lang does not use NULL-terminated strings, so these NULLs are
preserved in the path. Trim any NULLs from the end of $PREFIX paths.

Signed-off-by: Brandon Maier <[email protected]>
Acked-by: Robin Jarry <[email protected]>
  • Loading branch information
blmaier authored and rjarry committed Dec 21, 2024
1 parent baa0b69 commit d5c04d3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func buildDefaultDirs() []string {
}
}

// Trim null chars inserted post-build by systems like Conda
shareDir := strings.TrimRight(shareDir, "\x00")
libexecDir := strings.TrimRight(libexecDir, "\x00")

// Add custom buildtime dirs
if libexecDir != "" && libexecDir != "/usr/local/libexec/aerc" {
defaultDirs = append(defaultDirs, xdg.ExpandHome(libexecDir))
Expand Down

0 comments on commit d5c04d3

Please sign in to comment.