Mix command works in terminal but doesn't compile with "mix new my_project"

Hi, I am new to elixir, tried several ways to install elixir on my Mac M1.
Everything works on terminal or if I just create a test.exs file.
But when I want to add Phoenix or even with a “mix new my_project”, it always gives me this error below,

Compiling 1 file (.ex)

== Compilation error in file lib/learning.ex ==
** (ArgumentError) could not call Module.put_attribute/3 because the module Learning.MixProject is already compiled
    (elixir 1.15.7) lib/module.ex:2310: Module.assert_not_readonly!/2
    (elixir 1.15.7) lib/module.ex:2007: Module.__put_attribute__/5
    lib/learning.ex:2: (module)

I tried with homebrew, with asdf. Can anyone assist me solving this issue?
Looking forward to get started with elixir ~

Are you using the ARM native (M1) homebrew, oe emulated one through Rosetta 2?

Please share the content of the above.

macOS: 13.4-x86_64
Xcode: 14.2
Rosetta 2: true

Looks like i am using through Rosetta 2.

Change that. Use native ARM homebrew.

defmodule Learning do
@moduledoc “”"
Documentation for Learning.

@doc “”"
Hello world.


  iex> Learning.hello()

def hello do

The exact code came with “mix new learning”

Thank you, I will try it now.

That solved the issue. Thank you ~
All I had to do it, get out of inner session CTRL + D,
reinstall homebrew for amr64,
install elixir.
Thank you ~

1 Like

It’s a common gotcha. Glad you solved it.

1 Like