Fl4m3Ph03n1x

Fl4m3Ph03n1x

VScode mix.exs error - Could not compile with "make"

Background

I have an umbrella app where I am making a build for windows using bakeware:

I have followed the normal setup for windows:

choco install -y zstandard make mingw

I have installed elixir and erlang otp via their official website installers:

Problem

I am able to run and do everything normally, but my VSCode marks my mix.exs file as a huge red error blob:

an exception was raised:
    ** (Mix.Error) Could not compile with "make" (exit status: 2).

        (mix 1.13.1) lib/mix.ex:515: Mix.raise/2
        (elixir_make 0.6.3) lib/mix/tasks/compile.make.ex:154: Mix.Tasks.Compile.ElixirMake.run/1
        (mix 1.13.1) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3
        (mix 1.13.1) lib/mix/tasks/compile.all.ex:92: Mix.Tasks.Compile.All.run_compiler/2
        (mix 1.13.1) lib/mix/tasks/compile.all.ex:72: Mix.Tasks.Compile.All.compile/4
        (mix 1.13.1) lib/mix/tasks/compile.all.ex:59: Mix.Tasks.Compile.All.with_logger_app/2
        (mix 1.13.1) lib/mix/tasks/compile.all.ex:36: Mix.Tasks.Compile.All.run/1
        (mix 1.13.1) lib/mix/task.ex:397: anonymous fn/3 in Mix.Task.run_task/3ElixirLS

Question

In Bakeware’s page there is a section:

Change the default MAKE environment variable used by elixir_make from nmake to make (set it permanently to get rid of the errors in VSCode)

  • But how do I do this?
  • Is something wrong with my VSCode setup?

Marked As Solved

Fl4m3Ph03n1x

Fl4m3Ph03n1x

I was able to somehow fix the issue.
Bakeware, the dependency, really likes Powershell. But not any powershell. A powershell with admin rights.
To get rid of the warning one must perform the following steps while VSCode is closed:

  1. Open Windows Powershell in admin mode
  2. set $env:CC="gcc"
  3. set $env:MAKE="make"
  4. set MIX_ENV to something. It doesnt have to be prod, but since powershell does not set this value by default, you have to manually set it yourself. Before running tests, fetching dependencies or anything.
  5. mix deps.get

After this, if you still get the red wall of death, trying deleting your .elixir_ls folder to force to go again.
Then open VSCode with code .

Hope it works for you, it did for me.
Trying this with any other terminal will result in seeing the red wall of death. According to my experiments, powershell is the only that works.

Also Liked

axelson

axelson

Scenic Core Team

What extension are you using? You’ve tagged vscode-elixir which is not maintained and hasn’t been updated since 2017. If you use ElixirLS then you can set arbitrary environment variables if you’re using the latest version. Here’s the PR that exposed it in the VSCode extension add setting for environment variables by vacarsu · Pull Request #213 · elixir-lsp/vscode-elixir-ls · GitHub

cmo

cmo

In my experience, you don’t need to use PowerShell, nor do you require it to be an administrative shell. You do however need to set those environment variables, which I’m sure I added to the readme. Setting MAKE with the $env command won’t last, so do it through the Windows UI (press Windows key and type ‘env’ and the shortcurt should show up) to keep VSCode happy.

Fun fact, you can also use zig as your c compiler with CC=zig cc.

Where Next?

Popular in Questions Top

LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
jc00ke
Expanding on this topic: https://forum.elixirforum.net/t/map-typespec-question/19217 Let’s say I have a map with required and optional k...
New

Other popular topics Top

sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New

We're in Beta

About us Mission Statement