Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swoole-cli在linux下无法使用-a进入shell交互,提示:Interactive shell (-a) requires the readline extension. #790

Open
maxiaozhi opened this issue Sep 28, 2024 · 7 comments

Comments

@maxiaozhi
Copy link

maxiaozhi commented Sep 28, 2024

swoole-cli在linux下无法使用-a进入shell交互,提示:Interactive shell (-a) requires the readline extension.
猜测应该是readline扩展加载比较滞后导致的

@jingjingxyk
Copy link
Contributor

正在研究中

@jingjingxyk
Copy link
Contributor

经过测试验证发现 ,从 5.1.2 版本开始,出现了这种情况。
macos 环境下,未复现此问题

@jingjingxyk
Copy link
Contributor

jingjingxyk commented Oct 6, 2024

应该是升级 PHP 源码 把修改覆盖了 update php to 8.1.27

产生的原因: sync-source-code.php 代码有缺陷,同步readline 扩展未做处理

修复启用 readline 方法:
0401aed#diff-796648a9b6c2460b3c37064323891656592e446ee721d7ed5652b5bc68307ea8R747

修复方法:

@jingjingxyk
Copy link
Contributor

fix: #799

@maxiaozhi
Copy link
Author

经过测试验证发现 ,从 5.1.2 版本开始,出现了这种情况。 macos 环境下,未复现此问题

印象中以前版本的确不存在该问题,就是从5.1.x版本出现了该问题

@jingjingxyk
Copy link
Contributor

通用shell 脚本解决

FOUND_DL_READLINE=$(grep -c '#ifdef COMPILE_DL_READLINE' ext/readline/readline_cli.c)

if test $[FOUND_DL_READLINE] -gt 0 ; then
    # 获得待删除 区间
    START_LINE_NUM=$(sed  -n "/#ifdef COMPILE_DL_READLINE/=" ext/readline/readline_cli.c)
    START_LINE_NUM=$(($START_LINE_NUM - 1))
    END_LINE_NUM=$(sed  -n "/PHP_MINIT_FUNCTION(cli_readline)/=" ext/readline/readline_cli.c)
    END_LINE_NUM=$(($END_LINE_NUM - 5))

    sed -i.backup "${START_LINE_NUM},${END_LINE_NUM}d" ext/readline/readline_cli.c

    REPLACE_LINE_NUM=$(sed  -n "/#define GET_SHELL_CB(cb) (cb) = php_cli_get_shell_callbacks()/=" ext/readline/readline_cli.c)
    REPLACE_LINE_NUM=$(($REPLACE_LINE_NUM + 1))

    sed -i.backup "${REPLACE_LINE_NUM} s/.*/  /" ext/readline/readline_cli.c

fi

@maxiaozhi
Copy link
Author

通用shell 脚本解决

FOUND_DL_READLINE=$(grep -c '#ifdef COMPILE_DL_READLINE' ext/readline/readline_cli.c)

if test $[FOUND_DL_READLINE] -gt 0 ; then
    # 获得待删除 区间
    START_LINE_NUM=$(sed  -n "/#ifdef COMPILE_DL_READLINE/=" ext/readline/readline_cli.c)
    START_LINE_NUM=$(($START_LINE_NUM - 1))
    END_LINE_NUM=$(sed  -n "/PHP_MINIT_FUNCTION(cli_readline)/=" ext/readline/readline_cli.c)
    END_LINE_NUM=$(($END_LINE_NUM - 5))

    sed -i.backup "${START_LINE_NUM},${END_LINE_NUM}d" ext/readline/readline_cli.c

    REPLACE_LINE_NUM=$(sed  -n "/#define GET_SHELL_CB(cb) (cb) = php_cli_get_shell_callbacks()/=" ext/readline/readline_cli.c)
    REPLACE_LINE_NUM=$(($REPLACE_LINE_NUM + 1))

    sed -i.backup "${REPLACE_LINE_NUM} s/.*/  /" ext/readline/readline_cli.c

fi

嗯,我这边已经试过编译成功了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants