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

Install process does not stop when installing without git command #359

Closed
smeghead opened this issue Oct 11, 2024 · 7 comments · Fixed by #360
Closed

Install process does not stop when installing without git command #359

smeghead opened this issue Oct 11, 2024 · 7 comments · Fixed by #360
Assignees
Labels
bug Something isn't working

Comments

@smeghead
Copy link
Contributor

Q A
OS Linux
Shell bash
bashunit version 0.17.0

Summary

When installing in an environment where the git command does not exist, the message bashunit has been installed in the 'lib' folder appears even though the installation fails.

Current behavior

If you run the installation in an environment where the git command does not exist, you will get the following output.

root@173b17c8788d:/usr/src# curl -s https://bashunit.typeddevs.com/install.sh | bash
main: line 8: git: command not found
> Downloading the latest version: ''
> bashunit has been installed in the 'lib' folder

An error message is displayed because the git command does not exist.
However, the process continues and bashunit has been installed is also displayed.

How to reproduce

Perform the installation in an environment where the git command does not exist.

Expected behavior

If the git command is not present during installation, an error message is displayed and the process should stop.

If users see the message bashunit has been installed in the 'lib' folder, users may think that the installation was successful.

@smeghead smeghead added the bug Something isn't working label Oct 11, 2024
@Chemaclass Chemaclass moved this to Todo in bashunit Oct 11, 2024
@Chemaclass
Copy link
Member

Good catch!! Want to try to solve it, @smeghead ?

# add this function at the top above `get_latest_tag (eg line 7)`
function check_git_is_installed() {
  if ! command -v git >/dev/null 2>&1; then
    echo "Error: git is not installed." >&2
    exit 1
  fi
}
# then call this function before calling the `install` (eg line 57)

@smeghead
Copy link
Contributor Author

@Chemaclass
Thank you, I am going to try to resolve this.

@khru
Copy link
Member

khru commented Oct 11, 2024

Good catch!! Want to try to solve it, @smeghead ?

# add this function at the top above `get_latest_tag (eg line 7)`
function check_git_is_installed() {
  if ! command -v git >/dev/null 2>&1; then
    echo "Error: git is not installed." >&2
    exit 1
  fi
}
# then call this function before calling the `install` (eg line 57)

Or maybe you can remove the git dependency from the installer, if you can do that I think that would also be a valid solution.

Basically, it would be that the installer does not require the use of git

@smeghead
Copy link
Contributor Author

@khru
I was also just thinking that the normal installation could eliminate the git dependency.

I will make another pull request when I come up with idea.

@Chemaclass
Copy link
Member

I think it's not possible to remove git when installing the beta version build_and_install_beta because this is downloading the project (latest main branch) and building the project on the same machine.
Therefore, what I would suggest is:

  1. require git ONLY inside build_and_install_beta
  2. instead of having this function get_latest_tag we can remove it entirely and use a hardcoded number that must be setup during a new release (see .github/RELEASE.md for the whole process)
    • It would be similar as the first step doing "Update the version in BASHUNIT_VERSION in ./bashunit"

@smeghead
Copy link
Contributor Author

@Chemaclass
Yes, I too think it is impossible to make install.sh completely independent of git.

When installing a version other than beta, git is only used to ask for the LATEST_BASHUNIT_VERSION.

I was wondering if it is possible to get the LATEST_BASHUNIT_VERSION by using curl or something similar.

For example, it might be possible to get the information from the following URL. (However, I find it more stable and reliable to get it from the git command.)

curl -s https://api.github.com/repos/TypedDevs/bashunit/tags

The above is a possibility.
I can't judge how important it is to reduce your dependence on git.

@Chemaclass
Copy link
Member

Chemaclass commented Oct 12, 2024

@smeghead it is not that important right now. You can focus on other areas to improve :)

UPDATE: #365

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
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants