asdf-bun icon indicating copy to clipboard operation
asdf-bun copied to clipboard

listing all versions fails silently

Open nurrony opened this issue 2 years ago • 9 comments

I have installed this plugin to manage bun. Right after installing this plugin, I executed the following command and please check the snap for details.

asdf list all bun
snapshot-20231006111859@2x

Here are other relevant informations

Output of asdf info

OS:
Darwin Nurs-MacBook-Pro.local 21.6.0 Darwin Kernel Version 21.6.0: Fri Sep 15 16:17:23 PDT 2023; root:xnu-8020.240.18.703.5~1/RELEASE_X86_64 x86_64

SHELL:
zsh 5.8.1 (x86_64-apple-darwin21.0)

BASH VERSION:
5.2.15(1)-release

ASDF VERSION:
v0.13.1-0586b37

ASDF INTERNAL VARIABLES:
ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=.tool-versions
ASDF_DATA_DIR=/Users/nurrony/.asdf
ASDF_DIR=/Users/nurrony/.zi/plugins/asdf-vm---asdf
ASDF_CONFIG_FILE=/Users/nurrony/.asdfrc

ASDF INSTALLED PLUGINS:
bun                          https://github.com/cometkim/asdf-bun.git main 51d18b3

nurrony avatar Oct 06 '23 05:10 nurrony

Umm, do you have set $GITHUB_API_TOKEN in your env? If so try:

curl \
    -H 'Accept: application/vnd.github+json' \
    -H "Authorization: token $GITHUB_API_TOKEN" \
    "https://api.github.com/repos/oven-sh/bun/releases"

cometkim avatar Oct 06 '23 07:10 cometkim

@cometkim, I don't have GITHUB_API_TOKEN in my env. Do I need to one? if yes, does it not sound little inconvenient?

nurrony avatar Oct 08 '23 04:10 nurrony

No, I thought there was no way to get any error then. 🤔

cometkim avatar Oct 08 '23 05:10 cometkim

@cometkim I just tried your curl command by setting GITHUB_API_TOKEN as System Environment Variable. It works fine. But when I run asdf list all bun getting this following error. snapshot-20231008134909@2x

nurrony avatar Oct 08 '23 07:10 nurrony

Can you try asdf plugin update bun and again?

cometkim avatar Oct 10 '23 10:10 cometkim

@cometkim no luck back to the square 1 :(

❯ asdf plugin update bun
Location of bun plugin: /Users/nurrony/.asdf/plugins/bun
Updating bun to main
From https://github.com/cometkim/asdf-bun
   51d18b3..a79462c  main       -> main
   51d18b3..a79462c  main       -> origin/main
Already on 'main'
Your branch is up to date with 'origin/main'.

❯ asdf list all bun
Plugin bun's list-all callback script failed with output:
<no output nothing>

nurrony avatar Oct 10 '23 15:10 nurrony

umm, I cannot reproduce the issue on same environment, maybe it is better to debug on your end

here is a standalone script equivalent to the list-all

#!/usr/bin/env bash

set -eo pipefail

GITHUB_REPO="oven-sh/bun"
REPO_URL="https://github.com/$GITHUB_REPO"

curl_opts=(-fsSL)
if [ -n "${GITHUB_API_TOKEN:-}" ]; then
  curl_opts=("${curl_opts[@]}" -H "Authorization: token $GITHUB_API_TOKEN")
fi

function sort_versions() {
  sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' |
    LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}'
}

function list_github_releases() {
  curl "${curl_opts[@]}" \
    -H "Accept: application/vnd.github+json" \
    "https://api.github.com/repos/$GITHUB_REPO/releases" |
    grep -o '"tag_name": "bun-v.*"' |
    sed -E 's/"tag_name": "bun-v(.*)"/\1/'
}

list_github_releases | sort_versions | sed 1,11d | xargs echo

Can you try this and report back what you find?

cometkim avatar Oct 10 '23 16:10 cometkim

@cometkim it does not return any result. same as asdf list all bun. Sorry for replying late.

nurrony avatar Oct 18 '23 16:10 nurrony

As you can see, it's not much.

To make it precise, you can test the commands one by one without piping. just list_github_realeases first.

Excluding s(slient) from curl_opts also help.

cometkim avatar Oct 18 '23 17:10 cometkim