Skip to content

Mix.install/2 can only be called with the same dependencies in the given VM when debugging a plain .exs file #1178

Description

@jarrodmoldrich

Hi elixir-ls devs,

When debugging an .exs file without a mix.exs I ran into the following issue:

Started ElixirLS Debug Adapter v0.27.2
ElixirLS Debug Adapter built with elixir "1.18.3" on OTP "27"
Running on elixir "1.18.3 (compiled with Erlang/OTP 27)" on OTP "27"
Protocols are not consolidated

[...]

Running with MIX_ENV: dev MIX_TARGET: host
Running mix run --no-mix-exs test.exs
Mix task failed
Mix task exited with reason
an exception was raised:
    ** (Mix.Error) Mix.install/2 can only be called with the same dependencies in the given VM
        (mix 1.18.3) lib/mix.ex:618: Mix.raise/2
        test.exs:1: (file)
        (elixir 1.18.3) src/elixir_compiler.erl:77: :elixir_compiler.dispatch/4
        (elixir 1.18.3) src/elixir_compiler.erl:52: :elixir_compiler.compile/4
        (elixir 1.18.3) src/elixir_compiler.erl:39: :elixir_compiler.maybe_fast_compile/2
        (elixir 1.18.3) src/elixir_lexical.erl:13: :elixir_lexical.run/3
        (elixir 1.18.3) src/elixir_compiler.erl:17: :elixir_compiler.quoted/3
        (elixir 1.18.3) lib/module/parallel_checker.ex:120: Module.ParallelChecker.verify/1
returning code 1
Mix task exited with reason
an exception was raised:
    ** (Mix.Error) Mix.install/2 can only be called with the same dependencies in the given VM
        (mix 1.18.3) lib/mix.ex:618: Mix.raise/2
        test.exs:1: (file)
        (elixir 1.18.3) src/elixir_compiler.erl:77: :elixir_compiler.dispatch/4
        (elixir 1.18.3) src/elixir_compiler.erl:52: :elixir_compiler.compile/4
        (elixir 1.18.3) src/elixir_compiler.erl:39: :elixir_compiler.maybe_fast_compile/2
        (elixir 1.18.3) src/elixir_lexical.erl:13: :elixir_lexical.run/3
        (elixir 1.18.3) src/elixir_compiler.erl:17: :elixir_compiler.quoted/3
        (elixir 1.18.3) lib/module/parallel_checker.ex:120: Module.ParallelChecker.verify/1
returning code 1

12:14:40.298 [error] Process #PID<0.233.0> raised an exception
** (Mix.Error) Mix.install/2 can only be called with the same dependencies in the given VM
    (mix 1.18.3) lib/mix.ex:618: Mix.raise/2
    test.exs:1: (file)
    (elixir 1.18.3) src/elixir_compiler.erl:77: :elixir_compiler.dispatch/4
    (elixir 1.18.3) src/elixir_compiler.erl:52: :elixir_compiler.compile/4
    (elixir 1.18.3) src/elixir_compiler.erl:39: :elixir_compiler.maybe_fast_compile/2
    (elixir 1.18.3) src/elixir_lexical.erl:13: :elixir_lexical.run/3
    (elixir 1.18.3) src/elixir_compiler.erl:17: :elixir_compiler.quoted/3
    (elixir 1.18.3) lib/module/parallel_checker.ex:120: Module.ParallelChecker.verify/1
Received disconnect request

It runs fine in bash with mix run --no-mix-exs test.exs. Making a basic application and calling a function directly with -e seems to work fine. Is there a way to debug an a plain .exs?

Project: compile_crash.zip

.vscode/launch.json:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "mix_task",
      "name": "compile_crash",
      "request": "launch",
      "task": "run",
      "startApps": false,
      "taskArgs": ["--no-mix-exs", "test.exs"],
      "projectDir": "${workspaceRoot}",
      "exitAfterTaskReturns": false,
      "console": "internalConsole",
      "outputCapture": "std",
    }
  ]
}

test.exs:

Mix.install([{:req, "~> 0.5.10"}])

IO.puts "Hello world"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions