App with a private dependency

Hi! I have a regular Phoenix 1.6.6 app with a private dependency hosted on GitHub. I’ve tried using git submodules and even copied the dependency into the project folder, but I get this error on deploy:

#18 6.658 ** (Mix) Cannot compile dependency :my_dep because it isn't available, please ensure the dependency is at "vendor/my_dep"

For some reason, mix won’t pick up on the submodule or project location when deploying. However, it works fine on my local machine.

def deps do
  [
    ...
    {:my_dep, path: "./vendor/my_dep"},
  ]
end

Does mix have some configuration that must be set in order for it to find the dependency in the project folder? I’ve tried adding the lib to ./vendor/my_dep and ./lib/vendor/my_dep with no luck (with git submodules and just copying the folder as is).

I can’t use mix release and I would rather not SSH into the server to set up keys to connect to GitHub.

1 Like

There is no configuration in mix to enable path dependencies. It looks like the directory is missing in your deployment. Can you verify that it exists on the server and elaborate on how you deploy your project?

3 Likes

Hi! I’m following this guide on fly.io. I’ve tested the guide with a barebones Phoenix app and the guide works.

I’m assuming the directory isn’t getting pushed to the fly server when I run fly launch then? But why? It’s not in my .gitignore or .dockerignore.

1 Like

It was a long time since I worked with buildpacks (which I think fly uses by default) so I am not sure how much I can help.

Do buildpacks include git submodules in the build? Have you tried committing the directory directly to the repository?

1 Like

With some help from Chris and Fly.io folks I got it to work. In my Dockerfile, I had to make sure vendor/dep was being copied before the mix deps.get command.

Assuming the private lib is in ./vendor/lib:

COPY vendor vendor # <- added this line here

COPY config/config.exs config/${MIX_ENV}.exs config/
RUN mix deps.compile
5 Likes