wende / elchemy

Write Elixir code using statically-typed Elm-like syntax (compatible with Elm tooling)
https://wende.github.io/elchemy/
MIT License
1.15k stars 28 forks source link

Test Elixir 1.7.1-1.8 compatibility #360

Closed pavanmishra closed 5 years ago

pavanmishra commented 5 years ago

Following through the installation instructions I hit through the following snag.

elchemy clean elchemy init mix test `== Compilation error in file lib/Elchemy/XDebug.elchemy.ex == ** (UndefinedFunctionError) function Kernel.Typespec.translate_spec/3 is undefined or private. Did you mean one of:

  * translate_typespecs_for_module/2

(elixir) Kernel.Typespec.translate_spec(:spec, {:::, [line: 34], [{:format, [line: 34], [{:any, [line: 34], nil}]}, {{:., [line: 34], [{:__aliases__, [line: 34], [:String]}, :t]}, [line: 34], []}]}, %Macro.Env{aliases: [{XBasics, Elchemy.XBasics}, {XList, Elchemy.XList}, {XString, Elchemy.XString}, {XMaybe, Elchemy.XMaybe}, {XDebug, Elchemy.XDebug}, {XChar, Elchemy.XChar}, {XTuple, Elchemy.XTuple}, {XResult, Elchemy.XResult}, {XDict, Elchemy.XDict}, {XSet, Elchemy.XSet}, {XBitwise, Elchemy.XBitwise}, {XRegex, Elchemy.XRegex}], context: nil, context_modules: [Elchemy.XDebug], contextual_vars: [], current_vars: %{{:spec_ast, {Elchemy.XDebug, 15}} => {0, :term}}, file: "/Users/explorer/learnings/elmer21/elm-deps/wende/elchemy-core/0.7.0/lib/Elchemy/XDebug.elchemy.ex", function: nil, functions: [{Kernel, [!=: 2, !==: 2, *: 2, +: 1, +: 2, -: 1, -: 2, --: 2, <: 2, <=: 2, ==: 2, ===: 2, =~: 2, >: 2, >=: 2, abs: 1, apply: 2, apply: 3, binary_part: 3, bit_size: 1, byte_size: 1, ceil: 1, elem: 2, exit: 1, floor: 1, function_exported?: 3, get_and_update_in: 3, get_in: 2, hd: 1, inspect: 1, inspect: 2, is_atom: 1, is_binary: 1, is_bitstring: 1, is_boolean: 1, is_float: 1, is_function: 1, is_function: 2, is_integer: 1, ...]}, {Elchemy.Glue, [get_in_: 1, put_in_: 1, try_catch: 1, update_in_: 1]}], lexical_tracker: #PID<0.141.0>, line: 37, macro_aliases: [{XBasics, {{Elchemy.XDebug, 4}, Elchemy.XBasics}}, {XList, {{Elchemy.XDebug, 4}, Elchemy.XList}}, {XString, {{Elchemy.XDebug, 4}, Elchemy.XString}}, {XMaybe, {{Elchemy.XDebug, 4}, Elchemy.XMaybe}}, {XDebug, {{Elchemy.XDebug, 4}, Elchemy.XDebug}}, {XChar, {{Elchemy.XDebug, 4}, Elchemy.XChar}}, {XTuple, {{Elchemy.XDebug, 4}, Elchemy.XTuple}}, {XResult, {{Elchemy.XDebug, 4}, Elchemy.XResult}}, {XDict, {{Elchemy.XDebug, 4}, Elchemy.XDict}}, {XSet, {{Elchemy.XDebug, 4}, Elchemy.XSet}}, {XBitwise, {{Elchemy.XDebug, 4}, Elchemy.XBitwise}}, {XRegex, {{Elchemy.XDebug, 4}, Elchemy.XRegex}}], macros: [{Kernel, [!: 1, &&: 2, ..: 2, <>: 2, @: 1, alias!: 1, and: 2, binding: 0, binding: 1, def: 1, def: 2, defdelegate: 2, defexception: 1, defguard: 1, defguardp: 1, defimpl: 2, defimpl: 3, defmacro: 1, defmacro: 2, defmacrop: 1, defmacrop: 2, defmodule: 2, defoverridable: 1, defp: 1, defp: 2, defprotocol: 2, defstruct: 1, destructure: 2, get_and_update_in: 2, if: 2, in: 2, is_nil: 1, match?: 2, or: 2, pop_in: 1, ...]}, {Elchemy.Glue, [curry: 1, curry: 2, curryp: 1, defcurry: 2, defcurry: 3, defcurryp: 2, defcurryp: 3, defreverse: 2, defswap: 2, let: 1, rec: 2, typetest: 1, verify: 1]}, {Elchemy, [import_std: 0]}], module: Elchemy.XDebug, prematch_vars: :warn, requires: [Elchemy, Elchemy.Glue, Kernel, Kernel.Typespec], unused_vars: %{}, vars: [spec_ast: {Elchemy.XDebug, 15}]})
lib/Elchemy/XDebug.elchemy.ex:37: (module)
(stdlib) erl_eval.erl:680: :erl_eval.do_apply/6

could not compile dependency :elchemy, "mix compile" failed. You can recompile this dependency with "mix deps.compile elchemy", update it with "mix deps.update elchemy" or clean it with "mix deps.clean elchemy"`

pavanmishra commented 5 years ago

The problem was latest version of elixir 1.8.1 where they have changed the kernel specs. Looks like we need to freeze the version of elixir too as is done for Elm.

pavanmishra commented 5 years ago

It works fine with elixir 1.7 which I helped myself using kiex.

wende commented 5 years ago

@pavanmishra It used not to work for Elixir 1.7.0 either. 1.7.1 fixed it because of community asking to bring that function back. Maybe it'll happen with 1.8 as well I'll give it a look what changed

pavanmishra commented 5 years ago

@wende you are right. It did not work with elixir 1.7.0 however it did not work with 1.7.1 either and gave the same error.

== Compilation error in file lib/Elchemy/XDebug.elchemy.ex == ** (ArgumentError) argument error :erlang.hd(nil) lib/Elchemy/XDebug.elchemy.ex:37: (module) (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6 could not compile dependency :elchemy, "mix compile" failed. You can recompile this dependency with "mix deps.compile elchemy", update it with "mix deps.update elchemy" or clean it with "mix deps.clean elchemy"

pavanmishra commented 5 years ago

Tried with all the elixir versions in 1.7.x series. Same error as above.

Also tried bumping down the erlang to 1.9.2. But even stranger error. Pheew

Could anyone tell me what erlang/elixir version combo they are successfully using for development or deployment?

wende commented 5 years ago

@pavanmishra I use Elixir 1.6.4 with whatever Erlang version (20 and 21 both work fine) Elixir 1.7 doesn't work because of a removed undocumented function (https://github.com/elixir-lang/elixir/issues/8085). But it was added back so my assumption is it would start to work with next minor release. It wasn't tested further yet

wende commented 5 years ago

Ok. It seems the spec function have changed. I'm on it to fix it for versions 1.7.1-1.8.x. Until then please use 1.5.x - 1.7.0

wende commented 5 years ago

You can see all compatible builds here: https://travis-ci.org/wende/elchemy/builds/513491883

wende commented 5 years ago

It seems that the recent releases also significantly changed the way types internally work. I'll carry on later in next couple of days. If it turns out to be a bigger change I'll just disable FFI type checking because this it the feature that breaks the compatibility and until then Elchemy will have to deal without it on 1.7+

pavanmishra commented 5 years ago

@wende you are right. It did not work with elixir 1.7.0 however it did not work with 1.7.1 either and gave the same error.

== Compilation error in file lib/Elchemy/XDebug.elchemy.ex == ** (ArgumentError) argument error :erlang.hd(nil) lib/Elchemy/XDebug.elchemy.ex:37: (module) (stdlib) erl_eval.erl:680: :erl_eval.do_apply/6 could not compile dependency :elchemy, "mix compile" failed. You can recompile this dependency with "mix deps.compile elchemy", update it with "mix deps.update elchemy" or clean it with "mix deps.clean elchemy"

The same error in 1.7.0 OTP 21. Even though travis test suite https://travis-ci.org/wende/elchemy/jobs/513491887/config suggests that it passes.

wende commented 5 years ago

@pavanmishra #361 Should address that. I'll verify if it's true that the Travis CI tests don't address something but that'd be troubling given that they even create an example project for integration testing. I'll get back to you

wende commented 5 years ago

Didn't mean to close it. I released a new version disabling FFI checking for all above 1.7.0 And now a second PR that reenables them for 1.7.4 and above.

Version 1.7.0-3 will never have this feature because Elixir removed an essential function for it. 1.7.4 has it back so it should be working just fine

wende commented 5 years ago

@pavanmishra I was able to track dow the bug. It turns out that even though Elchemy was being updated and fixed the template for elchemy init wasn't. Because of that the default downloaded elchemy-core version was always at most 0.7.x and Elixir 1.7 support was added in 0.8.0.

Try now by downloading the latest version:

$ npm install -g elchemy && elchemy clean && elchemy init 
$ mix test
pavanmishra commented 5 years ago

@wende thank you for addressing this. It runs fine now. I did see 0.7.x fly by during development, I thought it was a minor mistake. I did note it but ignored it.