Problems with spacemacs credo and dogma

spacemacs
emacs
troubleshooting

#1

Hi there,

I’m using credo and dogma in my elixir 1.8 project and spacemacs is giving a hard time where it gives me the following error:

Error from syntax checker elixir-dogma: JSON readtable error: 61

I understand that dogma is not required for elixir 1.6+ so I tried to remove and I get the following crash in spacemacs whenever flycheck tries to run in a buffer:

Suspicious state from syntax checker elixir-credo: Flycheck checker elixir-credo returned non-zero exit code 1, but its output contained no errors: =SUPERVISOR REPORT==== 8-Feb-2019::10:05:36.301437 ===
    supervisor: {local,'Elixir.Logger.Supervisor'}
    errorContext: start_error
    reason: noproc
    offender: [{pid,undefined},
               {id,'Elixir.Logger.ErrorHandler'},
               {mfargs,
                   {'Elixir.Logger.Watcher',watcher,
                       [error_logger,'Elixir.Logger.ErrorHandler',
                        {true,false,500},
                        link]}},
               {restart_type,permanent},
               {shutdown,5000},
               {child_type,worker}]
=CRASH REPORT==== 8-Feb-2019::10:05:36.301346 ===
  crasher:
    initial call: Elixir.Logger.Watcher:init/1
    pid: <0.89.0>
    registered_name: []
    exception exit: noproc
      in function  gen:do_for_proc/2 (gen.erl, line 228)
      in call from gen_event:rpc/2 (gen_event.erl, line 239)
      in call from 'Elixir.Logger.Watcher':init/1 (lib/logger/watcher.ex, line 66)
      in call from gen_server:init_it/2 (gen_server.erl, line 374)
      in call from gen_server:init_it/6 (gen_server.erl, line 342)
    ancestors: ['Elixir.Logger.Supervisor',<0.83.0>]
    message_queue_len: 0
    messages: []
    links: [<0.84.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 376
    stack_size: 27
    reductions: 253
  neighbours:

=CRASH REPORT==== 8-Feb-2019::10:05:36.323862 ===
  crasher:
    initial call: application_master:init/4
    pid: <0.82.0>
    registered_name: []
    exception exit: {{shutdown,
                         {failed_to_start_child,'Elixir.Logger.ErrorHandler',
                             noproc}},
                     {'Elixir.Logger.App',start,[normal,[]]}}
      in function  application_master:init/4 (application_master.erl, line 138)
    ancestors: [<0.81.0>]
    message_queue_len: 1
    messages: [{'EXIT',<0.83.0>,normal}]
    links: [<0.81.0>,<0.43.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 376
    stack_size: 27
    reductions: 193
  neighbours:

=INFO REPORT==== 8-Feb-2019::10:05:36.326731 ===
    application: logger
    exited: {{shutdown,
                 {failed_to_start_child,'Elixir.Logger.ErrorHandler',noproc}},
             {'Elixir.Logger.App',start,[normal,[]]}}
    type: temporary
** (Version.InvalidRequirementError) ~> 1.0
    (elixir) lib/version.ex:159: Version.match?/3
    (mix) lib/mix/local.ex:100: Mix.Local.check_elixir_version_in_ebin/1
    (elixir) lib/enum.ex:651: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:651: Enum.each/2
    (mix) lib/mix/local.ex:50: Mix.Local.append_archives/0
    (mix) lib/mix/cli.ex:8: Mix.CLI.main/1


Try installing a more recent version of elixir-credo, and please open a bug report if the issue persists in the latest release.  Thanks!

Any idea on how to get over this, please?


#2

Which version of elixir and erlang are you running exactly?

This looks like some known bugs that pop up here every now and then and depend on the exact versions of erlang and elixir.


#3

I should have included this in my original post! :smiley:

Erlang/OTP 21 [erts-10.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.8.1 (compiled with Erlang/OTP 21)

Emacs 26.1

Spacemacs 0.200.13

also, I’m using the following credo and dogma in my mix.exs:

{:credo, “~> 1.0.0”, only: [:dev, :test], runtime: false},
{:dogma, “~> 0.1”, only: [:dev]}

Thanks!


#4

Since Dogma has been deprecated for over a year I’d recommend to only use credo and not dogma. Maybe dogma is having issues on Elixir 1.8+, but that seems unlikely since you’re getting an error from credo.

What version of Credo are you using? Are you using the latest version?

The Version.InvalidRequirementError sounds like this issue: Mix error corresponding to erlang-20rc.1 version but you shouldn’t be getting that error with Elixir 1.8.1 and OTP 21


#5

@axelson Yeah I thought the same and I did remove dogma but the issue appears to come from credo as you mentioned.
I initially had credo 1.0.0 and tried 1.0.2 (which is the latest I think) with the same effect …

I downgraded to erlang 20.3 and elixir 1.7.0 to test but the issue persists! Additionally, elixir 1.7.0 built against erlang 21.2 also gives the same error.

I can downgrade elixir to 1.6 just for testing although I don’t think that’ll be a long term plan for me since I’ll have to upgrade at some point.

Yes, I’ve read this post too. It sounds similar to the error I’m getting although a different module/package.

Maybe it’s safe to assume the issue is with credo?

Thanks,


#6

Do you get the same error if you run credo from the command line instead of via emacs?


#7

mix credo runs fine! It’s just when run in Spacemacs that I get the errors mentioned.


#8

Hmmm, how is elixir installed? Maybe spacemacs is picking up a global installation of Elixir that is different than the version you are getting at the command line.


#9

@axelson, thanks for the hint!
I use kiex for Elixir and the default is 1.7.0 compiled against Erlang 20.3 while Erlang is managed with kerl and the default I set in bashrc is also 20.3. I have other installations but upon starting a new terminal these defaults seems to be the effective ones. The culprit is exenv (totally forgot it was installed and failed to check the elixir command path too :confused:) and its default elixir build/installation. I forgot I used to use it instead of kiex … been hard coming back to an old laptop

Running elixir --version now gives me the following error:

Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]

{"init terminating in do_boot",{{badmatch,error},[{'Elixir.System',build,0,[{file,"lib/system.ex"},{line,164}]},{'Elixir.System',build_info,0,[{file,"lib/system.ex"},{line,156}]},{'Elixir.Kernel.CLI',parse_shared,2,[{file,"lib/kernel/cli.ex"},{line,153}]},{'Elixir.Kernel.CLI','shared_option?',3,[{file,"lib/kernel/cli.ex"},{line,113}]},{'Elixir.Kernel.CLI',main,1,[{file,"lib/kernel/cli.ex"},{line,14}]},{init,start_em,1,[]},{init,do_boot,3,[]}]}}
init terminating in do_boot ({{badmatch,error},[{Elixir.System,build,0,[{_},{_}]},{Elixir.System,build_info,0,[{_},{_}]},{Elixir.Kernel.CLI,parse_shared,2,[{_},{_}]},{Elixir.Kernel.CLI,shared_option?,

Crash dump is being written to: erl_crash.dump...done

and when I try to run iex -S mix phoenix.server inside my projct, I get the following:

Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-poll:false]

** (Version.InvalidRequirementError) ~> 1.0
    (elixir) lib/version.ex:159: Version.match?/3
    (mix) lib/mix/local.ex:100: Mix.Local.check_elixir_version_in_ebin/1
    (elixir) lib/enum.ex:651: Enum."-each/2-lists^foreach/1-0-"/2
    (elixir) lib/enum.ex:651: Enum.each/2
    (mix) lib/mix/local.ex:50: Mix.Local.append_archives/0
    (mix) lib/mix/cli.ex:8: Mix.CLI.main/1

I was prompted to check my defaults beyond kerl and kiex by your hint about global installations, thank you!


#10

At least everything is consistent now! Is there any reason not to use at least Elixir 1.7.4? But Elixir 1.7.0 and Erlang 20.3 should work together fine. You may want to try reinstalling everything. Also I like to use asdf instead of kerl and kiex (although the asdf plugins for elixir and erlang do use kerl and kiex under the hood). Also what operating system are you on?


#11

No reason why not use 1.7.4. I’ll probably upgrade soon.
I’m developing on OSX 10.14 but attempting to deploy to Ubuntu 16.04.