简单测试支持运行多种语言程序的工具run
又是张泽鹏先生推荐的项目,网页是https://github.com/Esubaalew/run,上面列举了它支持运行的语言,简单测试一下行不行。
先下载了编译好的二进制文件,分别是windows版和Linux版。
windows
C:\d>echo "Hello from stdin" | run python --code "import sys; print(sys.stdin.read().strip().upper())"C:\d>run --version
run-kit 0.2.1
Universal multi-language runner and smart REPL
author: Esubalew Chekol <esubalewchekol6@gmail.com>
homepage: https://esubalew.et
repository: https://github.com/Esubaalew/run
license: Apache-2.0
commit: 01adc49 (2025-10-10T15:24:35+03:00, dirty: clean)
built: 2025-10-10T12:26:29.348013100+00:00 [release for x86_64-pc-windows-msvc]
rustc: rustc 1.90.0 (1159e78c4 2025-09-14)C:\d>run --lang python --code "print('hello, polyglot world!')"
能显示版本号,但调用python执行python程序失败,也不报错,就是没有任何返回。
Linux
root@DESKTOP-59T6U68:/mnt/c/d# python3
Python 3.10.12 (main, Aug 15 2025, 14:32:43) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
root@DESKTOP-59T6U68:/mnt/c/d# ./run --version
./run: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.39' not found (required by ./run)
root@DESKTOP-59T6U68:/mnt/c/d# docker start gcc
gcc
root@DESKTOP-59T6U68:/mnt/c/d# docker exec -it gcc bash
root@6ae32a5ffcde:/# cd par
root@6ae32a5ffcde:/par# ./run --version
./run: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.39' not found (required by ./run)
root@6ae32a5ffcde:/par# exit
exit
root@DESKTOP-59T6U68:/mnt/c/d# docker start gcc15
gcc15
root@DESKTOP-59T6U68:/mnt/c/d# docker exec -it gcc15 bash
root@DESKTOP-59T6U68:/# cd par
root@DESKTOP-59T6U68:/par# ./run --version
./run: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.39' not found (required by ./run)
分别尝试了WSL的ubuntu 22.04, gcc14和gcc15的docker都报缺少`GLIBC_2.39’的错误。
那就只好从源代码编译了。还好步骤不难。将源代码解压缩到 run-0.2.1目录。进入rust docker容器。
docker start rust
rust
root@DESKTOP-59T6U68:/mnt/c/d# docker exec -it rust bashcd run-0.2.1
root@DESKTOP-59T6U68:/par/run-0.2.1# cargo install --path .Installing run-kit v0.2.1 (/par/run-0.2.1)Updating `mirror` indexLocking 110 packages to latest Rust 1.87.0 compatible versionsAdding rustyline v13.0.0 (available: v17.0.2)Adding which v6.0.3 (available: v8.0.0)Downloaded quote v1.0.41 (registry `mirror`)
...Compiling regex v1.12.2Compiling clap v4.5.49Finished `release` profile [optimized] target(s) in 15.64sInstalling /usr/local/cargo/bin/runInstalled package `run-kit v0.2.1 (/par/run-0.2.1)` (executable `run`)
运行
root@DESKTOP-59T6U68:/par/run-0.2.1# gcc -v
Using built-in specs.gcc version 12.2.0 (Debian 12.2.0-14+deb12u1)root@DESKTOP-59T6U68:/par/run-0.2.1# run --version
run-kit 0.2.1
Universal multi-language runner and smart REPL
author: Esubalew Chekol <esubalewchekol6@gmail.com>
homepage: https://esubalew.et
repository: https://github.com/Esubaalew/run
license: Apache-2.0
commit: unknown (unknown date, dirty: unknown)
built: 2025-10-16T12:26:43.911820347+00:00 [release for x86_64-unknown-linux-gnu]
rustc: rustc 1.87.0 (17067e9ac 2025-05-09)root@DESKTOP-59T6U68:/par/run-0.2.1# run --lang python --code "print('hello, polyglot world!')"
bash: !': event not found
root@DESKTOP-59T6U68:/par/run-0.2.1# run --lang python --code "print('hello, polyglot world')"
hello, polyglot world
root@DESKTOP-59T6U68:/par/run-0.2.1# echo "Hello from stdin" | run python --code "import sys; print(sys.stdin.read().strip().upper())"
HELLO FROM STDIN
root@DESKTOP-59T6U68:/par/run-0.2.1# run --lang rust --code "fn main() { println!(\"hello from rust\"); }"
bash: !: event not found
root@DESKTOP-59T6U68:/par/run-0.2.1# run --lang c --code "int main() { printf(\"hello from c\"); }"
hello from c
README例子中的python程序报错了,把命令行中的!
去掉,能正确执行,管道程序也正确执行了。
rust程序也报同样的错,因为println!中必须有!
,所以放弃了。
改成c程序通过了,因为rust开发环境中就包含了gcc 12。
后记,
发表本文时,DeepSeek的智能摘要提示说:因bash对感叹号的特殊处理导致包含!的Rust代码无法执行,测试表明该工具在特定环境下能正常工作,但存在兼容性和特殊字符处理问题。我切换到sh,确实可以执行。
root@DESKTOP-59T6U68:/par/run-0.2.1# sh
# run --lang rust --code "fn main() { println!(\"hello from rust\"); }"
hello from rust