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
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/*_*
1
Popular in Discussions
So useless benchmarks aside, Its possible to write a webserver that can serve 300k requests per second (perhaps more with optimizations)....
New
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
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
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....
New
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...
New
Following https://github.com/tbrand/which_is_the_fastest |>
https://raw.githubusercontent.com/tbrand/which_is_the_fastest/master/imgs...
New
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
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
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
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
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
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
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors:
[WARN] - (starship::utils): Executing command ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
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
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
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
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance









