M1终端添加路径后仍提示stacked: command not found问题求助
Stacked CLI 命令找不到问题排查
已安装Stacked CLI,文件存放在~/.pub-cache/global_packages目录,但执行stacked create app my_first_app时收到错误提示:
-bash: stacked: command not found
已通过echo $PATH确认/Users/alexa/.pub-cache/bin已添加到环境变量,登录Shell为/bin/bash,且该路径已写入~/.bash_profile,当前PATH内容如下:
/opt/homebrew/opt/dart@2.16/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/alexa/opt/anaconda3/bin:/Users/alexa/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/Cellar/ruby/2.5.1/bin:/Applications/XAMPP/xamppfiles/bin:/Applications/XAMPP/xamppfiles/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Applications/XAMPP/xamppfiles/bin:/Users/alexa/.pub-cache/bin:/Users/alexa/Developer/flutter/bin
排查解决步骤
验证可执行文件是否存在
先检查~/.pub-cache/bin目录下有没有stacked文件:ls -la /Users/alexa/.pub-cache/bin/stacked如果文件不存在,说明全局安装未成功,重新执行安装命令:
pub global activate stacked_cli(若使用Flutter环境,可替换为
flutter pub global activate stacked_cli)重新加载Shell配置
若文件存在,尝试重新加载~/.bash_profile使配置生效:source ~/.bash_profile之后再执行
stacked命令测试是否可用。检查PATH配置语法
打开~/.bash_profile确认PATH配置行无语法错误,正确格式应为:export PATH="$PATH:/Users/alexa/.pub-cache/bin"注意不要有多余空格或符号。
确认Shell配置加载状态
执行echo $BASH_VERSION确认当前使用bash,再执行以下命令验证路径是否已正确加载:echo $PATH | grep ".pub-cache/bin"若输出包含该路径,说明配置已生效;若没有,检查
~/.bash_profile是否被其他配置文件覆盖了PATH。
内容的提问来源于stack exchange,提问作者alexa tang
相关产品推荐
相关产品推荐

