paths: skip the user search tier when there is no home directory
ConfigSearchDirs/DataSearchDirs/ExecutableSearchDirs (and therefore core/config's Resolve/ResolveAll/LoadMerged) failed outright with ErrNoHomeDirectory when HOME/USERPROFILE was unset, so a service started without HOME could no longer find its working-directory or /etc/<app> config -- a regression against the hand-rolled lookups being migrated onto core, which just skipped the user location. Missing-home now only drops the user tier from the search lists; the canonical <Category>Dir() methods still report ErrNoHomeDirectory. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
72b656262d
commit
e8bf23a064
7 files changed
+220
-57
No files matched your search
+30
-21
@@ -186,16 +186,19 @@ func (r *Resolver) configLayersUnix() ([]layer, error) {
|
||||
if v, ok := r.overrideValue(ConfigPath); ok {
|
||||
return []layer{{path: r.applyRoot(v.path), source: v.source, priority: PriorityUser, canonical: true}}, nil
|
||||
}
|
||||
var user []layer
|
||||
userVal, err := r.xdgBase("XDG_CONFIG_HOME", ".config")
|
||||
if err != nil {
|
||||
if err := skipMissingHome(err); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
user := []layer{{
|
||||
path: r.applyRoot(unixJoin(userVal.path, r.app.Name)),
|
||||
source: userVal.source,
|
||||
priority: PriorityUser,
|
||||
canonical: true,
|
||||
}}
|
||||
if err == nil {
|
||||
user = []layer{{
|
||||
path: r.applyRoot(unixJoin(userVal.path, r.app.Name)),
|
||||
source: userVal.source,
|
||||
priority: PriorityUser,
|
||||
canonical: true,
|
||||
}}
|
||||
}
|
||||
system := make([]layer, len(r.flavor().systemConfigDirs))
|
||||
for i, dir := range r.flavor().systemConfigDirs {
|
||||
system[i] = layer{
|
||||
@@ -212,16 +215,19 @@ func (r *Resolver) dataLayersUnix() ([]layer, error) {
|
||||
if v, ok := r.overrideValue(DataPath); ok {
|
||||
return []layer{{path: r.applyRoot(v.path), source: v.source, priority: PriorityUser, canonical: true}}, nil
|
||||
}
|
||||
var user []layer
|
||||
userVal, err := r.xdgBase("XDG_DATA_HOME", ".local", "share")
|
||||
if err != nil {
|
||||
if err := skipMissingHome(err); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
user := []layer{{
|
||||
path: r.applyRoot(unixJoin(userVal.path, r.app.Name)),
|
||||
source: userVal.source,
|
||||
priority: PriorityUser,
|
||||
canonical: true,
|
||||
}}
|
||||
if err == nil {
|
||||
user = []layer{{
|
||||
path: r.applyRoot(unixJoin(userVal.path, r.app.Name)),
|
||||
source: userVal.source,
|
||||
priority: PriorityUser,
|
||||
canonical: true,
|
||||
}}
|
||||
}
|
||||
dirs, source := r.xdgDataDirs()
|
||||
system := make([]layer, len(dirs))
|
||||
for i, dir := range dirs {
|
||||
@@ -239,16 +245,19 @@ func (r *Resolver) executableLayersUnix() ([]layer, error) {
|
||||
if v, ok := r.overrideValue(BinPath); ok {
|
||||
return []layer{{path: r.applyRoot(v.path), source: v.source, priority: PriorityUser, canonical: true}}, nil
|
||||
}
|
||||
var user []layer
|
||||
home, err := r.homeDir()
|
||||
if err != nil {
|
||||
if err := skipMissingHome(err); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
user := []layer{{
|
||||
path: r.applyRoot(unixJoin(home, ".local", "bin")),
|
||||
source: PlatformDefault,
|
||||
priority: PriorityUser,
|
||||
canonical: true,
|
||||
}}
|
||||
if err == nil {
|
||||
user = []layer{{
|
||||
path: r.applyRoot(unixJoin(home, ".local", "bin")),
|
||||
source: PlatformDefault,
|
||||
priority: PriorityUser,
|
||||
canonical: true,
|
||||
}}
|
||||
}
|
||||
system := []layer{{
|
||||
path: r.applyRoot(r.flavor().systemBinDir),
|
||||
source: SystemDirectory,
|
||||
|
||||
Reference in new issue
Block a user