Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init fails if $HOME is not defined #3276

Open
Noxsios opened this issue Nov 26, 2024 · 1 comment
Open

Init fails if $HOME is not defined #3276

Noxsios opened this issue Nov 26, 2024 · 1 comment

Comments

@Noxsios
Copy link
Contributor

Noxsios commented Nov 26, 2024

Environment

Device and OS: Intel NUC on Ubuntu 22.04
App version: v0.42.0
Kubernetes distro being used: RKE2
Other: Running init as systemd service

Steps to reproduce

  1. Run zarf init as a user / profile w/ no $HOME env variable.
  2. Init fails due to always attempting to find user's homedir during file copying.

target, err := config.GetAbsHomePath(strings.Replace(file.Target, "###ZARF_TEMP###", p.layout.Base, 1))

GetAbsHomePath needs a slight changeup in logic, it should only try to calculate homePath if ~ is found in the string, otherwise no home path expansion is needed.

zarf/src/config/config.go

Lines 105 to 115 in 09c41a1

func GetAbsHomePath(path string) (string, error) {
homePath, err := os.UserHomeDir()
if err != nil {
return "", err
}
if strings.HasPrefix(path, "~") {
return strings.Replace(path, "~", homePath, 1), nil
}
return path, nil
}

Visual Proof (screenshots, videos, text, etc)

ERROR:  failed to deploy bundle: unable to deploy component "zarf-injector": unable to process the component files: $HOME is not defined

Severity/Priority

Low, can define a dummy $HOME in the meantime.

@phillebaba
Copy link
Member

While I may agree that we could flip the order of the logic here, I do wonder why the system is not setting the home environment variable?

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

No branches or pull requests

2 participants