erlef / rebar3_hex

Rebar3 Hex library
Apache License 2.0
101 stars 49 forks source link

Hex publish issue #50

Closed saleyn closed 8 years ago

saleyn commented 8 years ago

I am getting the following error when trying to publish a hex package:

$ rebar3 --version
rebar 3.0.0-beta.4+build.3432.ref9fe6588 on Erlang/OTP 18 Erts 7.1

$ rebar3 hex publish
Publishing erlexec 1.1.3
  Dependencies:

  Excluded dependencies (not part of the Hex package):

  Included files:
    /home/serge/projects/erl-libs/erlexec/src/edoc.css
    /home/serge/projects/erl-libs/erlexec/src/erlexec.app.src
    /home/serge/projects/erl-libs/erlexec/src/exec.erl
    /home/serge/projects/erl-libs/erlexec/src/exec_app.erl
    /home/serge/projects/erl-libs/erlexec/src/overview.edoc
    /home/serge/projects/erl-libs/erlexec/c_src/ei++.cpp
    /home/serge/projects/erl-libs/erlexec/c_src/ei++.hpp
    /home/serge/projects/erl-libs/erlexec/c_src/exec.cpp
    /home/serge/projects/erl-libs/erlexec/include/exec.hrl
    /home/serge/projects/erl-libs/erlexec/rebar.config.script
    /home/serge/projects/erl-libs/erlexec/rebar.config
    /home/serge/projects/erl-libs/erlexec/rebar.lock
    /home/serge/projects/erl-libs/erlexec/README.md
    /home/serge/projects/erl-libs/erlexec/LICENSE
Before publishing, please read Hex CoC: https://hex.pm/docs/codeofconduct
Proceed? ("Y")> y
escript: exception error: no function clause matching 
                 rebar3_hex_pkg:errors_to_string(#{<<"requirements">> => <<"expected type list(map)">>}) (/home/serge/.cache/rebar3/plugins/rebar3_hex/src/rebar3_hex_pkg.erl, line 192)
  in function  rebar3_hex_pkg:format_error/1 (/home/serge/.cache/rebar3/plugins/rebar3_hex/src/rebar3_hex_pkg.erl, line 54)
  in call from rebar3:handle_error/1 (/home/serge/tmp/archlinux/build/mqt-erl-sw/src/rebar3/_build/default/lib/rebar/src/rebar3.erl, line 267)
  in call from escript:run/2 (escript.erl, line 757)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_it/1 
  in call from init:start_em/1$ rebar3 hex publish
Publishing erlexec 1.1.3
  Dependencies:

  Excluded dependencies (not part of the Hex package):

  Included files:
    /home/serge/projects/erl-libs/erlexec/src/edoc.css
    /home/serge/projects/erl-libs/erlexec/src/erlexec.app.src
    /home/serge/projects/erl-libs/erlexec/src/exec.erl
    /home/serge/projects/erl-libs/erlexec/src/exec_app.erl
    /home/serge/projects/erl-libs/erlexec/src/overview.edoc
    /home/serge/projects/erl-libs/erlexec/c_src/ei++.cpp
    /home/serge/projects/erl-libs/erlexec/c_src/ei++.hpp
    /home/serge/projects/erl-libs/erlexec/c_src/exec.cpp
    /home/serge/projects/erl-libs/erlexec/include/exec.hrl
    /home/serge/projects/erl-libs/erlexec/rebar.config.script
    /home/serge/projects/erl-libs/erlexec/rebar.config
    /home/serge/projects/erl-libs/erlexec/rebar.lock
    /home/serge/projects/erl-libs/erlexec/README.md
    /home/serge/projects/erl-libs/erlexec/LICENSE
Before publishing, please read Hex CoC: https://hex.pm/docs/codeofconduct
Proceed? ("Y")> y
escript: exception error: no function clause matching 
                 rebar3_hex_pkg:errors_to_string(#{<<"requirements">> => <<"expected type list(map)">>}) (/home/serge/.cache/rebar3/plugins/rebar3_hex/src/rebar3_hex_pkg.erl, line 192)
  in function  rebar3_hex_pkg:format_error/1 (/home/serge/.cache/rebar3/plugins/rebar3_hex/src/rebar3_hex_pkg.erl, line 54)
  in call from rebar3:handle_error/1 (/home/serge/tmp/archlinux/build/mqt-erl-sw/src/rebar3/_build/default/lib/rebar/src/rebar3.erl, line 267)
  in call from escript:run/2 (escript.erl, line 757)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_it/1 
  in call from init:start_em/1

What is the cause of it? The "requirements" clause doesn't seem to be well documented here. Could you make this error report more "user-friendly"?

tsloughter commented 8 years ago

Can you upgrade to the latest rebar3 (3.1.1) and rebar3_hex plugin (2.5.1) and try again? This should be fixed.

saleyn commented 8 years ago

How do you determine the version of a local rebar3_hex? The path ~/.cache/rebar3/plugins/rebar3_hex doesn't seem to have git history.

tsloughter commented 8 years ago

Right, it isn't a git repo. I see that rebar3 plugins list does not include the versions... that is something we need to change in rebar3. For now you have to look in ~/.cache/rebar3/plugins/rebar3_hex/ebin/rebar3_hex.app

saleyn commented 8 years ago

Yes, that was a version issue. Removed ~/.cache/rebar3/plugins/, rebuilt rebar3, and the issue went away.

tsloughter commented 8 years ago

You can also upgrade global plugins without removing them by doing rebar3 as global plugins upgrade

saleyn commented 8 years ago

Thanks for the tip.

uwiger commented 8 years ago

I'm seeing the same type of error, using OTP 19.0, rebar3 vs 3.2.0 and rebar3_hex_plugin vsn 2.5.1:

uwpro:plain_fsm uwiger$ rebar3 hex publish
===> Fetching rebar3_hex ({pkg,<<"rebar3_hex">>,<<"2.5.1">>})
===> Downloaded package, caching at /Users/uwiger/.cache/rebar3/hex/default/packages/rebar3_hex-2.5.1.tar
===> Compiling rebar3_hex
===> Verifying dependencies...
Publishing plain_fsm 1.1
  Description: Plain_fsm library
  Dependencies:

  Included files:
    /Users/uwiger/uw/me/plain_fsm/LICENSE
    /Users/uwiger/uw/me/plain_fsm/NOTICE
    /Users/uwiger/uw/me/plain_fsm/README.md
    /Users/uwiger/uw/me/plain_fsm/include/plain_fsm.hrl
    /Users/uwiger/uw/me/plain_fsm/rebar.config
    /Users/uwiger/uw/me/plain_fsm/rebar.lock
    /Users/uwiger/uw/me/plain_fsm/src/fsm_example.erl
    /Users/uwiger/uw/me/plain_fsm/src/plain_fsm.app.src
    /Users/uwiger/uw/me/plain_fsm/src/plain_fsm.erl
    /Users/uwiger/uw/me/plain_fsm/src/plain_fsm_xform.erl
  Maintainers:
    Ulf Wiger
  Licenses: Apache 2.0
  Links:
    Github: https://github.com/uwiger/plain_fsm
  Build tools: rebar3
Before publishing, please read Hex CoC: https://hex.pm/docs/codeofconduct
Proceed? ("Y")> Y
escript: exception error: no function clause matching 
                 rebar3_hex_pkg:errors_to_string(#{<<"version">> => <<"expected type Elixir.HexWeb.Version">>}) (/Users/uwiger/.cache/rebar3/plugins/rebar3_hex/src/rebar3_hex_pkg.erl, line 220)
  in function  rebar3_hex_pkg:format_error/1 (/Users/uwiger/.cache/rebar3/plugins/rebar3_hex/src/rebar3_hex_pkg.erl, line 59)
  in call from rebar3:handle_error/1 (/Users/uwiger/git/rebar3/_build/default/lib/rebar/src/rebar3.erl, line 280)
  in call from escript:run/2 (escript.erl, line 757)
  in call from escript:start/1 (escript.erl, line 277)
  in call from init:start_em/1 
  in call from init:do_boot/3 
uwpro:plain_fsm uwiger$ rebar3 version
rebar 3.2.0 on Erlang/OTP 19 Erts 8.0
tsloughter commented 8 years ago

@uwiger that is a different error, i've not seen that issue before. Seems the Hex backend can't parse the version.

@ericmj ?

ericmj commented 8 years ago

The version is "1.1". It should follow semver and be "1.1.0".

uwiger commented 8 years ago

Ouch! That's harsh! ;-) The error indication from the plugin could perhaps be improved, but I'll be sure to fix the version. Thanks.

tsloughter commented 8 years ago

Yea, I need it to handle that error and print a proper error message to the user. Thanks

uwiger commented 8 years ago

Another problem (didn't think of it at first): 1.1 wasn't the latest version!

uwpro:plain_fsm uwiger$ git describe --abbrev
1.4

How is the version determined?

uwiger commented 8 years ago

Hmm, n.m., I think I may have messed up there...

uwiger commented 8 years ago

Aargh! The confusing part was:

uwpro:plain_fsm uwiger$ rm -rf _build
uwpro:plain_fsm uwiger$ rebar3 compile
===> Verifying dependencies...
===> Compiling plain_fsm
uwpro:plain_fsm uwiger$ grep vsn _build/default/lib/plain_fsm/ebin/plain_fsm.app 
              {vsn,"1.4.0"},
uwpro:plain_fsm uwiger$ rebar3 hex publish
===> Verifying dependencies...
Publishing plain_fsm 1.1
  Description: Plain_fsm library
...
uwpro:plain_fsm uwiger$ git log --oneline --no-walk --tags --decorate
972e8ab (HEAD, tag: 1.4.0, tag: 1.4, origin/uw-appsrc-vsn, uw-appsrc-vsn) change hard-coded vsn in .app.src
7777f30 (tag: 1.3) Merge pull request #11 from uwiger/uw-doc-profile
d2d0c30 (tag: 1.2) Merge pull request #10 from uwiger/uw-hex-attributes
57cd15a (tag: 1.1, origin/uw-cleanup-and-copyright, uw-cleanup-and-copyright) ws cleanup + copyright fix
7c1d0bc (tag: 1.0) added virtual function, plain_fsm:current_function()

So where did the "1.1" version come from? It was (wrongly) hard-coded in the old .app.src, and there happened to be an old plain_fsm/ebin/plain_fsm.app on the local disk, built using rebar 2 earlier. Apparently, the hex publish picked that up, even though rebar3 compile managed to sort it out. I recall the warnings about unpredictable consequences of having a top level ebin when using rebar3...

Removing the local ebin/ fixed the problem and (using semver versioning) publish worked.