Home > Backend Development > Golang > Why Does Makefile Throw a Permission Denied Error for Go Commands?

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

DDD
Release: 2024-10-23 15:54:01
Original
259 people have browsed it

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 . ;
Copy after login

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.

The above is the detailed content of Why Does Makefile Throw a Permission Denied Error for Go Commands?. For more information, please follow other related articles on the PHP Chinese website!

source:php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template