/bin/sh: /app/snowsql: file not found

If you just tested out Snowflake's snowsql CLI and thought you'd make quick work of integrating it into your Docker image... I feel your pain - much more than you'll have to, in fact, if you're reading this!

TL;DR: The answer

You can't use snowsql on Alpine. Don't even try. It uses musl-libc instead of "normal" libc. It just won't work.

Instead you can use FROM ubuntu:18.04 (or another normal Linux distro), but you you'll also need to set some envs:

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

You can see an example that works over at github.com/kurron/docker-snowsql that you can use with FROM kurron/snowsql.

As for myself, I follow this mantra:

A little copying is better than a little dependency.

# Use a libc-based linux distro
FROM ubuntu:18.04

WORKDIR /app

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

# Update apt and get curl
RUN apt-get update && apt-get install -y curl

# Get SnowSQL
RUN curl http://s3-us-west-2.amazonaws.com/sfc-snowsql-updates/bootstrap/1.1/linux_x86_64/snowsql-1.1.76-linux_x86_64.bash && \
    -o snowsql-1.1.76-linux_x86_64.bash && \
  touch /app/.profile && \
  SNOWSQL_DEST=/app/ SNOWSQL_LOGIN_SHELL=/app/.profile bash snowsql-1.1.76-linux_x86_64.bash && \
  rm -f snowsql-1.1.76-linux_x86_64.bash

# Let it do its first-time post-install install
RUN /app/snowsql

# Add your own stuff here...

Now, if you're interested in what the heck was happening, continue on below:

What do you mean "file not found"?

You'd think "file not found"? Doesn't that mean that the file... isn't found... right? That it magically was just there one moment and not the next, yeah?

Nope!

Most of us who don't know any better use Alpine Linux for all things Docker because, well, every's doing it and 200,000 people can't be wrong, right? Actually, Alpine is similar to another version of Linux called Busybox in that they are both "crippled" versions of Linux that are missing all of the standard libraries (like libc) that you need for "normal" programs to work.

You can see that it is not built as a fully staticly-linked redistributable package by checking with ldd:

ldd ~/bin/snowsql
    linux-vdso.so.1 (0x00007ffd1c3f6000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fa7a4db5000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fa7a4b98000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fa7a47a7000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fa7a4fb9000)

See all that libc, libz, libdl, etc? That means it' won't work when those aren't installed. For systems that don't have standard libc it simply means that it's not gonna work. Period.

Use a "normal" Linux with libc

As far as I can tell there is no official version of the snowsql client that supports environments that are built using musl-libc, dietlibc, or any other libc variant than libc itself.

From the error messages I've encountered, I'm fairly certain that it's just their Python3 SDK packaged up with a python CLI as a standalone executable. Even though it's not that much trouble to de-package and re-package with a version of Python that doesn't support such variants, it's probably not worth the effort. I certainly can't be bothered.

Using Ubuntu (or any plain old, fatty-mcfat-fat distro), will alleviate that headache.

I used FROM ubuntu:18.04, but then I hit another wall...

ASCII vs en_US vs C.UTF-8

The final headache was getting was related to locales. It's a headache I've had before, but with a new twist. Apparently the available locales and the ways they're set has changed.

Traceback (most recent call last):
  File "bootstrap.py", line 943, in <module>
  File "click/core.py", line 722, in __call__
  File "click/core.py", line 676, in main
  File "click/_unicodefun.py", line 118, in _verify_python3_env
RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment.  Consult http://click.pocoo.org/python3/for mitigation steps.

This system supports the C.UTF-8 locale which is recommended.
You might be able to resolve your issue by exporting the
following environment variables:

    export LC_ALL=C.UTF-8
    export LANG=C.UTF-8

Click discovered that you exported a UTF-8 locale
but the locale system could not pick up from it because
it does not exist.  The exported locale is "en_US.UTF-8" but it
is not supported
[8] Failed to execute script bootstrap

I at first, I tried simply prefixing the locales in front of the command that I was using, but it didn't work.

Looking back, I feel a little foolish. I must have copied and pasted wrong or somehow made a typo. In the end the solution is exactly as simple as explained in the error message.

For the Docker noobs: export won't work. Or if it does, it's just a coincidence. The way you have to do it is like this:

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

The whole enchilada:

One more time, just in case you scrolled past it at the top and went straight to the bottom:

# Use a libc-based linux distro
FROM ubuntu:18.04

WORKDIR /app

ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

# Update apt and get curl
RUN apt-get update && apt-get install -y curl

# Get SnowSQL
RUN curl http://s3-us-west-2.amazonaws.com/sfc-snowsql-updates/bootstrap/1.1/linux_x86_64/snowsql-1.1.76-linux_x86_64.bash && \
    -o snowsql-1.1.76-linux_x86_64.bash && \
  touch /app/.profile && \
  SNOWSQL_DEST=/app/ SNOWSQL_LOGIN_SHELL=/app/.profile bash snowsql-1.1.76-linux_x86_64.bash && \
  rm -f snowsql-1.1.76-linux_x86_64.bash

# Let it do its first-time post-install install
RUN /app/snowsql

# Add your own stuff here...

By AJ ONeal

If you loved this and want more like it, sign up!


Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )