Elixir: .formatter.exs `import_deps` does not work for git dependencies

Created on 9 Feb 2018  路  4Comments  路  Source: elixir-lang/elixir

Environment

  • Elixir & Erlang versions (elixir --version):

    Erlang/OTP 20 [erts-9.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]                    
    Elixir 1.6.1 (compiled with OTP 20)
    
  • Operating system: Linux (Fedora 26)

Current behavior

When I try to run mix format with an import_deps containing a Git dependency, it fails:

** (Mix) Unknown dependency :mock_uart given to :import_deps in the formatter configuration. The dependency is not listed in your mix.exs file

In my mix.exs, I have:

{:mock_uart, git: "http://<some_internal_address>/mock_uart.git", tag: "v0.1.0", only: :test}

Expected behavior

mix format should work as with Hex dependencies.

Mix Bug Intermediate

Most helpful comment

Just too double check. Does it also happen after you run mix deps.get?

Yes, I鈥檝e even run mix deps.clean --all, then mix deps.get to be sure.

All 4 comments

Just too double check. Does it also happen after you run mix deps.get?

Just too double check. Does it also happen after you run mix deps.get?

Yes, I鈥檝e even run mix deps.clean --all, then mix deps.get to be sure.

I wasn't able to reproduce this on Elixir master with {:ecto, github: "elixir-ecto/ecto"}.

I think the problem is that your dependency has only: :test which means it's not available in the default :dev environment which is used when doing mix format. I think if you change the dep to be only: [:dev, :test] it should work.

Good catch @wojtekmach. I will include the environment in the error message.

Was this page helpful?
0 / 5 - 0 ratings