I am trying to understand Elixir better following problems with caching deps
directory in my GitLab CI pipeline.
-
mix deps.get
fetches dependencies and puts them in thedeps
directory -
mix deps.compile
compiles the dependencies by creating files in both the_build
directory and thedeps
directory (deps/<DEPENDENCY>/_build
anddeps/<DEPENDENCY>/ebin/*.beam
)
Example:
$ rm -r deps/
$ rm -r _build/
$ mix deps.get
Resolving Hex dependencies...
Resolution completed in 0.476s
Unchanged:
[…]
ranch 1.8.0
[…]
* […]
* Getting ranch (Hex package)
* […]
You have added/upgraded packages you could sponsor, run `mix hex.sponsor` to learn more
$ tree -a deps/ranch/
deps/ranch/
├── .fetch
├── .hex
├── LICENSE
├── Makefile
├── README.asciidoc
├── ebin
│ └── ranch.app
├── erlang.mk
├── hex_metadata.config
└── src
├── ranch.erl
├── ranch_acceptor.erl
├── ranch_acceptors_sup.erl
├── ranch_app.erl
├── ranch_conns_sup.erl
├── ranch_crc32c.erl
├── ranch_listener_sup.erl
├── ranch_protocol.erl
├── ranch_proxy_header.erl
├── ranch_server.erl
├── ranch_ssl.erl
├── ranch_sup.erl
├── ranch_tcp.erl
└── ranch_transport.erl
2 directories, 22 files
$ mix deps.compile ranch
===> Analyzing applications...
===> Compiling ranch
$ tree -a deps/ranch/
deps/ranch/
├── .fetch
├── .hex
├── LICENSE
├── Makefile
├── README.asciidoc
├── _build
│ └── prod
│ └── lib
│ └── .rebar3
│ └── rebar_compiler_erl
│ └── source.dag
├── ebin
│ ├── ranch.app
│ ├── ranch.beam
│ ├── ranch_acceptor.beam
│ ├── ranch_acceptors_sup.beam
│ ├── ranch_app.beam
│ ├── ranch_conns_sup.beam
│ ├── ranch_crc32c.beam
│ ├── ranch_listener_sup.beam
│ ├── ranch_protocol.beam
│ ├── ranch_proxy_header.beam
│ ├── ranch_server.beam
│ ├── ranch_ssl.beam
│ ├── ranch_sup.beam
│ ├── ranch_tcp.beam
│ └── ranch_transport.beam
├── erlang.mk
├── hex_metadata.config
└── src
├── ranch.erl
├── ranch_acceptor.erl
├── ranch_acceptors_sup.erl
├── ranch_app.erl
├── ranch_conns_sup.erl
├── ranch_crc32c.erl
├── ranch_listener_sup.erl
├── ranch_protocol.erl
├── ranch_proxy_header.erl
├── ranch_server.erl
├── ranch_ssl.erl
├── ranch_sup.erl
├── ranch_tcp.erl
└── ranch_transport.erl
7 directories, 37 files
$ tree -a _build/dev/lib/ranch/
_build/dev/lib/ranch/
├── .mix
│ └── compile.fetch
├── ebin -> ../../../../deps/ranch/ebin
└── mix.rebar.config
2 directories, 2 files
Why is not mix deps.compile
limiting itself to create files in the _build
directory? After all the _build
directory is named so for a reason.
I am sure there is a good reason for that. I am just trying to understand the rational.