rebar3
rebar3 copied to clipboard
`bootstrap --offline` uses https_proxy
Please excuse my ignorance about rebar3, I didn't package it myself for pkgsrc, I'm just reporting a build bug I noticed. We have a rebar3 package in pkgsrc for a couple years now, but recently we wanted to ensure that packages do not cause network traffic while building (the network traffic should happen in the 'fetch' phase) and set the https_proxy environment variable by default, to an invalid value.
In a recent build I noticed that rebar3 is now broken. The build log ends with:
Evaluating config script "/tmp/devel/rebar3/work/rebar3-3.23.0/_build/default/lib/rebar/src/rebar.app.src.script"
escript: exception throw: {error,{bad_option,https_proxy,
{{"downloads-forbidden-except-during-fetch",
[]},
[]}}}
in function httpc:bad_option/2 (httpc.erl, line 1383)
in call from httpc:validate_options/2 (httpc.erl, line 1217)
in call from httpc:validate_options/1 (httpc.erl, line 1203)
in call from httpc:set_options/2 (httpc.erl, line 386)
in call from rebar_utils:set_httpc_options/2 (apps/rebar/src/rebar_utils.erl, line 1004)
in call from rebar_utils:set_httpc_options/0 (apps/rebar/src/rebar_utils.erl, line 992)
in call from rebar3:init_config/0 (apps/rebar/src/rebar3.erl, line 224)
in call from rebar3:run/1 (apps/rebar/src/rebar3.erl, line 100)
*** Error code 127
The build runs ./bootstrap --offline which I would expect to not evaluate or use any proxies.
Can you please advise how to make the build phase not try to use any proxies?
setting the build to offline mode just avoids starting the HTTP libraries: https://github.com/erlang/rebar3/blob/b64d94f4e6fb738c4a3004faf833e0b9617d86a8/bootstrap#L15-L23
If no proxy values are set, it won't call the API and will be fine.
However, by setting the proxy values, the detection that happens at start time (outside of bootstrapping's script) tries to call it. At this point, the code attempts to configure the client proxy and I believe that because we never started the HTTP client (because of the offline option), the operation fails.
Basically, the error is a very unclear way of saying "you're trying to set a proxy on a client that doesn't exist" and that fails.
Ok, I'm not sure I can follow the logic here.
I can confirm that if I set http_proxy= https_proxy= in the bootstrap environment, it works.
I haven't verified if it tries to use the network in that case in any way or not.
Is that what you recommend?
IMHO, in offline mode, the proxy variables shouldn't cause any behaviour change at all.
Yeah avoiding the error would require making sure that the code in https://github.com/erlang/rebar3/blob/b64d94f4e6fb738c4a3004faf833e0b9617d86a8/apps/rebar/src/rebar_utils.erl#L991-L1028 does not attempt to configure the proxy when REBAR_OFFLINE is set to "1" to avoid trying to configure an HTTP client that was never started.