Skip to content

Support overriding the HOME environment variable #1564

Closed

Description

@debarshiray

Currently, if the HOME environment variable is temporarily overriden, toolbox(1) doesn't respect it. This is likely because Go's os/user doesn't respect the variable. Instead, it could be better to use os.UserHomeDir.

package main

import (
	"fmt"
	"os"
	"os/user"
)

func main() {
	user, _ := user.Current()
	fmt.Printf("%s\n", user.HomeDir)

	userHomeDir, err := os.UserHomeDir()
	fmt.Printf("%s, %s\n", userHomeDir, err)
}
$ HOME=/tmp go run user.go
/home/rishi
/tmp, %!s(<nil>)

See the discussion from here for the original motivation.

Activity

  1. added a commit that references this issue on Oct 31, 2024
    3a70ee7
  2. dongdigua commented on May 19, 2025

    @dongdigua

    good

  3. debarshiray commented on Jun 26, 2025

    @debarshiray
    MemberAuthor

    Fixed by #1667 and #1670

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions