vfox icon indicating copy to clipboard operation
vfox copied to clipboard

[BUG]: `install.sh` fails due to 403

Open polarathene opened this issue 1 year ago • 3 comments

Version 0.5.5

OS Linux

Describe the bug

Manual installation instruction fails:

$ curl -sSL https://raw.githubusercontent.com/version-fox/vfox/main/install.sh | bash
Failed to get the latest version. Please check your network connection and try again.

This is due to the curl call to get the version (NOTE: This will also fail the earlier check if only wget available):

https://github.com/version-fox/vfox/blob/89689740184e2e5c26377107441028002ffb373d/install.sh#L16-L23

The failure is due to 403 status:

$ curl -fsSL "https://api.github.com/repos/version-fox/vfox/releases/latest"
curl: (22) The requested URL returned error: 403

You should not rely on user session to install. I tried to use vfox in a container on WSL2.

polarathene avatar Sep 24 '24 23:09 polarathene

I installed this way instead:

curl -fsSL https://github.com/version-fox/vfox/releases/download/v0.5.5/vfox_0.5.5_linux_x86_64.tar.gz \
  | tar -xz -C /usr/local/bin --strip-components=1 vfox_0.5.5_linux_x86_64/vfox

If you improve your GH release process, this could be simpler.

  • Don't use version in asset name.
  • Don't include directory in archive (or at least not one with version

Then it would look like this:

curl -fsSL https://github.com/version-fox/vfox/releases/download/v0.5.5/vfox_linux_x86_64.tar.gz \
  | tar -xz -C /usr/local/bin vfox

Now only the version tag is in the URL. This allows to also get the latest version released:

curl -fsSL https://github.com/version-fox/vfox/releases/latest/download/vfox_linux_x86_64.tar.gz \
  | tar -xz -C /usr/local/bin vfox

polarathene avatar Sep 24 '24 23:09 polarathene

This might because github api has rate limit, we can add some tips like: Error: Request https://api.github.com/repos/xxxxx failed with status code: 403 (you may be rate limited)

bytemain avatar Sep 25 '24 05:09 bytemain

we can add some tips

If you modify your release process, you will not need to use api.github.com, except for getting a version. Just delay this line:

https://github.com/version-fox/vfox/blob/89689740184e2e5c26377107441028002ffb373d/install.sh#L23

Show that after the binary is downloaded and extracted and now you have the version

$ vfox --version
vfox version 0.5.5

All of this can be simplified:

https://github.com/version-fox/vfox/blob/89689740184e2e5c26377107441028002ffb373d/install.sh#L46-L70

Example:

  sudo mkdir -p /usr/local/bin
  if [ $? -ne 0 ]; then
    echo 'Failed to create /usr/local/bin directory. Please check your sudo permissions and try again.'
    exit 1
  fi

  local VFOX_LATEST_RELEASE_URL="https://github.com/version-fox/vfox/releases/latest/download/vfox_${OS_TYPE}_${ARCH_TYPE}.tar.gz"
  curl -fsSL "${VFOX_LATEST_RELEASE_URL}" | sudo tar -vxz -C /usr/local/bin vfox
  if [ $? -ne 0 ]; then
    echo 'Failed to extract vfox to /usr/local/bin. Please check your sudo permissions and try again.'
    exit 1
  fi

  echo "$(vfox --version) installed successfully!"

No need for rm or mv. curl will pipe the .tar.gz archive straight into the tar command, which will extract and move vfox for you.

To make this work you will need to publish to GH Releases with changes I mentioned:

  • Don't use version in asset name.
  • Don't include directory in archive (or at least not one with version

UPDATE: Sorry, I forgot that you also support wget. For wget to output download to stdout, you must use wget -O - (the long option name for -O is --output-file, provide - as the "file" for stdout)

polarathene avatar Sep 25 '24 06:09 polarathene