【问题标题】:Find util not found on OSX查找在 OSX 上找不到的 util
【发布时间】:2021-11-27 17:55:45
【问题描述】:

我正在尝试运行使用find 命令的make 文件。我收到一条错误消息 make[3]: find: Command not found。我尝试使用 brew 安装 findutils,但仍然无法正常工作。

~/.zshrc

eval "$(rbenv init -)"
eval "$(pyenv init -)"

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

# Path to your oh-my-zsh installation.
export ZSH="/Users/antarr.byrd/.oh-my-zsh"

# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
ZSH_THEME="robbyrussell"

plugins=(git)

source $ZSH/oh-my-zsh.sh
export EDITOR='nano'

export GOPATH=~/go/
export GOROOT=/usr/local/opt/go/libexec
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOROOT/bin

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_PYTHON=/Users/antarr.byrd/.pyenv/versions/3.8.8/bin/python
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
source /usr/local/bin/virtualenvwrapper.sh
export PATH="/usr/local/opt/gnu-getopt/bin:$PATH"
export PATH="/usr/local/opt/grep/libexec/gnubin:$PATH"
export PATH="/usr/local/sbin:$PATH"
export PATH="/usr/local/opt/findutils/libexec/gnubin:$PATH"

生成文件

TEMPLATES = $(shell find . -type f -name 'template.yml')
GO_FILES = $(shell find . -type f -name '*.go') go.mod

.PHONY: coverage
coverage: $(GO_FILES) format
    @echo "* Running tests"
    go test ./... -coverprofile cover.out
    @awk 'BEGIN {print "** checking coverage"} \
          $$3 ~ /0/{print "  Missing coverage: " $$1}' cover.out
    @go tool cover -func cover.out \
    | awk -v min_coverage=$(MIN_COVERAGE) \
      '$$2 ~ /(statements)/ { \
         percent=$$3 + 0.0; \
         passed=(percent >= min_coverage); \
         passed_str=(passed?"yes":"no"); \
         print "overall total: " percent "% (" min_coverage "% or more: " passed_str ")"; \
         exit !passed}'
.PHONY: validate
validate: $(TEMPLATES)
    for template in $^ ; do sam validate -t $${template} ; done

【问题讨论】:

  • 你能分享一下makefile的相关/违规部分吗?
  • 我已经添加了@frippe
  • 谢谢。问起来有点粗鲁,但是您已经检查了 find 是否在交互式 shell(/bin/sh 或您设置为 make 使用的任何 shell)中找到,对吗?并检查了 PATH 以确保那里没有任何异常?
  • @frippe find 命令在 shell 中运行时工作正常。我不太确定要在路径中寻找什么,这就是它的样子/usr/local/opt/findutils/libexec/gnubin:/usr/local/sbin:/usr/local/opt/grep/libexec/gnubin:/usr/local/opt/gnu-getopt/bin:/Users/antarr.byrd/.pyenv/bin:/Users/antarr.byrd/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/usr/local/MacGPG2/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Users/antarr.byrd/go//bin:/usr/local/opt/go/libexec/bin
  • 您可以在终端窗口中使用which find 来查找它的位置。然后你可以尝试你的makefile中的完整路径。

标签: macos homebrew zshrc gnu-findutils


【解决方案1】:

运行以下命令:

type find

它可以给出类似的东西

/usr/local/opt/findutils/libexec/gnubin/find

然后你可以把你的makefile放在开头:

PATH := /usr/local/opt/findutils/libexec/gnubin:$(PATH)

【讨论】:

  • 我认为这不应该是公认的答案,因为它是一个硬编码的解决方法,并不能解决某些东西弄乱/与 PATH 相关的根本问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-11-07
  • 2013-04-03
  • 2013-08-18
  • 2011-03-08
  • 1970-01-01
相关资源
最近更新 更多