-
Notifications
You must be signed in to change notification settings - Fork 397
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
Conversation
Thank you for your first contribution! Your PR is related to #682. I recommend discussing with the @harry-hov, the other contributor to merge your changes efficiently. You can propose a plan for merging PRs, their order, or cherry-picking specific changes. I'll assign each other as reviewers for better collaboration. |
5ee8d28
to
367d715
Compare
Adds the ability to obtain the root directory from the GNOROOT environment variable. If this variable is not set, the root directory is then guessed using the go list command. Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
367d715
to
844d58c
Compare
// 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution 🙏
Looks good 🚀
Let's make sure To help developers, we must provide detailed documentation for all environment variables, default values/behaviors. And to keep things clear and manageable, we should limit the number of environment variables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll merge the changes now.
Before updating the documentation, let's wait for the new behavior by @harry-hov. It won't expect GNOROOT
to have an examples folder anymore. Instead, it'll use a folder with cached packages, which will download missing dependencies and could get automatically filled when installing the gno
binary or running it for the first time.
This small PR adds the ability to obtain the root directory from the
GNOROOT
environment variable. If this variable is not set, the root directory is then guessed using thego list
command.This enable the user to manually set gno root dir globally and not bother setting the
root-dir
parameter every time he need need itContributors' checklist...
BREAKING CHANGE: xxx
message was included in the description