Skip to content

[Bug] install.sh cannot resolve latest with wget only: LATEST_URL is undefined #1456

Closed

Description

@dongyikuan919

Describe the Bug

On current main (7de51a87a13f89de1084f07d9ded9c4603b4da9a), scripts/install.sh supports curl or wget, but resolve_version() cannot resolve the default latest version in the wget-only GitHub path.

Line 851 references $LATEST_URL. This variable is not initialized anywhere in the script, which enables set -eu. The expansion fails before wget runs, and installation exits with status 1.

Steps to Reproduce

The following exercises the actual installer function without downloading or installing anything. The script's final main invocation is removed in memory, and the downloader is stubbed to make the wget-only path deterministic.

Run from the repository root:

env -u LATEST_URL node <<'JS'
const fs = require('fs');
const { spawnSync } = require('child_process');
const source = fs.readFileSync('scripts/install.sh', 'utf8')
  .replace(/\nmain\s*$/, '\n');
const harness = `
need_cmd() { [ "$1" = wget ]; }
wget() { printf 'Location: https://github.com/DingTalk-Real-AI/dingtalk-workspace-cli/releases/tag/v1.2.3\\n' >&2; }
VERSION=latest
GITEE_REPO=""
resolve_version
printf 'resolved=%s\\n' "$VERSION"
`;
const result = spawnSync('/bin/sh', ['-c', source + harness], {
  env: process.env, encoding: 'utf8'
});
console.log(result.stdout + result.stderr);
console.log('exit=' + result.status);
JS

Expected Behavior

The wget-only path resolves the GitHub release tag using the repository's /releases/latest URL, as the curl branch already does. The stubbed reproduction should print resolved=v1.2.3 and exit 0.

Actual Behavior

/bin/sh: line 851: LATEST_URL: unbound variable
  ❌ Could not determine the latest version. Set DWS_VERSION explicitly.
exit=1

Environment

  • Source: main at 7de51a87a13f89de1084f07d9ded9c4603b4da9a (2026-09-30).
  • Reproduction: macOS, /bin/sh, Node.js v22.23.1; no CLI build or DingTalk credentials required.
  • Scope: default latest, GitHub source, wget available and curl unavailable. Explicit DWS_VERSION avoids this resolver branch.

Additional Context

Replacing only "$LATEST_URL" in memory with "https://github.com/${REPO}/releases/latest" makes the same stubbed reproduction succeed. This confirms the undefined variable is the failure point; real wget/network redirect behavior is not covered by this isolated test.

Suggested regression coverage: latest-version resolution with curl unavailable, wget available, and no inherited LATEST_URL.

Activity

  1. added a commit that references this issue on Oct 13, 2026
    caf79b4
  2. haofeng0705 commented on Oct 16, 2026

    @haofeng0705
    Collaborator

    Hi @dongyikuan919,感谢你提供清晰的定位和隔离复现。

    这个未初始化变量问题已在 PR #1492 修正,并包含于正式版 v1.0.64。

    • 根因:wget 分支读取未定义的 LATEST_URL,在 set -u 下展开失败,尚未发出下载请求就退出。
    • 修复方式:与 curl 分支一样,直接使用当前仓库的 GitHub /releases/latest URL 解析版本,不再依赖该变量。
    1. 请重新获取 v1.0.64 的安装脚本,避免继续执行保存的旧脚本。
    2. 如果已将脚本保存为当前目录的 install.sh,可显式指定版本安装:
    DWS_VERSION=v1.0.64 sh ./install.sh

    固定版本只跳过 latest 解析,不保证资产下载网络可达;自动切换 Gitee 也是另一条安装路径。

    以上是基于发布记录及版本源码的静态分析判断,我们本次未在你的环境运行真实 wget 或完整安装验证。我们先按已发布修复关闭这个 Issue;如果使用最新脚本仍有问题,请继续回复系统/架构、wget 版本、脚本来源、完整命令及脱敏错误输出,我们会继续跟进。感谢反馈,欢迎继续交流。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions