简体   繁体   中英

How to configure rebar3 to fetch dependencies from another host?

I have an app which uses rebar3, eg cowboy. My question is: how can I easily configure it to fetch cowboy from another host? That is I want to point it from github to another host.

By default, rebar3 will only grab packages from either hex.pm, any git repository, or any mercurial repository. You can see your options here .

If these defaults are not enough for you, you can create your own dependency resources . This will require you to write some Erlang code in order to tell rebar3 how to find and download the package(s) you are trying to use.

You want to build cowboy that has two dependencies which are git repositories on GitHub ( https://github.com/ninenines/cowlib and https://github.com/ninenines/ranch to be specific). But you want to fetch the repositories from some other host, like your company's own git server where you mirrored all public repositories you need.

You have a number of options:

  • Fork cowboy and change the dependency URL-s in the rebar.config . This is the only (sane) way I know to make Rebar3 fetch the dependencies from a different location. The other options will target the layers below Rebar3 to achieve the same result.
  • Configure git to rewrite GitHub URL-s to URL-s on your server, following eg https://stackoverflow.com/a/11383587/9015322
git config --global url.https://git.mycompany.com/.insteadOf https://github.com/
  • Add an /etc/hosts entry that resolves github.com to the IP of your server. You'll probably have to create a fake self-signed certificate for github.com, and make git on the build machine trust it. But you can do that following the advice here: https://stackoverflow.com/a/16543283/9015322

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM