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

Created on 19 Sep 2018  Β·  17Comments  Β·  Source: parcel-bundler/parcel

πŸ› bug report

Parcel works fine but gives lscpu: not found warning on Alpine Linux.

πŸŽ› Configuration (.babelrc, package.json, cli command)

parcel index.html

{
    "presets": ["@babel/preset-env"]
}

πŸ€” Expected Behavior

There should be no warnings.

😯 Current Behavior

β ‹ Building.../bin/sh: lscpu: not found

πŸ’ Possible Solution

Use something more widespread than lscpu that will be available in Alpine Linux.

πŸ”¦ Context

Parcel works fine, not sure whether it affects me in any practical way.

πŸ’» Code Sample

🌍 Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel |1.10.0-beta.1
| Node |10.10.0
| npm/Yarn |6.4.1
| Operating System |Alpine Linux

Bug

Most helpful comment

@DeMoorJasper
I think it worth adjusting this error with message like:

Building.../bin/sh: [Warning] lscpu: not found. "os.cpus" fallback used instead

So that user will not get confused with that and won't go and post yet another issue on Github.

All 17 comments

This is a warning not a bug, it falls back to os.cpus if you have sufficient permissions or it simply isn’t there.

So it already uses something else on that platform.

Sent with GitHawk

@DeMoorJasper

From the console output, we cannot tell whether it's an error or warning. It makes me nervous when I see this (I was building a docker image).

Is there anything working differently when it falls back to os.cpus? If not, I think there's no need to show even a warning.

@DeMoorJasper
I think it worth adjusting this error with message like:

Building.../bin/sh: [Warning] lscpu: not found. "os.cpus" fallback used instead

So that user will not get confused with that and won't go and post yet another issue on Github.

Please state this is a warning...

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.

@louh for the n00bs among us, can you please let us know where we're supposed to set the PARCEL_WORKERS=1?

I'm getting this error when I try to build my alpine docker image.

image

for the n00bs among us, can you please let us know where we're supposed to set the

it's just an environment variable, on linux/macos you can do
PARCEL_WORKERS=1 parcel build src/index.html

@louh your error is not /bin/sh: lscpu: not found. That's harmless. Your error is Can't read /app/browserslist config.

@bard how does one overcome the error?

@bard you tagged me, but I think you meant @JwanKhalaf.

@louh correct, apologies!

Getting this issue as well via NixOS build:

these derivations will be built:
  /nix/store/h4sczs8kh3b76r03vr4nzq9dlyhg6y7f-html5-boilerplate.drv
building '/nix/store/h4sczs8kh3b76r03vr4nzq9dlyhg6y7f-html5-boilerplate.drv'...
unpacking sources
unpacking source archive /nix/store/jh7kw2iiaxrj7nc07pzy3qg3lsqg0i31-v7.1.0.tar.gz
source root is html5-boilerplate-7.1.0
setting SOURCE_DATE_EPOCH to timestamp 1553027867 of file html5-boilerplate-7.1.0/test/file_existence.js
patching sources
configuring
no configure script, doing nothing
building
no Makefile, doing nothing
installing
/bin/sh: lscpu: not found
🚨  /build/html5-boilerplate-7.1.0/dist/css/normalize.css:undefined:undefined: Failed to install babel-preset-env.
    at PromiseQueue.install [as process] (/nix/store/5qrdimch8fgqgyp5z705mhscrh1l387v-node-parcel-bundler-1.12.3/lib/node_modules/parcel-bundler/src/utils/installPackage.js:46:11)
    at process._tickCallback (internal/process/next_tick.js:68:7)
note: keeping build directory '/tmp/nix-build-html5-boilerplate.drv-6'
builder for '/nix/store/h4sczs8kh3b76r03vr4nzq9dlyhg6y7f-html5-boilerplate.drv' failed with exit code 1
error: build of '/nix/store/h4sczs8kh3b76r03vr4nzq9dlyhg6y7f-html5-boilerplate.drv' failed

Exporting PARCEL_WORKERS=1 prevents the lscpu warning, but doesn't fix the installation.

Running parcel: 1.12.3

I think my above issue was to do with being inside a read-only directory. I don't have time to look into this any further right now.

@DeMoorJasper @mischnic
I see the issue is closed. Does that mean you're not planning to make this warning any way friendlier that it is now?
I understand that's a little stuff and not really worth changing from effort perspective, but end users are really unsatisfied with that.

What I would do is keep this issue open until you have time to make the log friendlier / swap lscpu with some other stuff / etc.
This can be done either by you or some other contributor, but by closing the issue you say that you don't care about that, ie don't care about users who are confused with that and force them digging through the issues to find this and ensure this is at least not a bug.

I see the issue is closed. Does that mean you're not planning to make this warning any way friendlier that it is now?

This warning comes from a dependency and not Parcel itself.

What I would do is keep this issue open until you have time to make the log friendlier / swap lscpu with some other stuff / etc.

Agree.
Actually, I just saw that #2555 is also open and contains more technical discussion/possible changes.

I have same issue with below setup
Dockerfile

FROM node:8.12.0-alpine AS runtime
WORKDIR /app
ENV NODE_ENV development
RUN yarn install
COPY . .
ENV NODE_ENV production
RUN yarn build
CMD ["node","server.js"]

package.json

"scripts": {
    "build": "rm -rf ./dist && ./node_modules/.bin/parcel build ./client/index.html --out-dir server/build",
    }

when running docker build -t myimage:test . will throw below errors

Step 7/8 : RUN yarn build
 ---> Running in 97d13125c18f
yarn run v1.9.4
$ rm -rf ./dist && ./node_modules/.bin/parcel build ./client/index.html --out-dir server/build
/bin/sh: ./node_modules/.bin/parcel: not found
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 127.
The command '/bin/sh -c yarn build' returned a non-zero code: 1
Was this page helpful?
0 / 5 - 0 ratings