Skip to content

[Bug] RocketMQ Go client log dir #1028

@mingzaily

Description

@mingzaily

Before Creating the Bug Report

  • I found a bug, not just asking a question, which should be created in GitHub Discussions.

  • I have searched the GitHub Issues and GitHub Discussions of this repository and believe that this is not a duplicate.

  • I have confirmed that this bug belongs to the current repository, not other repositories of RocketMQ.

Programming Language of the Client

Go

Runtime Platform Environment

macOS 15.5

RocketMQ Version of the Client/Server

5.1.12

Run or Compiler Version

No response

Describe the Bug

The current RocketMQ Go client initializes its logging system using os.Getenv("user.home") to determine the user's home directory. In certain environments (containers, CI/CD pipelines, or specific IDE debugging sessions), this environment variable may not exist, causing the client to attempt creating a /logs folder in the system root directory, which fails due to permission issues.

Steps to Reproduce

producer, err := golang.NewProducer(&golang.Config{
	Endpoint: cfg.Endpoint,
	Credentials: &credentials.SessionCredentials{
		AccessKey:    cfg.AccessKey,
		AccessSecret: cfg.SecretKey,
	},
})
if err != nil {
	return nil, fmt.Errorf("failed to create rocketmq producer: %w", err)
}

if err := producer.Start(); err != nil {
	return nil, fmt.Errorf("failed to start producer: %w", err)
}

What Did You Expect to See?

normal log file

What Did You See Instead?

2025-06-30 15:11:29.388166 +0800 CST m=+146.273243918 write error: can't make directories for new logfile: mkdir /logs: read-only file system
2025-06-30 15:11:29.388517 +0800 CST m=+146.273595334 write error: can't make directories for new logfile: mkdir /logs: read-only file system
2025-06-30 15:11:29.388639 +0800 CST m=+146.273716834 write error: can't make directories for new logfile: mkdir /logs: read-only file system

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions