CLion makefile error : Error running 'Makefile': Cannot run program "\usr\bin\make" CreateProcess error=2, The system cannot find the file specified
Asked Answered
H

3

8

Running Makefile in CLion. The Makefile is of stockfish(chess) and is here https://github.com/official-stockfish/Stockfish/blob/master/src/Makefile

I am trying this on a windows 10 system. Why is make unable to find the file? Is it a the separator issue of \ vs / on linux vs windows?

Full error

Error running 'Makefile': Cannot run program "\usr\bin\make" (in directory "C:\Users\anmol\Desktop\Coding\stockfish\src"): CreateProcess error=2, The system cannot find the file specified

My version of CLion has makefile support inbuilt and I have toolchain compilers installed via cygwin.

Hypnotic answered 3/5, 2021 at 22:56 Comment(0)
V
15

The full explanation of your problem is given in this comment in the JetBrains bug tracking system.

The Cannot run program "\usr\bin\make" error originates from the Makefile language plug-in which comes bundled with CLion and can be added to other JetBrains' IDEs, too. Despite being bundled, the plug-in was originally a 3rd-party one and is not a part of Makefile support in CLion: to some extent, it complements the built-in support for Makefile projects (e. g.: by enabling syntax highlighting), but has some functionality orthogonal to that.

That "orthogonal" functionality is, particularly, the way the plug-in runs Make (when you click the gutter icon from the Makefile editor). This has nothing to do with Toolchains in CLion and needs to be configured separately.

Cygwin

enter image description here

MinGW

enter image description here

You'll need to type the full Windows path into the text field (e. g.: C:\cygwin64\bin\make.exe) and either check the Use Cygwin box (for Cygwin) or leave it unchecked (for MinGW).

WSL

As of version 2022.1, the plug-in also supports running Make inside WSL guest VMs. See this section in the official documentation for more details.

Following the above guidelines will enable you to invoke Make targets from the Makefile editor (using any JetBrains IDE with the plug-in installed, not just CLion).

Vogel answered 13/5, 2021 at 12:12 Comment(1)
Thanks! It helped me realise the problem. Unfortunately, the plugin seems to be coded in such a poor manner that it breaks if the path of make executable has whitespace in between! Likely need to submit a bug...Tokenism
T
2

Workaround:

In a CLion Makefile project, two "Configuration" types are available: "Makefile Target" and "Makefile Application". If you edit a "Makefile Application" configuration, you will see a field called "Executable: "

The "Executable: " can be any Linux command including make itself. For "Makefile Application" (not "Makefile Target") the command is properly initiated using wsl.exe so that the command is run in WSL and not Windows.

(The problem with "Makefile Target" is obviously a CLion/plugin bug whereby "\usr\bin\make" is not run using wsl.exe, so it's run in Windows, so Windows is saying that it can't find it, which is expected because it's not supposed to be run in Windows to begin with! :-) )

Terminus answered 31/7, 2021 at 17:42 Comment(1)
I cannot find Makefile Application. Under "M" there is only "Makefile Target". Any ideas?Nairobi
D
0

Remove full path because in Powershell its work so

image

Dogwood answered 8/3 at 16:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.