sake icon indicating copy to clipboard operation
sake copied to clipboard

Config file not found from documented location ${XDG_CONFIG_HOME}/sake/config.yaml

Open ristomatti opened this issue 7 months ago • 1 comments

  • [x] I have the latest version of sake
  • [x] I have searched through the existing issues

Info

  • OS

    • [x] Linux
    • [ ] Mac OS X
    • [ ] Windows
    • [ ] other
  • Shell

    • [ ] Bash
    • [x] Zsh
    • [ ] Fish
    • [ ] Powershell
    • [ ] other
  • Version: 0.15.1

Problem / Steps to reproduce

Config file at ${XDG_CONFIG_HOME}/sake/config.yaml is not detected.

$ cat ${XDG_CONFIG_HOME}/sake/config.yaml
servers:
  one:
    host: 192.168.1.101
    tags:
      - home
  two:
    host: 192.168.1.102
    tags:
      - home

tasks:
  ping-router:
    desc: Ping router
    cmd: ping -c 1 192.168.1.1

# Cannot find config from the documented location
$ sake list servers 
error: cannot find any configuration file [sake.yaml sake.yml .sake.yaml .sake.yml] in current directory or any of the parent directories

# Explicitly telling the location results in a circular dependency
$ sake --config .config/sake/config.yaml list servers 
error: Found direct or indirect circular dependency
  --> /home/ristomatti/.config/sake/config.yaml
      /home/ristomatti/.config/sake/config.yaml

# I tried --user-config as well just for sake of completeness
$ sake --user-config .config/sake/config.yaml list servers 
error: cannot find any configuration file [sake.yaml sake.yml .sake.yaml .sake.yml] in current directory or any of the parent directories

# Move the config to current/home dir...
$ mv ${XDG_CONFIG_HOME}/sake/config.yaml ~/.sake.yaml 

# ... then it's detected
$ sake list servers                        

 server | host          | tags        
--------+---------------+-------------
 one    | 192.168.1.101 | home
 two    | 192.168.1.102 | home 

ristomatti avatar May 11 '25 20:05 ristomatti

User config is in addition to the regular config file. To invoke sake:

  • a sake.yml file must be found in the current or any parent directory, OR
  • you have set the env variable SAKE_CONFIG, OR
  • you use the config flag --config

The circular dependency is because you are specifying the user config (XDG_CONFIG_HOME/sake/config.yml) as a config.

The idea with the user config is mostly if you have some tasks/themes that you don't want to be shared with others, but maybe we should default to the user config if no sake.yaml is found.

Some more info here: https://sakecli.com/recipes#invoke-sake-from-any-directory https://sakecli.com/recipes#import-a-default-user-config-for-any-sake-project

alajmo avatar Jun 07 '25 06:06 alajmo

Ok, so it's not a bug, I'll close this.

My use case would be to manage groups of servers I host on my local network. It would be convenient not to have to go to a specific directory or specify a config file on every use. Please consider supporting this "global config" use case. Sake seems perfect for this sort of thing.

ristomatti avatar Jun 09 '25 07:06 ristomatti

I understand, just to mention it again, you can set the SAKE_CONFIG env variable to ~/.config/sake/sake.yaml and invoke mani from anywhere to get the same results, it's what I do myself.

alajmo avatar Jun 11 '25 03:06 alajmo