New installation won't run Mix on Windows

Hi, I just started trying to dive into Elixir today and I’m sure I’ll have lots of basic questions.

I’m on Windows 10 and primarily using the terminal inside VS Code (although I tried the PowerShell terminal and got a different error there).

When I try to use any Mix commands in my terminal, I’m getting:

mix : The term ‘mix’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.

I let Elixir add everything to my PATH that it wanted to add when I was installing it. When I open up my system environment variables and look under Path, I see “%USERPROFILE%.mix\escripts” is there.

Please help!

1 Like

When you open a normal cmd console can you use mix normally?

If so, close all vs code windows you have opened and run it again, normally when you add new env variables vscode does not recognize them until you close and open again it

1 Like

This is true for any program. A process will never pick up changes in the environment after it has been started, unless it polls its parent for changes, which again has to poll its parent, etc…

Therefore, its a safe choice to restart any program that might rely on the changed environment after it has been altered.

Anyway, mix itself is not in %USERPROFILE%.mix\escripts, but whereever you installed elixir to. No clue what the default is. But assuming windows conventions it should be C:\Programs\elixir\bin or something like that (especially the Programs part I’m not sure about, as I’ve only ever seen its localized name, and I’m not using windows regularly).

Well I feel dumb for not thinking of that. That was indeed the (primary) problem.

When I closed and re-opened VSCode, the error changed to the error I was getting in PowerShell, i.e. that I wasn’t allowed to run scripts without changing my Execution Policy. I was able to figure out how to do that, but it seems like there’s no decent setting between “Restricted” (can’t run scripts at all) and “Bypass” (no protection at all), since Mix isn’t “digitally signed.” So if I want to be protected against running untrusted scripts, I’ll have to manually change to “Bypass” and back every time I want to use Mix. Let me know if I’m missing something, because this seems stupid.

Anyway, I got Mix to start a new project, so I can continue following the tutorial now. Thanks.