# Resolve "The command '/bin/sh -c apk update && apk add jq' returned a non-zero code: 1"

**URL:** <https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118>\
**Category:** Product support\
**Created:** [July 18, 2019, 4:28pm UTC](https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118 "2019-07-18T16:28:08Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![agaurav](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@agaurav](https://forums.balena.io/u/agaurav)\
**Post date:** [July 18, 2019, 4:28pm UTC](https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118/1 "2019-07-18T16:28:08Z")

</div>

My base image in the dockerfile is  
**FROM balenalib/generic-armv7ahf-debian:jessie-build**

and I am trying to build by using the following commands  
**balena build --deviceType beaglebone-black --arch armv7hf --emulated**

Can someone please tell me how to fix it.

---

<div class="post-metadata">

**Author:** ![CameronDiver](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@CameronDiver](https://forums.balena.io/u/CameronDiver)\
**Post date:** [July 18, 2019, 4:33pm UTC](https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118/2 "2019-07-18T16:33:42Z")

</div>

Hey, `apk` is only available when using alpine based base images. To install jq in debian based base images, you need to use `apt-get`.

---

<div class="post-metadata">

**Author:** ![agaurav](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@agaurav](https://forums.balena.io/u/agaurav)\
**Post date:** [July 18, 2019, 4:37pm UTC](https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118/3 "2019-07-18T16:37:25Z")

</div>

Thanks @CameronDiver but I am not using apk anywhere in my docker file. I use apt-get to install the libraries. Below is a portion of my Dockerfile. Can you see anything which might be using the apk.

FROM balenalib/generic-armv7ahf-debian:jessie-build

ENV INITSYSTEM on  
ENV DBUS\_SYSTEM\_BUS\_ADDRESS unix:path=/host/run/dbus/system\_bus\_socket

RUN echo “umask 0077” \>\> /etc/profile

RUN printf “deb [http://archive.debian.org/debian/](http://archive.debian.org/debian/) jessie main\ndeb-src [http://archive.debian.org/debian/](http://archive.debian.org/debian/) jessie main\ndeb [http://security.debian.org](http://security.debian.org) jessie/updates main\ndeb-src [http://security.debian.org](http://security.debian.org) jessie/updates main” \> /etc/apt/sources.list

#Install unnecessary SDS tools like lftp  
RUN apt-get -q update && apt-get install -yq --no-install-recommends   
build-essential   
cmake   
libcurl4-openssl-dev   
htpdate   
git   
libssl-dev   
uuid-dev   
libunwind8   
libunwind8-dev   
gettext   
libicu-dev   
liblttng-ust-dev   
unzip   
alsa-utils   
libasound2-dev   
sqlite3   
libsqlite3-dev   
python-dbus   
libglib2.0-bin   
qdbus   
dbus   
libgoogle-glog-dev   
libboost-all-dev   
&& apt-get clean && rm -rf /var/lib/apt/lists/\*

---

<div class="post-metadata">

**Author:** ![CameronDiver](https://avatars.discourse-cdn.com/v4/letter/c/2acd7d/32.png) [@CameronDiver](https://forums.balena.io/u/CameronDiver)\
**Post date:** [July 18, 2019, 5:19pm UTC](https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118/4 "2019-07-18T17:19:07Z")

</div>

I managed to build your Dockerfile fine, but I had to change the quotes around `echo "umask"` and `printf "deb...` - I believe these are caused by mac OS. More importantly I could not reproduce and get the same error that you are. Do you have another Dockerfile in the same directory, or are you executing in the correct place for example? Can you show me the command that you are using the build this image?

---

<div class="post-metadata">

**Author:** ![agaurav](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@agaurav](https://forums.balena.io/u/agaurav)\
**Post date:** [July 18, 2019, 5:48pm UTC](https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118/5 "2019-07-18T17:48:40Z")

</div>

@CameronDiver I am also able to build the image when I push my repo to balena online. (If you did that)  
I have only one dockerfile in the current directory from where I am running the below command and trying to build it on my local machine as described in the balena build documentation [https://www.balena.io/docs/reference/cli/#build-source](https://www.balena.io/docs/reference/cli/#build-source)

**dzdo /balena-cli/balena build --deviceType beaglebone-black --arch armv7hf --emulated**

---

<div class="post-metadata">

**Author:** ![xginn8](https://avatars.discourse-cdn.com/v4/letter/x/8baadc/32.png) [@xginn8](https://forums.balena.io/u/xginn8)\
**Post date:** [July 18, 2019, 7:06pm UTC](https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118/19 "2019-07-18T19:06:00Z")

</div>

Hi @agaurav,

I have confirmed this issue locally and tracked it down to some changes released in 11.7.0. If you can downgrade your CLI to 11.6.1, you should be able to build successfully. I have opened [an issue](https://github.com/balena-io/balena-cli/issues/1355) for it as well and we will let you know once it has been fixed.

Thank you for reporting this issue!

---

<div class="post-metadata">

**Author:** ![agaurav](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@agaurav](https://forums.balena.io/u/agaurav)\
**Post date:** [July 18, 2019, 8:30pm UTC](https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118/21 "2019-07-18T20:30:30Z")

</div>

@xginn8 @CameronDiver Thanks for looking into this. I am able to build now.

---

<div class="post-metadata">

**Author:** ![karaxuna](https://avatars.discourse-cdn.com/v4/letter/k/e480ec/32.png) [@karaxuna](https://forums.balena.io/u/karaxuna)\
**Post date:** [October 9, 2019, 9:31am UTC](https://forums.balena.io/t/resolve-the-command-bin-sh-c-apk-update-apk-add-jq-returned-a-non-zero-code-1/21118/23 "2019-10-09T09:31:15Z")

</div>

Hi, the issue has been resolved in CLI v11.14.1
