Closed gadams999 closed 2 years ago
Confirmed adding environment setting in the formula via brew edit
correctly builds and works.
def install
ENV["GOPROXY"]= "direct"
Dir.chdir("src") do
system("go build -o=oh-my-posh -ldflags=\"-X \'main.Version=5.9.0\'\"")
bin.install "oh-my-posh"
end
mv "themes", prefix
end
I'm not sure the correct Ruby syntax, but what about adding something like _if HOMEBREW_GOPROXY
passed in to brew install
, set a local GOPROXY env to that value, otherwise, don't set?_
I'm going to have a look tomorrow, been following along but have no experience in that regard + I'll need to check what homebrew advises in such events.
Sounds good. I wonder if this would work (unable to test right now):
ENV["GOPROXY"] = h.has_key?('HOMEBREW_GOPROXY') ? h['HOMEBREW_GOPROXY'] : ''
@JanDeDobbeleer Adding a support of using user-defined HOMEBREW_GOPROXY
env can make it friendly to users who don't have access to proxy.golang.org
:
ENV["GOPROXY"] = ENV.has_key?("HOMEBREW_GOPROXY") ? ENV["HOMEBREW_GOPROXY"] : ""
Tested and it worked correctly.
@lewis-yeung please create a PR! Lost track of this one.
@JanDeDobbeleer See #9.
Thank you @JanDeDobbeleer and Thanks to @gadams999 who has already given an almost correct solution. 😄
Hi,
Loving oh-my-posh! I've run into an issue that I think is related to how brew manages environment variables in general, but then related to golang.
I work in environments where
proxy.golang.org
is not available. In those situations I setgo env -w GOPROXY=direct
and can build local go apps (pulls are done via GitHub directly). It seems that brew doesn't use these settings during build as I get the follow errors (related to blocking the proxy):With my proxy set to direct:
I can get
oh-my-posh
to successfully build.I'm not familiar with brew's build process or best practices, but could an environment variable check be added to the formula to set
GOPROXY
if injected? E.g., something like:Then that value can set
GOPROXY
used by the build system? I haven't found any other examples so far for setting up go inside of a formula to modify proxy settings.If this a sound approach, I can test locally and submit a PR for review.