diff mbox series

go receipe not installing go.env

Message ID ebb78d96-4372-4df8-b891-a46ff8703724@advisoft.co.nz
State Not Applicable
Headers show
Series go receipe not installing go.env | expand

Commit Message

Phil Williams March 20, 2024, 12:17 a.m. UTC
I ran into this issue when using the toolchain compiled with buildroot: 
https://github.com/golang/go/issues/61928

Aparently the default GOPROXY configuration is now read from GOROOT/go.env.

I made the following change which fixed my issue:


I don't know enough about buildroot or go as to whether this would be 
useful for others.

If someone can confirm it is, I will following the procedure and 
properly submit a patch.

Thanks

Comments

Yann E. MORIN March 20, 2024, 7:55 a.m. UTC | #1
Phil, Al,

On 2024-03-20 13:17 +1300, Phil Williams spake thusly:
> I ran into this issue when using the toolchain compiled with buildroot:
> https://github.com/golang/go/issues/61928

FTR, the issue is go whinning about:

    GOPROXY list is not the empty string, but contains no entries

> Aparently the default GOPROXY configuration is now read from GOROOT/go.env.
> 
> I made the following change which fixed my issue:

Thanks for the suggestion, see below...

> diff --git a/package/go/go.mk b/package/go/go.mk
> index 9efd4a31..d031fd25 100644
> --- a/package/go/go.mk
> +++ b/package/go/go.mk
> @@ -153,6 +153,8 @@ define HOST_GO_INSTALL_CMDS
> 
>         cp -a $(@D)/lib $(HOST_GO_ROOT)/
> 
> +       cp -a $(@D)/go.env $(HOST_GO_ROOT)/

The default go.env as provided by go, contains:
    GOPROXY=https://proxy.golang.org,direct

This looks like this is going to firt try the https://proxy.golang.org
proxy, and fallback to direct download if missing on the proxy.

I don't think that is what we want. Instead, we want to keep the
existing behaviour:

  - when we download, we want to do a direct downlod without going
    through any proxy at all

  - when we build, we do not want to go and fetch anything, as we are
    supposed to have everything already vendored at download time.

However, as I read from https://github.com/golang/go/blob/master/go.env
setting GOPROXY in the environment should still be supported:

    # The environment overrides everything else.

And the upstream documentation still references it, with the values we
are currently using:

    https://go.dev/ref/mod#environment-variables

    Two keywords may be used in place of proxy URLs:

      * off: disallows downloading modules from any source.
      * direct: download directly from version control repositories instead
        of using a module proxy.

So we'd need a little bit more information about the actual issue:

  - what package do you get the issue with?
  - is it during download (vendoring), or during build?
  - can you share a reproducer?

Regards,
Yann E. MORIN.

>         mkdir -p $(HOST_GO_ROOT)/pkg
>         cp -a $(@D)/pkg/include $(HOST_GO_ROOT)/pkg/
>         cp -a $(@D)/pkg/tool $(HOST_GO_ROOT)/pkg/
> 
> I don't know enough about buildroot or go as to whether this would be useful
> for others.
> 
> If someone can confirm it is, I will following the procedure and properly
> submit a patch.
> 
> Thanks
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Phil Williams March 20, 2024, 10 a.m. UTC | #2
I had sourced the host/environment-setup and was using go to manually 
build something which had dependencies that needed to be downloaded.

On both Windows and Ubuntu GOROOT contains that go.env file, so I 
figured it probably should be the same here.

On 20/03/2024 8:55 pm, yann.morin@orange.com wrote:
> Phil, Al,
>
> On 2024-03-20 13:17 +1300, Phil Williams spake thusly:
>> I ran into this issue when using the toolchain compiled with buildroot:
>> https://github.com/golang/go/issues/61928
> FTR, the issue is go whinning about:
>
>      GOPROXY list is not the empty string, but contains no entries
>
>> Aparently the default GOPROXY configuration is now read from GOROOT/go.env.
>>
>> I made the following change which fixed my issue:
> Thanks for the suggestion, see below...
>
>> diff --git a/package/go/go.mk b/package/go/go.mk
>> index 9efd4a31..d031fd25 100644
>> --- a/package/go/go.mk
>> +++ b/package/go/go.mk
>> @@ -153,6 +153,8 @@ define HOST_GO_INSTALL_CMDS
>>
>>          cp -a $(@D)/lib $(HOST_GO_ROOT)/
>>
>> +       cp -a $(@D)/go.env $(HOST_GO_ROOT)/
> The default go.env as provided by go, contains:
>      GOPROXY=https://proxy.golang.org,direct
>
> This looks like this is going to firt try the https://proxy.golang.org
> proxy, and fallback to direct download if missing on the proxy.
>
> I don't think that is what we want. Instead, we want to keep the
> existing behaviour:
>
>    - when we download, we want to do a direct downlod without going
>      through any proxy at all
>
>    - when we build, we do not want to go and fetch anything, as we are
>      supposed to have everything already vendored at download time.
>
> However, as I read from https://github.com/golang/go/blob/master/go.env
> setting GOPROXY in the environment should still be supported:
>
>      # The environment overrides everything else.
>
> And the upstream documentation still references it, with the values we
> are currently using:
>
>      https://go.dev/ref/mod#environment-variables
>
>      Two keywords may be used in place of proxy URLs:
>
>        * off: disallows downloading modules from any source.
>        * direct: download directly from version control repositories instead
>          of using a module proxy.
>
> So we'd need a little bit more information about the actual issue:
>
>    - what package do you get the issue with?
>    - is it during download (vendoring), or during build?
>    - can you share a reproducer?
>
> Regards,
> Yann E. MORIN.
>
>>          mkdir -p $(HOST_GO_ROOT)/pkg
>>          cp -a $(@D)/pkg/include $(HOST_GO_ROOT)/pkg/
>>          cp -a $(@D)/pkg/tool $(HOST_GO_ROOT)/pkg/
>>
>> I don't know enough about buildroot or go as to whether this would be useful
>> for others.
>>
>> If someone can confirm it is, I will following the procedure and properly
>> submit a patch.
>>
>> Thanks
>>
>> _______________________________________________
>> buildroot mailing list
>> buildroot@buildroot.org
>> https://lists.buildroot.org/mailman/listinfo/buildroot
diff mbox series

Patch

diff --git a/package/go/go.mk b/package/go/go.mk
index 9efd4a31..d031fd25 100644
--- a/package/go/go.mk
+++ b/package/go/go.mk
@@ -153,6 +153,8 @@  define HOST_GO_INSTALL_CMDS

         cp -a $(@D)/lib $(HOST_GO_ROOT)/

+       cp -a $(@D)/go.env $(HOST_GO_ROOT)/
+
         mkdir -p $(HOST_GO_ROOT)/pkg
         cp -a $(@D)/pkg/include $(HOST_GO_ROOT)/pkg/
         cp -a $(@D)/pkg/tool $(HOST_GO_ROOT)/pkg/