Elixir `mix` command throws error `could not call Module.put_attribute/3 because the module Helloworld.MixProject is already compiled`
Asked Answered
D

2

3

Setup new project with command mix new project_name it setup everything without any error or warning message, cd to project and ran command iex -S mix it throws error

enter image description here

lib/helloworld.ex

defmodule Helloworld do
  @moduledoc """
  Documentation for `Helloworld`.
  """

  @doc """
  Hello world.

  ## Examples

      iex> Helloworld.hello()
      :world

  """
  def hello do
    :world
  end
end

Version installed on system

MacBook Pro M2 - OS 13.4.1
Terminal - Rosetta
OpenSSL 3.1.2 1 Aug 2023 (Library: OpenSSL 3.1.2 1 Aug 2023)
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit
Elixir 1.15.4 (compiled with Erlang/OTP 26)
Mix 1.15.4 (compiled with Erlang/OTP 26)
Node v18.15.0
NPM 9.5.0
Dementia answered 7/8, 2023 at 3:12 Comment(6)
That's strange. Can you edit the question and add the contents of lib/helloworld.ex? – Vietcong
@Vietcong updated question, lib/helloworld.ex has default content generated by mix – Dementia
What's really strange is that the error is in the @ processing in Helloworld, and yet the closed module reported in the error is Helloworld.MixProject 😩 – Spondaic
For shits and giggles, throw up your mix.exs – Spondaic
@Vietcong Is it miss configuration of elixir? I followed this to setup elixir on MacOs m2 https://mcmap.net/q/1180503/-install-elixir-on-m1-mac – Dementia
Try a mix clean and see what happens. I agree that this is really a strange issue. – Complicated
D
1

I was trying to install elixir on Rosetta terminal, and after switching to native terminal, was getting same error, so uninstalled everything related to elixir from Rosetta terminal, and on native terminal installed homebrew and followed https://elixir-lang.org/install.html#macos

Make sure all required dependencies must be installed with same homebrew

Dementia answered 23/8, 2023 at 2:57 Comment(0)
A
-1

I think you can follow this instruction to install elixir for MacOS: https://elixir-lang.org/install.html#macos

Analogy answered 9/8, 2023 at 15:33 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.