"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Why Does Makefile Throw a Permission Denied Error for Go Commands?

Why Does Makefile Throw a Permission Denied Error for Go Commands?

Published on 2024-11-05
Browse:309

Why Does Makefile Throw a Permission Denied Error for Go Commands?

Permission Denied Error in Makefile When Running Go

You may encounter "permission denied" errors while running Go commands through a Makefile, even when you can execute them directly. This discrepancy arises due to an issue in GNU make.

Cause:

The error occurs when you have a directory on your PATH that contains a subdirectory named "go." For instance, if you have "/usr/bin/go/" on your PATH, it could interfere with the execution.

Solution:

To address this issue, check your PATH variable and remove any directories containing subdirectories named "go." If that's not feasible, add a semicolon (";") after the "go run" command in your Makefile to force GNU make to use a shell.

Example:

run:
    go run . ;

Additional Insights:

  • Running "make with -d/--trace" shows that GNU make doesn't recognize "run" as a target due to a non-existent directory or file by that name.
  • In the case of "run2," the echo command forces GNU make to interpret it as a target, allowing the "go run" command to execute successfully.
Release Statement This article is reprinted at: 1729668177 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3