skwidbreth

skwidbreth

When I’m working on a mix app, I’ve noticed that changes that I make to code in my app’s dependencies are observable in the dev environment after recompiling the dep, but not in the test environment. Is this an intentional part of mix’s design? If so, is there a mix-based workaround?

Here’s an example scenario… I’m working on an app, doing some basic red-to-green testing. I’m having trouble debugging my app’s integration with one of its dependencies, and want to throw some IO.inspects into the dep to help me debug. I add the debug code, recompile the dependency, and run the tests again, but the code I’ve added has no effect. However, if I remove the directory at _build/test/lib/my_dep and run the tests again, the changes are present.

Steps to replicate:

  • get a dependency with mix deps.get my_dep
  • compile the dependency with mix deps.compile my_dep

At this point, a compiled version of the dependency will appear at my_app/_build/dev/lib/my_dep, but not at my_app/_build/test/lib/my_dep

  • I run tests with mix test - the compiled version of my_dep now appears at my_app/_build/test/lib/my_dep
  • I make a change to a file in my_app/deps/my_dep, compile the dep with mix deps.compile my_dep, and run the tests again

The change that I’ve made to the dependency is reflected in the _build/dev/ version, but not in the _build/test/ version - so if I run the tests again, the change does not take affect, nor is it observable if I start an iex session via MIX_ENV=test iex -S mix (though it is observable if I start iex in the dev environment).

From walking through this step-by-step, it’s become evident to me that deps are compiled differently for different environments . If there’s no other way around this, it’s not a big deal - I just have to run $ rm -rf _build/test/lib/my_dep when I make changes… but I’m interested in learning more about this aspect of mix’s design, and if there’s a way that I can recompile a dependency specifically for the test environment.

Showing Posts 1 to 3

NobbZ

NobbZ

You are not supposed to make any changes in deps, if you really have to, then you need to recompile the deps manually for each environment, eg. MIX_ENV=test mix deps.compile.

skwidbreth

skwidbreth OP

I definitely appreciate the fact that making changes to deps is somewhat taboo, but I find that it is helpful for my development process. Thanks very much for the tip! I didn’t realize that would work, makes sense.

axelson

axelson

Scenic Core Team

While developing you could also try changing the dependency to:

    {:my_dep, '~> 1.0.0', path: 'deps/my_dep'}

But in either case you have to be very careful to not overwrite any changes you make and I wouldn’t commit code that includes a path dep in deps. But I have found this technique useful for testing changes locally.

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews