Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: install.sh fails due to 403 #357

Open
polarathene opened this issue Sep 24, 2024 · 3 comments
Open

[BUG]: install.sh fails due to 403 #357

polarathene opened this issue Sep 24, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@polarathene
Copy link

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):

vfox/install.sh

Lines 16 to 23 in 8968974

# Get the latest version
VERSION=$(curl --silent "https://api.github.com/repos/version-fox/vfox/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c 2-)
if [ -z "$VERSION" ]; then
echo "Failed to get the latest version. Please check your network connection and try again."
exit 1
fi
echo "Installing vfox v$VERSION ..."

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 polarathene added the bug Something isn't working label Sep 24, 2024
@polarathene
Copy link
Author

polarathene commented Sep 24, 2024

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

@bytemain
Copy link
Member

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)

@polarathene
Copy link
Author

polarathene commented Sep 25, 2024

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:

echo "Installing vfox v$VERSION ..."

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:

vfox/install.sh

Lines 46 to 70 in 8968974

tar -zxvf $TAR_FILE
if [ $? -ne 0 ]; then
echo "Failed to extract vfox binary. Please check if the downloaded file is a valid tar.gz file."
exit 1
fi
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
if [ -d "/usr/local/bin" ]; then
sudo mv "${FILENAME}/vfox" /usr/local/bin
else
echo "/usr/local/bin is not a directory. Please make sure it is a valid directory path."
exit 1
fi
if [ $? -ne 0 ]; then
echo "Failed to move vfox to /usr/local/bin. Please check your sudo permissions and try again."
exit 1
fi
rm $TAR_FILE
rm -rf $FILENAME

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants