jdesilvio
jdesilvio

Reputation: 1854

Elixir - Installing Hex packages from source

I am working behind a proxy and need to install hex and some modules for a Mix project.

Eshell V7.2
Interactive Elixir (1.2.2)

I was able to download hex-0.9.0.ez to install Hex using mix archive.install F:/hex-0.9.0.ez.

$ mix hex
Hex v0.9.0

I am trying to do the same with https://github.com/kafkaex/kafka_ex/. I downloaded the .zip and ran:

$ mix archive.build -i C:/kafka_ex-0.5.0 -o C:/kafka_ex-0.5.0.ez
Generated archive "C:/kafka_ex-0.5.0.ez" with MIX_ENV=dev

Then I ran:

$ mix archive.install C:/kafka_ex-0.5.0.ez
Are you sure you want to install archive "C:/kafka_ex-0.5.0.ez"? [Yn] Y
* creating .mix/archives/kafka_ex-0.5.0.ez
** (MatchError) no match of right hand side value: {:error, :bad_directory}
    (mix) lib/mix/tasks/archive.install.ex:58:   Mix.Tasks.Archive.Install.install_archive/2
    (mix) lib/mix/tasks/archive.install.ex:40: Mix.Tasks.Archive.Install.run/1
    (mix) lib/mix/cli.ex:58: Mix.CLI.run_task/2
    (elixir) lib/code.ex:363: Code.require_file/2

I'm not sure what the above error is, but the package appears in the archive:

$ ls c/Users/me/.mix/archives
hex-0.9.0.ez  kafka_ex-0.5.0.ez

I can't figure out how to satisfy the dependencies in my project though.

$ mix deps.get

$ mix deps
* kafka_ex (c:/Users/me/.mix/archives/kafka_ex-0.5.0.ez)
  the dependency is not available

$ iex -S mix
Eshell V7.2  (abort with ^G)
Unchecked dependencies for environment dev:
* kafka_ex (c:/Users/me/.mix/archives/kafka_ex-0.5.0.ez)
  the dependency is not available
** (Mix) Can't continue due to errors on dependencies

Any suggestions? Maybe I'm doing something incorrect when I build/install from source or maybe my mix.exs file is wrong.


mix.exs:

defmodule Voting.Mixfile do
  use Mix.Project

  def project do
    [app: :voting,
     version: "0.0.1",
     elixir: "~> 1.2",
     build_embedded: Mix.env == :dev,
     start_permanent: Mix.env == :dev,
     deps: deps]
  end

  def application do
    [applications: [:logger, :kafka_ex],
    mod: {Voting, []}]
  end

  defp deps do
    [{:kafka_ex, path: "c:/Users/me/.mix/archives/kafka_ex-0.5.0.ez"}]
  end
end

Upvotes: 1

Views: 5106

Answers (1)

Onorio Catenacci
Onorio Catenacci

Reputation: 15293

If I had to guess I'd say this is the error message you should be paying attention to:

** (MatchError) no match of right hand side value: {:error, :bad_directory}

I'd say it seems to indicate that it can't create that kafka directory under c/Users/me/.mix/archives. Try manually creating the directory and when you've created it then retry mix archive.install C:/kafka_ex-0.5.0.ez

Upvotes: 1

Related Questions