When you compile a package yourself where is stored?

I couldn’t get sqlite_ecto2 to work in a project so I downloaded the package fron its github repo and compiled it.

After compiling it does it get automatically stored for global use in some directory managed by Erlang/elixir package system, or do I need to run some mix command to set how it will be available for other projects and packages?

The compiled package is stored in _build/<mix_env>/<package>, and you shouldn’t use that one anywhere but for developing it. If you want to use the git version of a dependency then specify it as such. That’s what the :git key in the dependencies options is about.

1 Like

Why can’t what is compiled locally be used in my other projects in place of those downloaded from hex?

How do I obtain the version information from the one I just built?

You can do, but you shouldn’t. It would either mean, that you have to copy your locally build stuff manually into the _build-tree of your actual app. Hex might complain about this and try to compile again from what it sees in its deps-tree.

Another way to use the locally compiled stuff is to use it as a :path dependency, which basically does the following:

  • Copy the sources from the given path into your deps-tree
  • Compile it using MIX_ENV=prod into your _build-tree
  • Use it as a proper dependency

So it would roughly do the same what you had to do, but less error-prone.

Still, what you really wan’t is to use a :git-dependency. This is the easiest way to make your application available to others and make contributions free of any hurdles.

The way to check the version of a package that you pulled/cloned from git is often refered to as the version specified in the mix-file plus the actual commit-SHA you compiled from.

1 Like

Because configurations and macro’s and such can entirely change how that library is compiled based on the various usages and configs and such of each individual project, so each project, and indeed each environment inside even a single project, needs to be compiled uniquely.

You really want to use the :git option dependency in the mix.exs file.

1 Like