Parcel: /bin/sh: lscpu: not found on Alpine Linux

Created on 18 Jan 2019  路  8Comments  路  Source: parcel-bundler/parcel

馃檵 Feature Request

In order to make the tool more user-friendly it is nice to have separation between:

  • error messages, that considerably affect how the tool works (like functionality, performance, etc.);
  • warning messages, that just states something that might be useful for someone.

馃槸 Current Behavior

A red-colored message appears in console which states:
/bin/sh: lscpu: not found

From user's perspective the message text and color is confusing and forces to investigate it's cause - check other platforms, understand whether there is a fallback for this functionality, ensure the user's application build is made聽without any issues.

馃拋 Possible Solution

As as user I would be happy to see that it's just a warning that brings some non-critical information.
This may be done by changing the message color to something less shocking (e.g. yellow) and changing the message text to something like:
/bin/sh: lscpu: not found. "os.cpus" fallback is used instead

馃敠 Context

Got this problem while building UI application with docker using Alpine image, e.g.
FROM node:11-alpine

馃捇 Examples

Decided to ask you again since there was an opened issue before (#2031) and it is yet not solved.

PS not sure if that's really a feature request or a bug

Bug

Most helpful comment

Why are you using lscpu at all?
uname -p will give you the architecture and nproc the number of cores

All 8 comments

@mischnic /bin/sh: lscpu: not found will be the shells output when calling lscpu and it not being found, it's not an error omitted by any JS code specifically.

The catch(err) should probably trigger?(add a console.log() to verify?), if so a helpful message that a fallback is being used instead could be output there.

@abramenal I've seen this issue with Alpine image projects elsewhere(I'm not presently using Parcel myself, just saw this issue while looking into Parcel), afaik it's nothing to worry about as it uses a fallback, but you could also just install lscpu(it's in the util-linux package) into your alpine image if you want to avoid that error.

Do note this isn't a bug specific to Parcel, I don't think they can hide/change that line you're getting as it's a result of the package they use calling the command. They could print a more helpful message afterwards afaik to handle this better.

I agree a warning would be way more user friendly.

Another workaround that hasn't been mentioned here but I'll add it for reference: if you know what the cpu count is on your machine you can set the environment variable PARCEL_WORKERS to that amount or just PARCEL_WORKERS=1 as a safe option. If this is set, then Parcel doesn't try to detect the cpu count itself and it will never attempt to run lscpu. Here it is in the docs.

Why are you using lscpu at all?
uname -p will give you the architecture and nproc the number of cores

Any progress on that?

@abramenal this is an issue with the physical cpu count package, I'll move it into the parcel monorepo and open a PR later today, so this error hopefully no longer occurs in Parcel 2.

@DeMoorJasper cool!
Let me know if I can help with anything

Opened the PR, it uses nproc first and after that tries lscpu so it should work on alpine and in case it fails it does it silently so it does not alarm anyone as it would have no effect, besides maybe a small performance decrease. See #4029

Was this page helpful?
0 / 5 - 0 ratings