Skip to content

Conversation

@sumantro93
Copy link

Add fixes for 1564

@sumantro93 sumantro93 changed the title fixes #1564 usr /home/sumantro fixes #1564 usr home Oct 31, 2024
Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pull request, @sumantro93 !

The code is failing to compile with:

# github.com/containers/toolbox/cmd
cmd/utils.go:30:2: user redeclared in this block
cmd/utils.go:28:2: other declaration of user
cmd/utils.go:30:2: "os/user" imported and not used
cmd/create.go:308:2: declared and not used: homeDir
cmd/create.go:309:2: declared and not used: resolvedPath
cmd/create.go:309:45: undefined: HomeDir
cmd/create.go:476:15: undefined: homeDirMountArg
cmd/initContainer.go:270:21: undefined: user
cmd/initContainer.go:580:15: undefined: user
cmd/run.go:445:17: assignment mismatch: 1 variable but user.Current returns 2 values

Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are some things that I noticed that could help with getting the code to compile:

src/cmd/utils.go Outdated
"fmt"
"io"
"os"
"os/user"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet this line is causing:

cmd/utils.go:30:2: user redeclared in this block
cmd/utils.go:28:2: other declaration of user

The code was already importing os/user a few lines below, so no need to import it again. :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now you removed both imports, and it's causing:

cmd/utils.go:333:38: undefined: user

"fmt"
"io/ioutil"
"os"
"os/user"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet this line is causing:

cmd/initContainer.go:270:21: undefined: user
cmd/initContainer.go:580:15: undefined: user

Why did you remove the import of os/user?

"errors"
"fmt"
"os"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: stray newline.

Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally, a few things about the Git metadata.

Could you please try to squash the commits into logical units that successfully build and pass the tests, instead of a series of fix-up commits? See the other commits for examples. It's possible that for this pull request there will be only one commit.

Could you please add a link to the GitHub issue at the bottom of the commit message like in the other commits?

Could you please use your full name for the commit? One way to do this is to set the GIT_AUTHOR_NAME and GIT_COMMITTER_NAME environment variables.

Copy link
Member

@debarshiray debarshiray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still failing to build:

# github.com/containers/toolbox/cmd
cmd/utils.go:333:38: undefined: user
cmd/create.go:308:2: declared and not used: homeDir
cmd/create.go:309:2: declared and not used: resolvedPath
cmd/create.go:309:45: undefined: HomeDir
cmd/create.go:476:15: undefined: homeDirMountArg
cmd/run.go:445:17: assignment mismatch: 1 variable but user.Current returns 2 values

logrus.Errorf("Failed to get HOME directory: %v", err)
}
homeDir := user.HomeDir
resolvedPath, err := filepath.EvalSymlinks(HomeDir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be homeDir, not HomeDir. This is causing:

cmd/create.go:308:2: declared and not used: homeDir
cmd/create.go:309:45: undefined: HomeDir

@wazir-ahmed
Copy link

wazir-ahmed commented Jun 17, 2025

Hi @debarshiray, I started using toolbox few days back and ran into the same issue this PR is trying to fix.
This PR doesn't seem active. Is it okay if I raise a new PR addressing the comments you have given along with @sumantro93 initial commits?

@wazir-ahmed
Copy link

Could you please try to squash the commits into logical units that successfully build and pass the tests, instead of a series of fix-up commits?

Okay, I'm just reading this comment. I will squash all the changes in my new PR.

@debarshiray
Copy link
Member

debarshiray commented Jun 26, 2025

I started using toolbox few days back and ran into the same issue this PR is trying to fix. This PR doesn't seem active. Is it okay if I raise a new PR addressing the comments you have given along with @sumantro93 initial commits?

Hey! I apologize that I didn't respond earlier.

I started working on a branch to isolate the host's HOME from the system tests, and that can only be done by addressing this problem. So, I had to adopt this PR myself.

Are you looking for newcomer-friendly issues to work on? If so, please reach out to me via email and I can point you to some.

Once again, sorry for the late response; and thanks for stopping by and playing with Toolbx.

@debarshiray
Copy link
Member

Closing in favour of #1667

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants