MatijaL

MatijaL

Getting :enoent on System.cmd() but file exists (deployed on Fly.io)

Hi guys,

I deployed a small LiveView app on Fly.io but when I try to upload an image and run System.cmd() on it, it returns :enoent which should indicate that the file doesn’t exists, but it does, the function checks if ti exists and I also checked manually using Fly.io iex console.

def content_type(filepath) do
    with true <- File.exists?(filepath),
         {file_utility_output, 0} <- System.cmd("file", ["--mime", "--brief", filepath])
    do
      content_type =
        Regex.named_captures(
          ~r/^(?<content_type>.+);/,
          file_utility_output
        )["content_type"]
      {:ok, content_type}
    else
      {error, 1} ->
        {:error, error}

      false ->
        "inode/x-empty"
    end
  end

Path example

/uploads/tmp/live_view_upload-1710842554-413969956620-1.png

Trying to run it manually from Fly.io iex

filepath  = "/uploads/tmp/live_view_upload-1710842554-413969956620-1.png"
iex(...)6> File.exists?(filepath)
true
iex(...)7> dbg System.cmd("file", ["--mime", "--brief", filepath])
** (ErlangError) Erlang error: :enoent
    (elixir 1.16.0) lib/system.ex:1101: System.cmd("file", ["--mime", "--brief", filepath], [])
    iex:7: (file)

Do you have any idea what could cause this behaviour?

Most Liked

MatijaL

MatijaL

It’s just called file

this is the line inside Dockerfile, I added file to it

RUN apt-get update -y && \
  apt-get install -y libstdc++6 openssl libncurses5 locales file ca-certificates \
  && apt-get clean && rm -f /var/lib/apt/lists/*_*

Where Next?

Popular in Discussions Top

vans163
So useless benchmarks aside, Its possible to write a webserver that can serve 300k requests per second (perhaps more with optimizations)....
New
Ankhers
Just a little information upfront. Generally speaking, if I feel like I need to either break a pipe chain or use an anonymous function in...
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
AlexMcConnell
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
588 19652 166
New
Crowdhailer
I’ve been hearing much about the new formatter and it’s something I have been keen to try. I find examples buy far the most illuminating...
248 19327 150
New
mbenatti
Following https://github.com/tbrand/which_is_the_fastest |&gt; https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
IVR
Hi all, I’ve seen a number of related threads in the past, but I’d still be very curious to hear an up-to-date opinion on this topic. I...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
wmnnd
The Go vs Elixir thread got me thinking: Would it be too hard to implement a simple mechanism for creating Go-style static app binaries f...
New
scouten
I’m looking for a host for the server part of a small (personal) side project that I’m working on. It’s currently written in Node.js and ...
New

Other popular topics Top

mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement