Closed fenollp closed 4 years ago
Actually other config commands also fail:
DEBUG=1 rebar3 hex config key
===> Evaluating config script "rebar.config.script"
===> Load global config file /home/pete/.config/rebar3/rebar.config
===> 22.0.1 satisfies the requirement for minimum OTP version 18
===> Expanded command sequence to be run: []
===> Provider: {default,do}
===> Expanded command sequence to be run: []
===> Command config not found in namespace hex
This is from https://github.com/zotonic/hexpub
I tried clearing ~/.cache/rebar3 no to avail.
All this seems related to a bad / corrupted install over the years.
My actual issue is publishing in CI. It seems the old trick of
{
echo '{username,<<"'${HEX_USERNAME}'">>}.'
echo '{key,<<"'${HEX_KEY}'">>}.'
} >~/.hex/hex.config
and rebar3 hex publish <<<y
isn't cutting it anymore: it complains about a missing write key.
Turns out if I add all the contents of a "working" hex.config file (including a tuple tagged '$write_key'
) it still doesn't work.
So I'm resorting to the call
rebar3 hex user auth
however I can't get that command to read username & passwords from STDIN:
[{binary,split,[eof,<<"\n">>],[]},
{rebar3_hex_io,get_password,1,
[{file,"/root/.cache/rebar3/plugins/rebar3_hex/src/rebar3_hex_io.erl"},
{line,69}]},
{rebar3_hex_user,auth,2,
[{file,"/root/.cache/rebar3/plugins/rebar3_hex/src/rebar3_hex_user.erl"},
{line,134}]},
{rebar_core,do,2,
[{file,"/usr/src/rebar3-src/src/rebar_core.erl"},{line,154}]},
{rebar_prv_do,do_task,5,
[{file,"/usr/src/rebar3-src/src/rebar_prv_do.erl"},{line,87}]},
{rebar_core,do,2,
[{file,"/usr/src/rebar3-src/src/rebar_core.erl"},{line,154}]},
{rebar3,run_aux,2,[{file,"/usr/src/rebar3-src/src/rebar3.erl"},{line,182}]},
{rebar3,main,1,[{file,"/usr/src/rebar3-src/src/rebar3.erl"},{line,66}]}]
@fenollp Hi, yeah AFAIK config
was never implemented, but should be and will open an issue for that. However, let's see if we can't get you past your initial issue which is generating a key to so you can publish in CI. At the moment there's a few bug fixes that need to be released in regards to keys and we will get that out as soon as possible, for the moment I recommend logging into hex.pm (or your private instance) and generating a key there. Copy the key into your CI config (assuming you can pull in variables into your CI env). From there you can simply specify the key in an env var vs setting up a hex config file.
Example:
env HEX_API_KEY=$MY_API_KEY_VAR rebar3 hex publish -r myrepo
===> Verifying dependencies...
Publishing truecoat 0.4.1 to hexpm
Description: It gets installed at the factory
Dependencies:
...
===> Published truecoat 0.4.1
===> Published docs for truecoat 0.4.1
Note the -r switch is only needed if you have multiple repos. If it's only hexpm then the -r
switch is not needed.
Does this help?
Hi! Thanks for the thorough explanation.
I'm using the public hex.pm repo. I generated a key by checking all the boxes at https://hex.pm/dashboard/keys and defining a CI secret HEX_API_KEY
with the key.
But this is still failing:
https://github.com/fenollp/otp_vsn/runs/599296685?check_suite_focus=true
===> No write key found for user. Be sure to authenticate first with: rebar3 hex user auth
And I'm having issues running that command in CI.
But then again I should only be needing the generated key, right?
That is correct, all you should need is the generated key. Makes me think the generated key is not in your env... if I do :
env HEX_API_KEY= rebar3 hex publish
then I get the error you are encountering.
I know for myself with github ci I have to access set env vars in my workflow per https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
Hell I did not think of that. Thanks!
This is still somehow failing (with the same message): https://github.com/fenollp/otp_vsn/runs/599824172?check_suite_focus=true
This time I generated a key by checking only the "API" checkbox (which also checks Read & Write) and not the second checkbox.
Thank you for your patience :)
@fenollp No worries :) Yeah, it still seems like the key is not defined. Can you try testing this outside of CI?
@fenollp Also, as I mentioned to someone else in another issue... I would be remiss if I didn't say that publishing in this way is discouraged by both hex and rebar team. This has been available in hex for a while and recently added to rebar3_hex but this is mostly because people were automating publishing anyway. See #126 for more context. 🙇
@fenollp Did you ever test this outside of CI?
@fenollp Closing this issue as stale, but feel free to re-open if need be.
I'm trying to generate a key (to use in CI) but following the readme I get
Note: on https://www.rebar3.org/docs/hex-package-management the first command doesn't seem to exist:
Also when
cut
-ting a release I have a crash:Report