Search code examples
elixirelixir-mix

Mix install.archive fails and asks for -i to specify directory


I am running this command

$ mix archive.install github ninenines/cowboy
* Getting new package (https://github.com/ninenines/cowboy.git)
remote: Counting objects: 9525, done.        
remote: Compressing objects: 100% (13/13), done.        
remote: Total 9525 (delta 0), reused 11 (delta 0), pack-reused 9511        
...
** (Mix) Cannot create archive without input directory, please pass -i as an option

But there is no -i option, and mix won't let me do that. How do I get around this?


Solution

  • TL;DR It’s impossible to execute this task outside of mix project.

    From the Mix.Tasks.Archive.Install documentation:

    If no argument is supplied but there is an archive in the project’s root directory (created with mix archive.build), then the archive will be installed locally. For example:

    mix do archive.build, archive.install
    

    If an argument is provided, it should be a local path or a URL to a prebuilt archive, a git repository, a github repository, or a hex package.

    mix archive.install calls archive.build under the hood. The error you are receiving is introduced by archive.build, which, unlike install, receives -i option.

    It, in turn, expects the installation spec to be present.

    The summing up: one might provide the dep_spec as shown in the source linked above, but in general mix just does not understand where to build the downloaded packages. Afterward, it will nevertheless be in doubt, where to install it. So the simplest solution would be to create the empty project with mix new and then execute these tasks there.