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

Replace detect-libc with isAlpine check? #101

Closed
vweevers opened this issue Apr 5, 2019 · 3 comments
Closed

Replace detect-libc with isAlpine check? #101

vweevers opened this issue Apr 5, 2019 · 3 comments
Labels
question Support or open question(s)

Comments

@vweevers
Copy link
Member

vweevers commented Apr 5, 2019

Same as in node-gyp-build, we can do:

var platform = os.platform()
var libc = process.env.LIBC || (isAlpine(platform) ? 'musl' : 'glibc')

function isAlpine (platform) {
  return platform === 'linux' && fs.existsSync('/etc/alpine-release')
}

This is much more lightweight, see prebuild/node-gyp-build#14 (comment).

@lovell (as the author of #55) any objections?

@vweevers vweevers added the question Support or open question(s) label Apr 5, 2019
@vweevers
Copy link
Member Author

vweevers commented Apr 5, 2019

While we're at it, let's also read env.npm_config_libc to support npm i --libc=musl. That use case makes more sense than what we currently support (prebuild-install --libc=musl).

@lovell
Copy link
Member

lovell commented Apr 5, 2019

I think the desire is to correctly detect musl libc, of which Alpine Linux is just one consumer.

An increasing number of Linux flavours also use musl libc but won't have /etc/alpine-release, e.g. Void, OpenWrt.

The existsSync check proposed here would make a good addition to detect-libc and could occur before spawning any processes if that's a problem. Happy to accept a PR.

@vweevers
Copy link
Member Author

vweevers commented Apr 5, 2019

The existsSync check proposed here would make a good addition to detect-libc and could occur before spawning any processes if that's a problem

Nah, it would still spawn processes if the platform is not Alpine, which is more common. And in the context of detect-libc it's probably more important to be correct (e.g. older Alpine does use glibc).

An increasing number of Linux flavours also use musl libc but won't have /etc/alpine-release, e.g. Void, OpenWrt.

Roger.

@vweevers vweevers closed this as completed Apr 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Support or open question(s)
Projects
None yet
Development

No branches or pull requests

2 participants