Hi!
I installed elixir from source and I am not able to do anything with mix than to get its version:
$ mix
** (ArgumentError) cannot invoke def/2 outside module
(elixir) lib/kernel.ex:3556: Kernel.assert_module_scope/3
(elixir) lib/kernel.ex:2816: Kernel.define/4
(elixir) expanding macro: Kernel.def/2
This message appears regardless what I try to do with it, only thing working is mix --version (see below).
Some more info:
$ erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell
"17"
$ erl -version
Erlang (ASYNC_THREADS) (BEAM) emulator version 6.2
$ elixir --version
Elixir 1.0.3
$ mix --version
Mix 1.0.3
$ uname -a
Linux sabayon.local 3.17.0-sabayon #1 SMP Mon Jan 12 02:54:39 UTC 2015 x86_64 Intel(R) Core(TM) i5-4210M CPU @ 2.60GHz GenuineIntel GNU/Linux
Same thing happened also when I tried using tags 1.0.0, 1.0.1, 1.0.2, and HEAD.
Are you, by any chance, trying to run mix inside the Elixir directory or in a directory that has a mix.exs file with gibberish in it?
I don't know if it was gibberish ;) But at least there was a mix.exs.
After removing it, it worked, but that project isn't usable anymore :) I have to talk to my co-student first, its his code, I just wanted to run it here.
Perhaps that errormessage could be somewhat more meaningful?
Yup, the error message is horrible. It needs to be fixed. :)
The error coming from mix.exs is likely a call to def outside of a module.
Fixed in master, thank you!
I got this in espec in a test. Just for the next guy or gal running into this error, it was due to a subject not having an "end" keyword, which probably creates a function outside a module.
e: nvm me, sorry for that. i need to read directions more carefully.
Hit the same thing on my mac, with elixir installed via brew:
>elixir --version
Erlang/OTP 21 [erts-10.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]
Elixir 1.8.0 (compiled with Erlang/OTP 21)
Had a mix.exs file with the following content. I think this was from Programming Erlang but I can't remember now:
def deps do
[{:poison, "~> 3.1"}]
end
Full output was:
** (ArgumentError) cannot invoke def/2 outside module
(elixir) lib/kernel.ex:5362: Kernel.assert_module_scope/3
(elixir) lib/kernel.ex:4101: Kernel.define/4
(elixir) expanding macro: Kernel.def/2
mix.exs:1: (file)
Anyway, things worked once I removed it.