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

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
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
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Other popular topics Top

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
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
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
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
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
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

We're in Beta

About us Mission Statement