Skip to content

xlings安装脚本忽略下载失败错误 #125

@mikami-w

Description

@mikami-w

Background | 背景

你好,我在 WSL (Ubuntu) 环境下尝试安装 xlings 时遇到了问题。

Describe | 问题描述

主要发现了两个 Bug:

  1. 首先尝试在非 sudo 模式下安装, 脚本最后尝试自动配置时先使用了 sudo 提权, 紧接着提示 xlings: command not found, 似乎是环境变量未即时生效导致的, 且脚本并没有因错误而退出.

  2. (较严重) 然后尝试了在 sudo 模式下, 当核心组件 xvm 因网络原因下载失败时, 安装脚本没有终止, 而是继续执行并提示 "Installation completed!". 这导致后续步骤报错 No such file or directory.

Desktop | 环境

WSL2, Ubuntu Desktop 24.04 LTS

To Reproduce | 复现步骤

分别尝试了普通用户安装和 sudo 安装.

Additional context | 额外补充

安装过程的完整终端log:

mikami@LAPTOP-BU4O7VF4:~/works/cpp/llmapi$ curl -fsSL https://d2learn.org/xlings-install.sh | bash

 __   __  _      _
 \ \ / / | |    (_)    pre-v0.0.4
  \ V /  | |     _  _ __    __ _  ___
   > <   | |    | || '_ \  / _  |/ __|
  / . \  | |____| || | | || (_| |\__ \
 /_/ \_\ |______|_||_| |_| \__, ||___/
                            __/ |
                           |___/

repo:  https://github.com/d2learn/xlings
forum: https://forum.d2learn.org

---
Testing network...
Latency for github.com : 0.517 ms
Latency for gitee.com : 0.251 ms
Downloading xlings...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  117k    0  117k    0     0   286k      0 --:--:-- --:--:-- --:--:--  286k
Extracting files...
Running install.unix.sh...
[xlings]: start detect environment and try to auto config...
[xlings]: xmake installed
xmake v3.0.6+HEAD.8be7de5, A cross-platform build utility based on Lua
Copyright (C) 2015-present Ruki Wang, https://xmake.io
                         _
    __  ___ __  __  __ _| | ______
    \ \/ / |  \/  |/ _  | |/ / __ \
     >  <  | \__/ | /_| |   <  ___/
    /_/\_\_|_|  |_|\__ \|_|\_\____|
                         by ruki, xmake.io
    👉  Manual: https://xmake.io/guide/quick-start
    🙏  Donate: https://xmake.io/about/sponsor


Usage: $xmake [task] [options] [target]

Build targets if no given tasks.

Actions:
    b, build        Build targets if no given tasks.
    c, clean        Remove all binary and temporary files.
    f, config       Configure the project.
       create       Create a new project.
    g, global       Configure the global options for xmake.
    i, install      Package and install the target binary files.
    p, package      Package target.
    q, require      Install and update required packages.
    r, run          Run the project target.
       service      Start service for remote or distributed compilation and etc.
       test         Run the project tests.
    u, uninstall    Uninstall the project binary files.
       update       Update and uninstall the xmake program.

Plugins:
       check        Check the project sourcecode and configuration.
       doxygen      Generate the doxygen document.
       format       Format the current project.
    l, lua          Run the lua script.
    m, macro        Run the given macro.
       pack         Pack binary installation packages.
       plugin       Manage plugins of xmake.
       project      Generate the project file.
       repo         Manage package repositories.
       show         Show the given project information.
       watch        Watch the project directories and run command.

Common options:
    -q, --quiet                      Quiet operation.
    -y, --yes                        Input yes by default if need user confirm.
        --confirm=CONFIRM            Input the given result if need user confirm.
                                         - yes
                                         - no
                                         - def
    -v, --verbose                    Print lots of verbose information for users.
        --root                       Allow to run xmake as root.
    -D, --diagnosis                  Print lots of diagnosis information (backtrace, check info ..) only for
                                     developers.
                                     And we can append -v to get more whole information.
                                         e.g. $ xmake -vD
    -h, --help                       Print this help message and exit.

    -F FILE, --file=FILE             Read a given xmake.lua file.
    -P PROJECT, --project=PROJECT    Change to the given project directory.
                                     Search priority:
                                         1. The Given Command Argument
                                         2. The Envirnoment Variable: XMAKE_PROJECT_DIR
                                         3. The Current Directory

Command options (build):
        --version                    Print the version number and exit.
    -b, --build                      Build target. This is default building mode and optional.
    -r, --rebuild                    Rebuild the target.
    -a, --all                        Build all targets.
        --shallow                    Only re-build the given targets without dependencies.
    -g GROUP, --group=GROUP          Build all targets of the given group. It support path pattern matching.
                                     e.g.
                                         xmake -g test
                                         xmake -g test_*
                                         xmake --group=benchmark/*
        --dry-run                    Dry run to build target.

    -j JOBS, --jobs=JOBS             Set the number of parallel compilation jobs. (default: 18)
        --linkjobs=LINKJOBS          Set the number of parallel link jobs.
    -w, --warning                    Enable the warnings output. (deprecated)
        --linkonly                   Only link targets if object files have been compiled.
        --files=FILES                Build the given source files.
                                     e.g.
                                         - xmake --files=src/main.c
                                         - xmake --files='src/*.c' [target]
                                         - xmake --files='src/**.c|excluded_file.c'
                                         - xmake --files='src/main.c:src/test.c'

          target                     The target name. It will build all default targets if this parameter is not
                                     specified.
                                         - basic
                                         - c_basic
                                         - c_chat
                                         - c_hello_mcpp
                                         - chat
                                         - hello_mcpp
                                         - llmapi
                                         - llmapi_c
                                         - std_module
error: invalid task: xlings
[sudo] password for mikami:
tools/install.unix.sh: line 65: xlings: command not found
[xlings]: xlings installed

            run [ xlings help ] get more information
         after restart  cmd/shell  to refresh environment

Cleaning up...
Removing /home/mikami/works/cpp/llmapi/.xlings_software_install(tmpfiles)...
Installation completed!
mikami@LAPTOP-BU4O7VF4:~/works/cpp/llmapi$ xlings help
xlings: command not found
mikami@LAPTOP-BU4O7VF4:~/works/cpp/llmapi$ curl -fsSL https://d2learn.org/xlings-install.sh | bash

 __   __  _      _
 \ \ / / | |    (_)    pre-v0.0.4
  \ V /  | |     _  _ __    __ _  ___
   > <   | |    | || '_ \  / _  |/ __|
  / . \  | |____| || | | || (_| |\__ \
 /_/ \_\ |______|_||_| |_| \__, ||___/
                            __/ |
                           |___/

repo:  https://github.com/d2learn/xlings
forum: https://forum.d2learn.org

---
Testing network...
Latency for github.com : 0.391 ms
Latency for gitee.com : 0.244 ms
Downloading xlings...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  117k  100  117k    0     0   358k      0 --:--:-- --:--:-- --:--:--  358k
Extracting files...
Running install.unix.sh...
[xlings]: start detect environment and try to auto config...
[xlings]: xmake installed
xmake v3.0.6+HEAD.8be7de5, A cross-platform build utility based on Lua
Copyright (C) 2015-present Ruki Wang, https://xmake.io
                         _
    __  ___ __  __  __ _| | ______
    \ \/ / |  \/  |/ _  | |/ / __ \
     >  <  | \__/ | /_| |   <  ___/
    /_/\_\_|_|  |_|\__ \|_|\_\____|
                         by ruki, xmake.io
    👉  Manual: https://xmake.io/guide/quick-start
    🙏  Donate: https://xmake.io/about/sponsor


Usage: $xmake [task] [options] [target]

Build targets if no given tasks.

Actions:
    b, build        Build targets if no given tasks.
    c, clean        Remove all binary and temporary files.
    f, config       Configure the project.
       create       Create a new project.
    g, global       Configure the global options for xmake.
    i, install      Package and install the target binary files.
    p, package      Package target.
    q, require      Install and update required packages.
    r, run          Run the project target.
       service      Start service for remote or distributed compilation and etc.
       test         Run the project tests.
    u, uninstall    Uninstall the project binary files.
       update       Update and uninstall the xmake program.

Plugins:
       check        Check the project sourcecode and configuration.
       doxygen      Generate the doxygen document.
       format       Format the current project.
    l, lua          Run the lua script.
    m, macro        Run the given macro.
       pack         Pack binary installation packages.
       plugin       Manage plugins of xmake.
       project      Generate the project file.
       repo         Manage package repositories.
       show         Show the given project information.
       watch        Watch the project directories and run command.

Common options:
    -q, --quiet                      Quiet operation.
    -y, --yes                        Input yes by default if need user confirm.
        --confirm=CONFIRM            Input the given result if need user confirm.
                                         - yes
                                         - no
                                         - def
    -v, --verbose                    Print lots of verbose information for users.
        --root                       Allow to run xmake as root.
    -D, --diagnosis                  Print lots of diagnosis information (backtrace, check info ..) only for
                                     developers.
                                     And we can append -v to get more whole information.
                                         e.g. $ xmake -vD
    -h, --help                       Print this help message and exit.

    -F FILE, --file=FILE             Read a given xmake.lua file.
    -P PROJECT, --project=PROJECT    Change to the given project directory.
                                     Search priority:
                                         1. The Given Command Argument
                                         2. The Envirnoment Variable: XMAKE_PROJECT_DIR
                                         3. The Current Directory

Command options (build):
        --version                    Print the version number and exit.
    -b, --build                      Build target. This is default building mode and optional.
    -r, --rebuild                    Rebuild the target.
    -a, --all                        Build all targets.
        --shallow                    Only re-build the given targets without dependencies.
    -g GROUP, --group=GROUP          Build all targets of the given group. It support path pattern matching.
                                     e.g.
                                         xmake -g test
                                         xmake -g test_*
                                         xmake --group=benchmark/*
        --dry-run                    Dry run to build target.

    -j JOBS, --jobs=JOBS             Set the number of parallel compilation jobs. (default: 18)
        --linkjobs=LINKJOBS          Set the number of parallel link jobs.
    -w, --warning                    Enable the warnings output. (deprecated)
        --linkonly                   Only link targets if object files have been compiled.
        --files=FILES                Build the given source files.
                                     e.g.
                                         - xmake --files=src/main.c
                                         - xmake --files='src/*.c' [target]
                                         - xmake --files='src/**.c|excluded_file.c'
                                         - xmake --files='src/main.c:src/test.c'

          target                     The target name. It will build all default targets if this parameter is not
                                     specified.
                                         - basic
                                         - c_basic
                                         - c_chat
                                         - c_hello_mcpp
                                         - chat
                                         - hello_mcpp
                                         - llmapi
                                         - llmapi_c
                                         - std_module
error: invalid task: xlings
tools/install.unix.sh: line 65: xlings: command not found
[xlings]: xlings installed

            run [ xlings help ] get more information
         after restart  cmd/shell  to refresh environment

Cleaning up...
Removing /home/mikami/works/cpp/llmapi/.xlings_software_install(tmpfiles)...
Installation completed!
mikami@LAPTOP-BU4O7VF4:~/works/cpp/llmapi$ xlings
xlings: command not found
mikami@LAPTOP-BU4O7VF4:~/works/cpp/llmapi$ cd ~
mikami@LAPTOP-BU4O7VF4:~$ sudo curl -fsSL https://d2learn.org/xlings-install.sh | bash

 __   __  _      _
 \ \ / / | |    (_)    pre-v0.0.4
  \ V /  | |     _  _ __    __ _  ___
   > <   | |    | || '_ \  / _  |/ __|
  / . \  | |____| || | | || (_| |\__ \
 /_/ \_\ |______|_||_| |_| \__, ||___/
                            __/ |
                           |___/

repo:  https://github.com/d2learn/xlings
forum: https://forum.d2learn.org

---
Testing network...
Latency for github.com : 0.478 ms
Latency for gitee.com : 0.343 ms
Downloading xlings...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  117k    0  117k    0     0   280k      0 --:--:-- --:--:-- --:--:--  281k
Extracting files...
Running install.unix.sh...
[xlings]: start detect environment and try to auto config...
[xlings]: xmake installed
[xlings]: remove /home/xlings/.xlings - ok
[xlings]: xlings uninstalled - ok
[xlings]: create xlings home dir /home/xlings
[xlings]: install xlings to /home/xlings/.xlings
[xlings]: create rcachedir /home/xlings/.xlings_data
[xlings]: create bindir /home/xlings/.xlings_data/bin
[xlings]: copy profile to rcachedir...
[xlings]: copy xlings config file to rcachedir...
[xlings]: init xlings...
[xlings]: clean xlings runtimedir(tmp-cache) /home/xlings/.xlings_data/xim/runtimedir - ok
[xlings]: clean xlings tmp files - ok
[xlings]: config user environment...
[xlings]: config [bash] shell - /home/mikami/.bashrc
[xlings]: check xlings user group(only unix)...
[xlings]: create group xlings and add current user [mikami] to it(only-first)
[xlings]: add current /home/xlings owner to xlings group(only-first)
[xlings]: create and init subos linux dir /home/xlings/.xlings_data/subos/linux
[xlings: xim]: sync indexrepos...
[xlings: xim]: sync package index repo: https://gitee.com/sunrisepeak/xim-pkgindex.git
[xlings: xim]: sync sub-indexrepos...
[xlings: xim]: sync package index repo: https://gitee.com/xlings-res/xim-pkgindex-template.git
[xlings: xim]: _sync_repo: create rootdir: /home/xlings/.xlings_data/xim/xim-index-repos
[xlings: xim]: sync package index repo: https://github.com/d2learn/xim-pkgindex-fromsource.git
[xlings: xim]: sync package index repo: https://github.com/d2learn/xim-pkgindex-awesome.git
[xlings: xim]: sync package index repo: https://gitee.com/xlings-res/xim-pkgindex-d2x.git
[xlings: xim]: sync package index repo: https://github.com/d2learn/xim-pkgindex-scode.git
[xlings: xim]: save sub-indexrepos pass list to /home/xlings/.xlings_data/xim/xim-index-repos/xim-indexrepos.json
[xlings:xim]: rebuild index database
[xlings:xim]: update index database
[xlings:xim]: rebuild index for [main] namespace
[xlings:xim]: rebuild index for [xim] namespace
[xlings:xim]: rebuild index for [fromsource] namespace
[xlings:xim]: rebuild index for [awesome] namespace
[xlings:xim]: local pkgindex-build file found, start building...
Updated 0 paths from the index
[1/7] awesome::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-awesome/pkgs/f/fromsource.lua
[2/7] awesome::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-awesome/pkgs/a/awesome.lua
[3/7] awesome::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-awesome/pkgs/t/template.lua
[4/7] awesome::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-awesome/pkgs/x/xim.lua
[5/7] awesome::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-awesome/pkgs/d/dragonos.lua
[6/7] awesome::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-awesome/pkgs/d/d2x.lua
[7/7] awesome::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-awesome/pkgs/s/scode.lua
[xlings:xim]: rebuild index for [d2x] namespace
[xlings:xim]: local pkgindex-build file found, start building...
Updated 0 paths from the index
[1/2] d2x::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-d2x/pkgs/d/d2ds.lua
[2/2] d2x::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-d2x/pkgs/m/mcpp-standard.lua
[xlings:xim]: rebuild index for [scode] namespace
[xlings:xim]: local pkgindex-build file found, start building...
Updated 0 paths from the index
[1/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/r/readline.lua
[2/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/u/util-linux.lua
[3/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/z/zlib.lua
[4/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/a/automake.lua
[5/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/g/gdbm.lua
[6/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/p/pango.lua
[7/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/l/linux.lua
[8/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/l/libffi.lua
[9/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/l/libnsl.lua
[10/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/l/linux-headers.lua
[11/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/n/ncurses.lua
[12/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/o/openssl.lua
[13/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/x/xz-utils.lua
[14/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/s/sqlite.lua
[15/15] scode::/home/xlings/.xlings_data/xim/xim-index-repos/xim-pkgindex-scode/pkgs/b/bzip2.lua
[xlings:xim]: update index database
[xlings:xim]: create pm executor for <xvm@0.0.5> ...

--- [package] info

name: xvm
version: 0.0.5
authors: sunrisepeak
maintainers: d2learn
contributors: https://github.com/d2learn/xlings/graphs/contributors
licenses: Apache-2.0
repo: https://github.com/d2learn/xlings

        a simple and generic version management tool

[xlings:xim]: checking [xvm@0.0.5] for mutex groups...
[xlings]: downloading: https://gitcode.com/xlings-res/xvm/releases/download/0.0.5/xvm-0.0.5-linux-x86_64.tar.gz to /home/xlings/.xlings_data/xim/runtimedir/xvm-0.0.5-linux-x86_64.tar.gz
curl: (28) Failed to connect to file-cdn.gitcode.com port 443 after 131480 ms: Couldn't connect to server

exec("/usr/bin/curl" -L -# -o /home/xlings/.xlings_data/xim/runtimedir/xvm-0.0.5-linux-x86_64.tar.gz https://gitcode.com/xlings-res/xvm/releases/download/0.0.5/xvm-0.0.5-linux-x86_64.tar.gz) failed(28)

        Please check your network environment

[xlings:xim]: download failed, start to detect all mirror and retry...
[xlings]: Latency of URL 'https://github.com/xlings-res/xvm/releases/download/0.0.5/xvm-0.0.5-linux-x86_64.tar.gz': 206.249ms
[xlings]: Latency of URL 'https://gitcode.com/xlings-res/xvm/releases/download/0.0.5/xvm-0.0.5-linux-x86_64.tar.gz': 74.011ms
[xlings]: downloading: https://gitcode.com/xlings-res/xvm/releases/download/0.0.5/xvm-0.0.5-linux-x86_64.tar.gz to /home/xlings/.xlings_data/xim/runtimedir/xvm-0.0.5-linux-x86_64.tar.gz
curl: (28) Failed to connect to gitcode.com port 443 after 133538 ms: Couldn't connect to server

exec("/usr/bin/curl" -L -# -o /home/xlings/.xlings_data/xim/runtimedir/xvm-0.0.5-linux-x86_64.tar.gz https://gitcode.com/xlings-res/xvm/releases/download/0.0.5/xvm-0.0.5-linux-x86_64.tar.gz) failed(28)

        Please check your network environment

[xlings:xim]: download or sha256-check failed
[xlings:xim]: hooks: download or build failed

             反馈 & 交流 | Feedback & Discourse
        (if encounter any problem, please report it)

        https://forum.d2learn.org/category/9/xlings
        https://github.com/d2learn/xlings/issues

[xlings:xim]: xvm@0.0.5 install failed or not support, clear cache and retry

--- [package] info

name: xvm
version: 0.0.5
authors: sunrisepeak
maintainers: d2learn
contributors: https://github.com/d2learn/xlings/graphs/contributors
licenses: Apache-2.0
repo: https://github.com/d2learn/xlings

        a simple and generic version management tool

-> install xvm@0.0.5? (y/n)
             反馈 & 交流 | Feedback & Discourse
        (if encounter any problem, please report it)

        https://forum.d2learn.org/category/9/xlings
        https://github.com/d2learn/xlings/issues

link [ xvm ] to global - /usr/bin/xvm
error: cannot exec(xvm add xim 0.0.4 --alias "xlings install"), No such file or directory
[xlings]: xlings installed

            run [ xlings help ] get more information
         after restart  cmd/shell  to refresh environment

mikami@LAPTOP-BU4O7VF4:~$ xlings
xlings version: 0.0.4

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions