rebar3 icon indicating copy to clipboard operation
rebar3 copied to clipboard

Failed to fetch and copy dep (git not installed)

Open grahamrhay opened this issue 2 years ago • 2 comments

Current behaviour

I started a new project, following this. Adding a dep on cowboy worked fine, but when I added a source dependency, I got this:

===> Verifying dependencies...
===> Fetching cowboy v2.9.0
===> Fetching jsonformat (from {git,"[email protected]:kivra/jsonformat.git"})
===> Failed to fetch and copy dep: {git,"[email protected]:kivra/jsonformat.git"}
The command '/bin/sh -c rebar3 get-deps' returned a non-zero code: 1

After a lot of flailing, I realised git wasn't installed, and I needed this in my dockerfile:

RUN apk add --no-cache git

Expected behaviour

Would it be possible to return some more useful error, e.g. "no git binary found"? (there doesn't seem to be a verbose flag for get-deps)

grahamrhay avatar Jun 10 '22 14:06 grahamrhay

you might have gotten more details if you ran it with 'DEBUG=1 rebar3 get-deps' which would have returned the failing command and the output of the failing command, which would have revealed the issue:

===> sh(git ...)
failed with return code 127 and the following output:
sh: line 1: exec: git: not found

That's generally the way to get more information within rebar3, though I realize it's not super discoverable.

ferd avatar Jun 10 '22 14:06 ferd

Step 7/12 : RUN DEBUG=1 rebar3 as prod release
 ---> Running in 2d66257b28f3
===> Expanded command sequence to be run: [as]
===> Running provider: as
===> Expanded command sequence to be run: [app_discovery,install_deps,lock,compile,release]
===> Running provider: app_discovery
===> Found top-level apps: [log_json]
	using config: [{src_dirs,["src"]},{lib_dirs,["apps/*","lib/*","."]}]
===> Running provider: install_deps
===> Verifying dependencies...
===> Getting definition for package cowboy from repo hexpm (#{api_url => <<"https://hex.pm/api">>,name => <<"hexpm">>,
         repo_name => <<"hexpm">>,repo_organization => undefined,
         repo_url => <<"https://repo.hex.pm">>,repo_verify => true,
         repo_verify_origin => true})
===> Fetching cowboy v2.9.0
===> Making request to get package cowboy from repo hexpm
===> Downloaded package cowboy, caching at /root/.cache/rebar3/hex/hexpm/packages/cowboy-2.9.0.tar
===> Writing {pkg,<<"cowboy">>,<<"2.9.0">>,
                  <<"865DD8B6607E14CF03282E10E934023A1BD8BE6F6BACF921A7E2A96D800CD452">>,
                  <<"2C729F934B4E1AA149AFF882F57C6372C15399A20D54F65C8D67BEF583021BDE">>,
                  #{api_url => <<"https://hex.pm/api">>,name => <<"hexpm">>,
                    repo_name => <<"hexpm">>,repo_organization => undefined,
                    repo_url => <<"https://repo.hex.pm">>,repo_verify => true,
                    repo_verify_origin => true}} to cache at /root/.cache/rebar3/hex/hexpm/packages/cowboy-2.9.0.tar
===> Linking _build/default/lib/cowboy to _build/prod/lib/cowboy
===> Fetching jsonformat (from {git,"https://github.com/kivra/jsonformat.git",
                      {tag,"v2.4.1"}})
===> sh(git --version)
failed with return code 127 and the following output:
sh: exec: line 1: git: not found

yes, that would have been extremely useful :)

grahamrhay avatar Jun 10 '22 15:06 grahamrhay