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

enhancement: notify if installing on Alpine #233

Closed
mefellows opened this issue Aug 5, 2022 · 5 comments
Closed

enhancement: notify if installing on Alpine #233

mefellows opened this issue Aug 5, 2022 · 5 comments

Comments

@mefellows
Copy link
Member

Alpine is not officially supported, and is fraught with problems due to its use of musl over glibc.

See also pact-foundation/pact-net#387 (comment).

If we can detect the alpine OS at pact-go install (or other CLI calls) we could print out a notice warning users of potential issues.

@maranix
Copy link
Contributor

maranix commented Oct 11, 2022

Hi!
I would like to work on this issue but i am not quite sure how to approach it correctly. I do have a working solution currently ready but before opening a pr, I thought it would be best to discuss more about this.

My current approach and solution is like this :-

  1. Check if the OS is Linux.
  2. Look for sh shell in the OS environment path.
  3. Grep the OS ID from /etc/*-release
  4. Check whether the ID is alpine.
  5. Print an Info message if it is otherwise continue on checking installation and binaries.

All of those steps happen on running pact-go install

My concerns about the above approach :-

  1. What if sh shell does not exist on the system? Should we fall back to a different shell?
  2. Isn't there any better way other than grep-ing the system info through a shell?

@mefellows
Copy link
Member Author

Thanks for picking this up - much appreciated!

What's the point of step (2) sorry?

Print an Info message if it is otherwise continue on checking installation and binaries.

I think we should print a WARN level here, even if the user has compiled their own alpine target of the library. What do you think?

The main issue with alpine is not simply alpine, but it's use of the musl library. So another approach could be to detect the presence of musl (or absence of glibc). There are various ways to do that, but executing ldd on any known binary and then doing a string match (in golang) on the result should be enough to detect the presence of musl, and warn about it.

@maranix
Copy link
Contributor

maranix commented Oct 11, 2022

Thank you for the input!

What's the point of step (2) sorry?

Print an Info message if it is otherwise continue on checking installation and binaries.

I think we should print a WARN level here, even if the user has compiled their own alpine target of the library. What do you think?

I was printing the INFO level message while testing my implementation and did not really pay attention that much. Now that you have pointed it out, It does make a lot of sense to just print out a WARN level message. I will keep that in mind.

The main issue with alpine is not simply alpine, but it's use of the musl library. So another approach could be to detect the presence of musl (or absence of glibc). There are various ways to do that, but executing ldd on any known binary and then doing a string match (in golang) on the result should be enough to detect the presence of musl, and warn about it.

I see, this approach is way better than mine. Thanks!

@mefellows
Copy link
Member Author

No worries, thanks!

@maranix
Copy link
Contributor

maranix commented Nov 2, 2022

Solution merged in #246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants