zhamao-robot/zhamao-framework

安装脚本环境问题

FishZe opened this issue · 0 comments

受影响版本

after 6dc6d93

描述

无法使用内建phpcomposer安装框架 (ubuntu 22.04 / amd64)

  1. 在将phpcomposertemp_dir移动到runtime_dir前执行了 zhamao init,报错如下:
[*] 开始安装框架到目录 zhamao-v3 ...
Composer could not detect the root package (zhamao/zhamao-v3-app) version, defaulting to '1.0.0'. See https://getcomposer.org/root-version
[*] 从 Composer 拉取框架 ...
./composer.json has been updated
Running composer update zhamao/framework
Loading composer repositories with package information
Updating dependencies
Lock file operations: 43 installs, 0 updates, 0 removals
...
[ErrCode:E00014] Cannot find any PHP runtime, please use command "./install-runtime.sh" or install PHP manually!
[!] 安装框架失败!
  1. 安装脚本不会移动 composer.pharruntime_dir
[*] 移动内建 Composer 到框架目录 /home/ubuntu/project/lark-what2eat/zhamao-v3/runtime/ ...
* Framework started with built-in php.
提取框架基础文件
提取 /zhamao ... 完成
提取 /config/config.php ... 完成
提取 /config/container.php ... 完成
提取 /config/file_header.json ... 完成
提取 /config/global.php ... 完成
提取 /config/global_old.php ... 完成
提取 /config/motd.txt ... 完成
[*] 初始化框架脚手架文件 ...
Could not open input file: /home/ubuntu/project/lark-what2eat/zhamao-v3/runtime/composer.phar
[!] 安装框架失败!

复现步骤

在不存在默认phpcomposer的设备执行安装脚本

bash <(curl -fsSL https://zhamao.xin/v3.sh)

解决方案

  1. 移动 if_restore_native_runtimevendor/bin/zhamao init 之前
echo "$(nhead) 从 Composer 拉取框架 ..." && \
        echo '{"minimum-stability":"dev","prefer-stable":true}' > composer.json && $composer_executable require -n zhamao/framework:^3.0 && \
        $composer_executable require -n --dev swoole/ide-helper:^4.5 && \
        if_restore_native_runtime && \
        vendor/bin/zhamao init && \
        echo "$(nhead) 初始化框架脚手架文件 ..." && \
  1. 修改 if_restore_native_runtime()
echo "$(nhead) 移动内建 Composer 到框架目录 $ZM_RUNTIME_DIR ..." && \
            (([ -e "$ZM_TEMP_DIR/composer" ] && mv "$ZM_TEMP_DIR/composer" "$ZM_RUNTIME_DIR") && \
            ([ -e "$ZM_TEMP_DIR/composer.phar" ] && mv "$ZM_TEMP_DIR/composer.phar" "$ZM_RUNTIME_DIR")) || {
                echo "$(nhead red) 移动内建 Composer 到框架目录失败!" && return 1
        }

附加信息

No response