Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Include $PROJECT/bin in $PATH for gb generate #686

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pritambaral
Copy link

@pritambaral pritambaral commented Jan 16, 2017

Projects may want to use binaries in $PROJECT/bin in //go:generate

Closes #630

@pritambaral pritambaral force-pushed the patch-1 branch 2 times, most recently from 06c44d8 to 8bb15ce Compare January 16, 2017 02:24
@@ -29,6 +29,7 @@ See 'go help generate'.
Run: func(ctx *gb.Context, args []string) error {
env := cmd.MergeEnv(os.Environ(), map[string]string{
"GOPATH": fmt.Sprintf("%s%c%s", ctx.Projectdir(), filepath.ListSeparator, filepath.Join(ctx.Projectdir(), "vendor")),
"PATH": fmt.Sprintf("%s%c%s", filepath.Join(ctx.Projectdir(), "bin"), filepath.ListSeparator, os.Environ["PATH"]),
Copy link
Contributor

Choose a reason for hiding this comment

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

os.Environ returns a []string not a map, you should try os.Getenv("PATH") instead.

Please move the $PROJECT/bin to the end of the search path.

Thanks and sorry for the long review delay.

Copy link
Author

Choose a reason for hiding this comment

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

If $PROJECT/bin is at the end of the path, then a non-project installation (of say, a tool like msgp) would override a project-specific installation. I thought it would go well with the project-centric approach of gb to prefer the latter over the former.

Projects may want to use binaries in $PROJECT/bin in `//go:generate`

Closes constabulary#630
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants