erlef / rebar3_hex

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

Running rebar3 hex publish with git dependency results in Uncaught error: function_clause #222

Closed NicklasXYZ closed 3 years ago

NicklasXYZ commented 3 years ago

Hello, I hope someone can help :)

Specifying a git dependency in the rebar.config results in an error message that is not very understandable/user-friendly.

Environment

(base) [nicklasxyz@nicklasxyz test_package]$ rebar3 report rebar3 hex publish --version 0.1.0
Rebar3 report
 version 3.14.4
 generated at 2021-04-12T22:11:04+00:00
=================
Please submit this along with your issue at https://github.com/erlang/rebar3/issues (and feel free to edit out private information, if any)
-----------------
Task: rebar3hexpublish--version0.1.0
Entered as:
  rebar3hexpublish--version0.1.0
-----------------
Operating System: x86_64-unknown-linux-gnu
ERTS: Erlang/OTP 23 [erts-11.1.8] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [hipe]
Root Directory: /usr/lib/erlang
Library directory: /usr/lib/erlang/lib
-----------------
Loaded Applications:
bbmustache: 1.10.0
certifi: 2.5.3
cf: 0.3.1
common_test: 1.19.1
compiler: 7.6.6
crypto: 4.8.3
cth_readable: 1.5.0
dialyzer: 4.3
edoc: 0.12
erlware_commons: 1.4.0
eunit: 2.6
eunit_formatters: 0.5.0
getopt: 1.0.1
hipe: 4.0.1
inets: 7.3.1
kernel: 7.2
providers: 1.8.1
public_key: 1.9.2
relx: 4.3.0
sasl: 4.0.1
snmp: 5.7.3
ssl_verify_fun: 1.1.6
stdlib: 3.14
syntax_tools: 2.4
tools: 3.4.3

-----------------
Escript path: /usr/bin/rebar3
Providers:
  app_discovery as clean compile compile compile cover ct ct cut deps dialyzer do docs edoc escriptize eunit eunit get-deps help install install_deps key list lock new owner path pkgs publish release relup repo report repos retire revert search shell state tar tree unlock update upgrade upgrade upgrade user version xref 
...

Current behaviour

Describe the current behaviour. In case of a failure, crash, or exception, please include the result of running the command with debug information:

It seems like rebar3 just crashes without much useful information.

(base) [nicklasxyz@nicklasxyz test_package]$ DEBUG=1 rebar3 hex publish --version 0.1.0
===> Compile (apps)
===> 23.2.5 satisfies the requirement for minimum OTP version 18
===> Evaluating config script "/home/nicklasxyz/Desktop/git_repos/gleam_projects/test_package/_build/default/plugins/hex_core/rebar.config.script"
===> Compile (apps)
===> Expanded command sequence to be run: []
===> Running provider: do
===> Expanded command sequence to be run: [app_discovery,install_deps,lock,{hex,publish}]
===> Running provider: app_discovery
===> Found top-level apps: [test_package]
        using config: [{src_dirs,["gen/src","src"]},
                       {lib_dirs,["apps/*","lib/*","."]}]
===> Running provider: install_deps
===> Verifying dependencies...
===> Running provider: lock
===> Running provider: {hex,publish}
Publishing test_package 1.0.0 to hexpm
  Description: A Gleam project
  Dependencies:
    gleam_stdlib 0.14.0
  Included files:
    README.md
    gleam.toml
    rebar.config
    rebar.lock
    src/test_package.app.src
    src/test_package.gleam
  Licenses: Apache 2.0
  Links:

  Build tools: rebar3
Be aware, you are publishing to the public Hexpm repository.
Before publishing, please read Hex CoC: https://hex.pm/policies/codeofconduct
Proceed? ("Y")> y
===> Uncaught error in rebar_core. Run with DIAGNOSTIC=1 to see stacktrace or consult rebar3.crashdump
===> Uncaught error: function_clause
===> When submitting a bug report, please include the output of `rebar3 report "your command"

Expected behaviour

Error that git dependency can not be used with Hex.

NicklasXYZ commented 3 years ago

If it is any help, this is the rebar.config file I was using:

{erl_opts, [debug_info]}.
{src_dirs, ["src", "gen/src"]}.

{profiles, [
    {test, [{src_dirs, ["src", "test", "gen/src", "gen/test"]}]}
]}.

{project_plugins, [rebar_gleam, rebar3_hex]}.

{deps, [
    %% git dependencies
    {gleam_stdlib, "", {git, "git://github.com/gleam-lang/stdlib.git", {branch, "main"}}}
]}.
starbelly commented 3 years ago

@NicklasXYZ Thank you and that helps. As soon I get a few I will try to reproduce this. FWIW hex does allow there to be git deps, so I'm not sure if this problem is related to a git dep, but not sure it isn't completely unrelated either. What I am certain of and in agreement on, this is not helpful or friendly.

Can you tell me what version of rebar3_hex you are using? It may the problem you're encountering was fixed in a subsequent release...

NicklasXYZ commented 3 years ago

No git dep test example

Test example with no git dependency. Here I am at least prompted for a password and something gets published to hex: https://hex.pm/packages/test_package_nogit

In this example the rebar.config file contains:

{erl_opts, [debug_info]}.
{src_dirs, ["src", "gen/src"]}.

{profiles, [
    {test, [{src_dirs, ["src", "test", "gen/src", "gen/test"]}]}
]}.

{project_plugins, [rebar_gleam, rebar3_hex]}.

{deps, [
    {gleam_stdlib, "0.14.0"}
]}.

This is the output when I try to publish:

(base) [nicklasxyz@nicklasxyz test_rebar3_hex]$ rebar3 version
rebar 3.14.4 on Erlang/OTP 23 Erts 11.1.8
(base) [nicklasxyz@nicklasxyz test_rebar3_hex]$ gleam new test_package_nogit && cd test_package_nogit
* creating test_package_nogit/.gitignore
* creating test_package_nogit/.github/workflows/test.yml
* creating test_package_nogit/README.md
* creating test_package_nogit/gleam.toml
* creating test_package_nogit/rebar.config
* creating test_package_nogit/src/test_package_nogit.app.src
* creating test_package_nogit/src/test_package_nogit.gleam
* creating test_package_nogit/test/test_package_nogit_test.gleam

Your Gleam project "test_package_nogit" has been successfully created.
The rebar3 program can be used to compile and test it.

    cd test_package_nogit
    rebar3 eunit

(base) [nicklasxyz@nicklasxyz test_package_nogit]$ rebar3 hex publish
===> Fetching rebar_gleam v0.1.0
===> Analyzing applications...
===> Compiling rebar_gleam
===> Fetching rebar3_hex v6.11.2
===> Fetching hex_core v0.7.1
===> Fetching verl v1.0.2
===> Analyzing applications...
===> Compiling verl
===> Compiling hex_core
===> Compiling rebar3_hex
===> Verifying dependencies...
===> Fetching gleam_stdlib v0.14.0
Publishing test_package_nogit 1.0.0 to hexpm
  Description: A Gleam project
  Dependencies:
    gleam_stdlib 0.14.0
  Included files:
    README.md
    gleam.toml
    rebar.config
    rebar.lock
    src/test_package_nogit.app.src
    src/test_package_nogit.gleam
  Licenses: Apache 2.0
  Links:

  Build tools: rebar3
Be aware, you are publishing to the public Hexpm repository.
Before publishing, please read Hex CoC: https://hex.pm/policies/codeofconduct
Proceed? ("Y")> y
Local Password:                         
===> Published test_package_nogit 1.0.0 
===> No valid hex docs configuration found. Docs will will not be generated
===> Docs were not published since they couldn't be found in '/home/nicklasxyz/Desktop/test_rebar3_hex/test_package_nogit/doc'. Please build the docs and then run `rebar3 hex docs` to publish them.
(base) [nicklasxyz@nicklasxyz test_package_nogit]$

With git dep test example

In this example the error message occurs and I have added the following to the rebar.config file:

{erl_opts, [debug_info]}.
{src_dirs, ["src", "gen/src"]}.

{profiles, [
    {test, [{src_dirs, ["src", "test", "gen/src", "gen/test"]}]}
]}.

{project_plugins, [rebar_gleam, rebar3_hex]}.

{deps, [
    %% git dependencies
    {gleam_stdlib, "", {git, "git://github.com/gleam-lang/stdlib.git", {branch, "main"}}}
]}.

This is the output when I try to publish:

(base) [nicklasxyz@nicklasxyz test_rebar3_hex]$ rebar3 version
rebar 3.14.4 on Erlang/OTP 23 Erts 11.1.8
(base) [nicklasxyz@nicklasxyz test_rebar3_hex]$ gleam new test_package_withgit && cd test_package_withgit
* creating test_package_withgit/.gitignore
* creating test_package_withgit/.github/workflows/test.yml
* creating test_package_withgit/README.md
* creating test_package_withgit/gleam.toml
* creating test_package_withgit/rebar.config
* creating test_package_withgit/src/test_package_withgit.app.src
* creating test_package_withgit/src/test_package_withgit.gleam
* creating test_package_withgit/test/test_package_withgit_test.gleam

Your Gleam project "test_package_withgit" has been successfully created.
The rebar3 program can be used to compile and test it.

    cd test_package_withgit
    rebar3 eunit

(base) [nicklasxyz@nicklasxyz test_package_withgit]$ rebar3 hex publish
===> Fetching rebar3_hex v6.11.2
===> Fetching hex_core v0.7.1
===> Fetching verl v1.0.2
===> Analyzing applications...
===> Compiling verl
===> Compiling hex_core
===> Compiling rebar3_hex
===> Verifying dependencies...
===> Fetching gleam_stdlib (from {git,"git://github.com/gleam-lang/stdlib.git",
                        {branch,"main"}})
===> Uncaught error in rebar_core. Run with DIAGNOSTIC=1 to see stacktrace or consult rebar3.crashdump
===> When submitting a bug report, please include the output of `rebar3 report "your command"`
(base) [nicklasxyz@nicklasxyz test_package_withgit]$

The two projects directories can be found here: test_packages.zip

NicklasXYZ commented 3 years ago

These are the plugins (rebar3_hex included):

--- Local plugins ---
rebar_gleam (0.1.0)
rebar3_hex (6.11.2)
starbelly commented 3 years ago

I see the issue. A fix is on the way @NicklasXYZ .

NicklasXYZ commented 3 years ago

Awesome :+1:

starbelly commented 3 years ago

The good news is you'll get a friendly error message, the bad news is no, we don't allow publishing when the thing in question depends on a git dep, which now that my head is in the space again, makes perfect sense.

NicklasXYZ commented 3 years ago

Yeah, I figured that out in the end by reading through the docs a bit more closely, which yeah, makes sense. I kinda jumped head first into this whole ecosystem and I can imagine some one else might do the same. At least they will not have to wonder what they are doing wrong in this case now :+1:

starbelly commented 3 years ago

@NicklasXYZ I vastly you appreciate you opening this. UX is very important and it's something we're trying to get better at, one bug ticket at a time 😁

NicklasXYZ commented 3 years ago

You're welcome :)!

lpil commented 3 years ago

That was fast! Nice one @starbelly