[Proposal] Support individual path for git dependencies

30 views
Skip to first unread message

Jason Axelson

unread,
Jul 18, 2019, 2:28:47 PM7/18/19
to elixir-lang-core
I like to structure my code with applications and I often have more than one application in a specific git repo (in a mono-repo type fashion) where an application will have a path dependency to another application in the git repository. However, this is poorly supported by mix at the moment. There is the `:sparse` option, but that sets the path to a path in the git repository AND does a sparse checkout so only that path is downloaded. I'd like an option to have the former without the latter. As far as I can tell this is currently not possible.

I think the option can be named something like "git_path", which would make the configuration look like this:

    def deps do
      [
        ...,
        {:timer, git: "https://github.com/axelson/pomodoro.git", git_path: "timer"}
      ]
    end

Note: Today if you use `sparse: "timer"` and after the repository is downloaded you manually switch it to a full instead of sparse checkout, the dependency will work correctly.


-Jason

José Valim

unread,
Jul 18, 2019, 2:51:10 PM7/18/19
to elixir-l...@googlegroups.com
Can you please expand on why sparse is not enough? Why do you want a full checkout but use only part of it?


José Valim
Skype: jv.ptec
Founder and Director of R&D


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/2bbd23a7-4001-46c8-b8bb-5c3047412360%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Norbert Melzer

unread,
Jul 18, 2019, 2:57:03 PM7/18/19
to elixir-lang-core
He does want to use all of it, as the repository is a monolithic structure, where the part he wants to depend on has `:path` dependencies to sibling folders within the same repository.

Jason Axelson

unread,
Jul 19, 2019, 2:13:06 PM7/19/19
to elixir-l...@googlegroups.com
Norbert is correct, a full checkout but pointing to a specific folder in the checkout is what I am after.

This is my use-case. I have the following git repository:

https://github.com/axelson/pomodoro

Which has these applications within:
* timer_core - provides common timer functionality
* timer - uses scenic along with timer_core (via path dependency) to graphically render a timer
* timer_ui - provides the configuration to run timer on a desktop computer

Then I have another project (and github repository) that uses timer along with other scenic programs and runs them together (on desktop as well as on nerves)

All this would be possible if I pushed up all of these projects to hex.pm, but I don't want to "pollute" hex.pm with these packages that aren't ready/polished (and may never be) enough to belong on there, I feel that they would just add noise to the package repository.

Hopefully that explains my use-case better.

Thanks,
Jason

José Valim

unread,
Jul 19, 2019, 2:39:30 PM7/19/19
to elixir-l...@googlegroups.com
Thanks Jason!

I understand your use case now but I am not sure how comfortable I am with the idea of having path dependencies being brought in indirectly via git.

A workaround for now is to bring all dependencies as sparse dependencies but watch out they may get out of sync, so you want to make sure they all point to the same ref.

You can also implement this as a custom SCM. You just need to wrap all of Git functions and change accepts_options.

José Valim
Skype: jv.ptec
Founder and Director of R&D

Jason Axelson

unread,
Jul 20, 2019, 2:52:39 PM7/20/19
to elixir-l...@googlegroups.com
Thanks José!

The workaround of listing the dependency and sub-dependency both with sparse and ensuring that they're both referencing the same commit works for me.

For future/others reference this is what it looks like:

    defp deps do
      {:timer, git: "https://github.com/axelson/pomodoro.git", sparse: "timer"},
      {:timer_core, git: "https://github.com/axelson/pomodoro.git", sparse: "timer_core", override: true}
    end

In the future I may look into implementing this feature as a custom SCM, thanks for the pointer on that.

-Jason Axelson
Reply all
Reply to author
Forward
0 new messages