phf

phf

Prevent Mix from fetching dependencies

Hi!

The objective is to prevent Mix from fetching dependencies and to rely solely on ERL_LIBS. The idea is that all dependencies are already available through ERL_LIBS, which have been added by Guix.

However, the issue arises when using mix compile. It attempts to fetch dependencies regardless of existing settings. Currently, no option prevents this behavior; it always tries and subsequently fails. A potential workaround is to patch mix.exs so that the project() function returns a key/value list with the deps key set to [].

For instance, in the Mix project named makeup, there isn’t a straightforward method to instruct mix to avoid fetching nimble_parsec, even when it’s already available in ERL_LIBS:

┌────
│ $ mix compile --no-deps-check
│ Could not find Hex, which is needed to build dependency :nimble_parsec
│ Shall I install Hex? (if running non-interactively, use "mix local.hex --force") [Yn] n
│ ** (Mix) Could not find an SCM for dependency :nimble_parsec from Makeup.Mixfile
└────

It’s evident from the IEx session below that nimble_parsec is
available:

┌────
│ $ iex 
│ Interactive Elixir (1.14.0) - press Ctrl+C to exit (type h() ENTER for help)
│ iex(1)> :code.which(NimbleParsec)
│ '/gnu/store/261qi8bmagns11d3ssiypbqj82i9k16g-profile/lib/elixir/1.14/nimble_parsec/ebin/Elixir.NimbleParsec.beam'
└────

So, the pressing question is: how can we configure mix to prioritize ERL_LIBS over fetching new dependencies?

Marked As Solved

phf

phf

If nimble_parsec package is built locally:

/tmp/guix-build-elixir-nimble-parsec-1.3.1.drv-4$ tree -L 5
.
├── _build
│   └── prod
│       └── lib
│           └── nimble_parsec
│               ├── consolidated
│               └── ebin
├── CHANGELOG.md
├── CHECKSUM
├── environment-variables
├── lib
│   ├── mix
│   │   └── tasks
│   │       └── nimble_parsec.compile.ex
│   ├── nimble_parsec
│   │   ├── compiler.ex
│   │   └── recorder.ex
│   └── nimble_parsec.ex
├── metadata.config
├── mix.exs
├── README.md
└── VERSION

and a symlink has been built in the source of the package makeup that depends on nimble_parsec like so:

/tmp/guix-build-elixir-makeup-1.1.0.drv-6$ tree _build/
_build/
└── prod
    └── lib
        └── nimble_parsec -> /tmp/guix-build-elixir-nimble-parsec-1.3.1.drv-4/_build/prod/lib/nimble_parsec

then mix does not fetch dependencies:

/tmp/guix-build-elixir-makeup-1.1.0.drv-6$ guix shell elixir -- bash -c 'MIX_ENV=prod mix compile --no-deps-check'
Compiling 44 files (.ex)
Generated makeup app

It suffices to generalize that idea for all dependencies of a given package.

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New

We're in Beta

About us Mission Statement