Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mix deps.get doesn't error when a local dependency is missing #13915

Open
nickgnd opened this issue Oct 18, 2024 · 0 comments
Open

mix deps.get doesn't error when a local dependency is missing #13915

nickgnd opened this issue Oct 18, 2024 · 0 comments

Comments

@nickgnd
Copy link

nickgnd commented Oct 18, 2024

Elixir and Erlang/OTP versions

Elixir v 1.17.2
Erlang/OTP 27

Operating system

Mac OS 15.0.1

Current behavior

Hey 👋
as always, thanks for all the great work, that's a pleasure working in Elixir.

That's really a minor issue, but I spent few minutes on it, and therefore I wanted to share it.

First. When a dependency is not found in hex.pm, maybe because misspelled, mix deps.get returns an error with an hint. For example:

❯ mix deps.get
Failed to fetch record for plugxxxxx from registry (using cache instead)
This could be because the package does not exist, it was spelled incorrectly or you don't have permissions to it
** (Mix) No package with name plugxxxxx (from: mix.exs) in registry

While, the same does not happen when a local dependency specified with the option path is not found.
For instance, if this is my mix.exs

defmodule Hello.MixProject do
  use Mix.Project

  def project do
    [
      app: :hello,
      version: "0.1.0",
      elixir: "~> 1.17",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [extra_applications: [:logger]]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      # Refer to a local dependency that is missing
      {:other_package, path: "other_package"}
    ]
  end
end

Running mix deps.get just succeed without any error or warning, actually without printing anything in this case that it is the only dep.

Expected behavior

I'd expect a consistent behaviour across the different way to install a dependency.

mix deps.get should error when the specified path is not pointing to any folder in the local file system, or to a folder that is not an elixir library.

Maybe here, it would be enough to check if there is a mix.exs file within the specified path, otherwise raise an error. If you think it is a good idea, I'm happy to open a PR.

Keyword.put(opts, :dest, Path.expand(raw))

Thank you 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant