Closed d-led closed 1 year ago
@d-led , thanks for very for the PR. I think this is best added to cldr_utils since that provides HTTP support for the Cldr family. I'll leave this PR open until I make the change in cldr_utils
and will close this PR then.
Thanks for the contribution, greatly appreciated.
I've published cldr_utils version 2.23.0 that incorporates your PR. Would you consider mix deps.update cldr_utils
and confirming it operates as you expect?
I have also added a commit that adds :http_proxy
as a valid configuration key in config.exs
under the :ex_cldr
key.
Makes sense. Thx. Will do now
@kipcole9 the upgraded cldr_utils
fix the problem (in the docker/kaniko build with https_proxy
set). Thanks!
getting a strange build in local docker without proxy. gotta follow up:
#0 0.566 --== Compiling ==--
#0 1.937 Compiling 21 files (.ex)
#0 2.577
#0 2.577 == Compilation error in file lib/my_module/cldr.ex ==
#0 2.577 ** (FunctionClauseError) no function clause matching in String.to_charlist/1
#0 2.577
#0 2.577 The following arguments were given to String.to_charlist/1:
#0 2.577
#0 2.577 # 1
#0 2.577 nil
#0 2.577
#0 2.577 Attempted function clauses (showing 1 out of 1):
#0 2.577
#0 2.577 def to_charlist(+string+) when -is_binary(string)-
#0 2.577
#0 2.577 (elixir 1.14.4) lib/string.ex:2530: String.to_charlist/1
#0 2.577 (cldr_utils 2.23.0) lib/cldr/http/http.ex:271: Cldr.Http.get_with_headers/2
#0 2.577 (cldr_utils 2.23.0) lib/cldr/http/http.ex:120: Cldr.Http.get/2
#0 2.577 (ex_cldr 2.37.0) lib/cldr/install.ex:104: Cldr.Install.do_install_locale_name/3
#0 2.577 (elixir 1.14.4) lib/enum.ex:975: Enum."-each/2-lists^foreach/1-0-"/2
#0 2.577 (ex_cldr 2.37.0) lib/cldr/install.ex:29: Cldr.Install.install_known_locale_names/1
#0 2.577 (ex_cldr 2.37.0) lib/cldr.ex:82: Cldr.install_locales/1
#0 2.577 (ex_cldr 2.37.0) expanding macro: Cldr.Backend.Compiler.__before_compile__/1
no such error on mix compile
or mix phx.server
.
I seem to be unable to pin the problem down. Both environment variables are not set in the docker build. Why does the http.ex:271
case match at all 🤔 ?
↓
the env var was set to whitespace somehow. Not a fault in cldr_utils
upd: HTTPS_PROXY
seems to be set to whitespace in my local docker setup somehow, thus causing esbuild proxy logic to fail too. I think, the PR can be closed.
Thanks @d-led, I'll close the PR. And make the code more resilient to invalid HTTP_PROXY env vars in cldr_utils. Thanks for your patience.
I've published cldr_utils version 2.23.1 that makes Cldr.Http.get/2
resilient in the face of invalid https proxy URLs. Hopefully that gets you back in business. If the proxy URL is invalid then that fact is logged and to request continues without the proxy being set (and therefore possibly still failing).
superb. Thanks!
For posterity: the combination that didn't work:
Dockerfile:
ARG HTTPS_PROXY=
ENV HTTPS_PROXY=${HTTPS_PROXY}
ENV https_proxy=${HTTPS_PROXY}
#...
RUN ./build_release.sh
build_release.sh:
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
//...
mix.compile
for some reason, the variables seem to be set, although empty, causing System.get_env("HTTPS_PROXY")
not to return nil
but an empty string (needs follow up in erlang, I think).
Fixed the build script with the following:
if [[ "$HTTPS_PROXY" = "" ]]; then unset HTTPS_PROXY; fi
Problem
During a CI build behind a proxy (no auth parameters, just
HTTPS_PROXY
set, getting dependencies works, however building cldr fails with:as httpc options are not set in
Cldr.Install.install_locale_name
Solution
httpc
, another mechanism might be preferable