Skip to content

--edit-config fails with a nonexistent ~/.config #2283

Description

@tablackburn

Checklist

Area

Topgrade in general

Erroneous behavior

trent@hades:~$ topgrade -v --edit-config
DEBUG Current system locale is en-US
DEBUG No additional configuration directory exists, skipping
DEBUG No configuration exists
DEBUG Unable to write the example configuration file to /home/trent/.config/topgrade.toml: No such file or directory (os error 2). Using blank config.
Error:
   0: No such file or directory (os error 2)

Location:
   src/config.rs:663

Expected behavior

trent@hades:~$ topgrade -v --edit-config
DEBUG Current system locale is en-US
DEBUG No additional configuration directory exists, skipping
DEBUG No configuration exists
<text editor choice prompt>

Steps to reproduce

rm -rf /tmp/tg-repro
XDG_CONFIG_HOME=/tmp/tg-repro/config topgrade -v --edit-config

Problem persists when running command outside of Topgrade

None

Possible cause

ConfigFile::ensure() writes the file without creating its parent directory; Config::load guards this exact condition with if config_directory.is_dir(), but --edit-config returns early in main.rs and calls ConfigFile::edit() → ensure() directly, bypassing that guard.

Ran through Remote Execution?

No

Topgrade version

topgrade 17.9.0

Last working version

No response

Environment

OS: Ubuntu Server 26.04.1 LTS (GNU/Linux 7.0.0-29-generic x86_64)
Topgrade installed from the official .deb release asset. It's a system-wide install at /usr/bin/topgrade. The machine had no ~/.config directory at all

Configuration file

There is no config file

Verbose output

Verbose output
trent@hades:~$ XDG_CONFIG_HOME=/tmp/tg-repro/config topgrade -v --edit-config
DEBUG Current system locale is en-US
DEBUG No additional configuration directory exists, skipping
DEBUG No configuration exists
DEBUG Unable to write the example configuration file to /tmp/tg-repro/config/topgrade.toml: No such file or directory (os error 2). Using blank config.
Error:
   0: No such file or directory (os error 2)

Location:
   src/config.rs:663

Contribution

  • I am able and willing to implement a fix myself.
  • I am willing to test if someone else implements it. Guide

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs PRThis issue has a possibly feasible solution, waiting for a patch!

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions