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

feat: add GNOROOT environment variables #1014

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion gnovm/cmd/gno/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,16 @@ func fmtDuration(d time.Duration) string {
}

func guessRootDir() string {
// try to get the root directory from the GNOROOT environment variable.
if rootdir := os.Getenv("GNOROOT"); rootdir != "" {
return filepath.Clean(rootdir)
}

// if GNOROOT is not set, try to guess the root directory using the `go list` command.
cmd := exec.Command("go", "list", "-m", "-mod=mod", "-f", "{{.Dir}}", "github.com/gnolang/gno")
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatal("can't guess --root-dir, please fill it manually.")
log.Fatal("can't guess --root-dir, please fill it manually or define the GNOROOT environment variable globally.")
}
rootDir := strings.TrimSpace(string(out))
return rootDir
Comment on lines +113 to 120
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// if GNOROOT is not set, try to guess the root directory using the `go list` command.
cmd := exec.Command("go", "list", "-m", "-mod=mod", "-f", "{{.Dir}}", "github.com/gnolang/gno")
out, err := cmd.CombinedOutput()
if err != nil {
log.Fatal("can't guess --root-dir, please fill it manually.")
log.Fatal("can't guess --root-dir, please fill it manually or define the GNOROOT environment variable globally.")
}
rootDir := strings.TrimSpace(string(out))
return rootDir

I really want to get rid of this part.

Either use --rootdir or set GNOROOT. no guessing anymore :)

this will affect many commands/functionalities. Since it's a breaking change. If we all agree on this, it can be done in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

I suggest opening up a separate PR for this change as it has ramifications for existing user functionality

Expand Down
Loading