# Simplest app fails to build for balena fin

**URL:** <https://forums.balena.io/t/simplest-app-fails-to-build-for-balena-fin/122591>\
**Category:** Product support\
**Tags:** balenafin\
**Created:** [May 31, 2020, 11:13pm UTC](https://forums.balena.io/t/simplest-app-fails-to-build-for-balena-fin/122591 "2020-05-31T23:13:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xff](https://avatars.discourse-cdn.com/v4/letter/0/5fc32e/32.png) [@0xff](https://forums.balena.io/u/0xff)\
**Post date:** [May 31, 2020, 11:13pm UTC](https://forums.balena.io/t/simplest-app-fails-to-build-for-balena-fin/122591/1 "2020-05-31T23:13:04Z")

</div>

I have created an application with a simple Dockerfile.template

```
FROM balenalib/%%BALENA_MACHINE_NAME%%-alpine-python:3.7-build as build
RUN echo "Hello"
COPY idle.sh idle.sh
CMD ["/bin/bash","-c",". idle.sh"]

```

The target device is a `fincm3` in an application with ID 1497516 named `fins-to-the-left`. I try to build using:

`balena build -a fins-to-the-left`

and it fails

```
balena-test> balena build -a fins-to-the-left
[Info] Creating default composition with source: /Users/ff/consulting/NSR/dev/balena-test
[Info] Building for armv7hf/fincm3
[Info] Docker Desktop detected (daemon architecture: "x86_64")
[Info] Docker itself will determine and enable architecture emulation if required,
[Info] without balena-cli intervention and regardless of the --emulated option.
[Build] Built 1 service in 0:01
[Build] main [=============>] 66% Step 2/3: standard_init_linux.go:211: exec user process caused "no such file or directory"
[Error] Build failed
The command '/bin/sh -c echo "Hello"' returned a non-zero code: 1

Additional information may be available by setting a DEBUG=1 environment
variable: "set DEBUG=1" on a Windows command prompt, or "export DEBUG=1"
on Linux or macOS.

If you need help, don't hesitate in contacting our support forums at
https://forums.balena.io

For CLI bug reports or feature requests, have a look at the GitHub issues or

```

Removing the offending `RUN` command, I can build and the run the image, and then logging into the container I can see

```
bash-5.0# sh -c echo hello
bash: /bin/sh: /bin/sh.real\nbalena-info\nrm: bad interpreter: No such file or directory

bash-5.0# cat /bin/sh
#!/bin/sh.real\nbalena-info\nrm -f /bin/sh\ncp /bin/sh.real /bin/sh\n/bin/sh "$@"

```

seems `/bin/sh` is broken?

---

<div class="post-metadata">

**Author:** ![nghiant2710](https://avatars.discourse-cdn.com/v4/letter/n/90db22/32.png) [@nghiant2710](https://forums.balena.io/u/nghiant2710)\
**Post date:** [June 1, 2020, 9:18am UTC](https://forums.balena.io/t/simplest-app-fails-to-build-for-balena-fin/122591/3 "2020-06-01T09:18:01Z")

</div>

Hi,

From the logs, your docker daemon architecture is x86\_64 while the fincm3 is armv7hf so you should add `--emulated` option to your `balena build` command and it will run an emulated build using qemu on your development machine (more details can be found in our docs here [https://www.balena.io/docs/learn/deploy/deployment/#--emulated--e-1](https://www.balena.io/docs/learn/deploy/deployment/#--emulated--e-1)).

Regarding the `/bin/sh` issue, it’s an old issue that we fixed so can you please re-pull the image and try again? I just manually run `balenalib/fincm3-alpine-python:3.7-build` and have no issue with it.

---

<div class="post-metadata">

**Author:** ![0xff](https://avatars.discourse-cdn.com/v4/letter/0/5fc32e/32.png) [@0xff](https://forums.balena.io/u/0xff)\
**Post date:** [June 1, 2020, 4:23pm UTC](https://forums.balena.io/t/simplest-app-fails-to-build-for-balena-fin/122591/5 "2020-06-01T16:23:56Z")

</div>

Hi,

Thanks. Pulling a new image fixed the issue.

> [@nghiant2710](#):
>
> From the logs, your docker daemon architecture is x86\_64 while the fincm3 is armv7hf so you should add `--emulated` option to your `balena build` command and it will run an emulated build using qemu on your development machine (more details can be found in our docs here [Deploy to your fleet - Balena Documentation](https://www.balena.io/docs/learn/deploy/deployment/#--emulated--e-1)).

The `--emulated` switch has been confusing to me. When I’ve had issues, I have found no difference running w/ --emulated or not and in previous discussions my understanding was that the --emulated option was superfluous. Note the comment output by the build:

```
[Info] Docker Desktop detected (daemon architecture: "x86_64")
[Info] Docker itself will determine and enable architecture emulation if required,
[Info] without balena-cli intervention and regardless of the --emulated option.

```

What’s your interpretation of this comment?

As a note, I was using this super simple project with `balena build` just because it manifested the issue and was faster to experiment with than `balena push` with the real project. But now the real project works - hmm, was there a bad image cached even with the push?

In any case, we’re off and running - not sure what changed, but it works.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![alanb128](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/alanb128/32/2839_2.png) [@alanb128](https://forums.balena.io/u/alanb128)\
**Post date:** [June 1, 2020, 5:53pm UTC](https://forums.balena.io/t/simplest-app-fails-to-build-for-balena-fin/122591/6 "2020-06-01T17:53:02Z")

</div>

The build output comment you referred to is basically saying that we try to detect and override for `emulated` where we can but it may not happen in all cases. It’s probably best to pass the flag to be explicit just in case the need for emulation is not automatically detected.

---

<div class="post-metadata">

**Author:** ![0xff](https://avatars.discourse-cdn.com/v4/letter/0/5fc32e/32.png) [@0xff](https://forums.balena.io/u/0xff)\
**Post date:** [June 1, 2020, 6:30pm UTC](https://forums.balena.io/t/simplest-app-fails-to-build-for-balena-fin/122591/7 "2020-06-01T18:30:08Z")

</div>

@alanb128 Thanks that makes sense.

May I also ask a very basic question? how do I find the appropriate architecture for a device. For example, the deviceType for my app is clearly `fincm3` but if I want to build w/o the `-a` switch I have to provide both deviceType and architecture, which assumes a device type can have multiple architectures?

---

<div class="post-metadata">

**Author:** ![alanb128](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/alanb128/32/2839_2.png) [@alanb128](https://forums.balena.io/u/alanb128)\
**Post date:** [June 1, 2020, 7:33pm UTC](https://forums.balena.io/t/simplest-app-fails-to-build-for-balena-fin/122591/8 "2020-06-01T19:33:32Z")

</div>

Sure, you can use this page: [https://www.balena.io/docs/reference/base-images/devicetypes/](https://www.balena.io/docs/reference/base-images/devicetypes/) to see devices and architecture types. I don’t think any device type has multiple architectures though.
