phoenixframework / esbuild

An installer for esbuild
MIT License
271 stars 38 forks source link

`mix esbuild` fails with `"/.cache/phx-esbuild": no such file or directory` #37

Closed dantswain closed 2 years ago

dantswain commented 2 years ago

With 0.4.0, we get the following error:

+ mix esbuild default
** (File.Error) could not make directory (with -p) "/.cache/phx-esbuild": no such file or directory
    (elixir 1.12.3) lib/file.ex:316: File.mkdir_p!/1
    (esbuild 0.4.0) lib/esbuild.ex:200: Esbuild.install/0
    (esbuild 0.4.0) lib/esbuild.ex:185: Esbuild.install_and_run/2
    (esbuild 0.4.0) lib/mix/tasks/esbuild.ex:49: Mix.Tasks.Esbuild.install_and_run/1
    (mix 1.12.3) lib/mix/task.ex:394: anonymous fn/3 in Mix.Task.run_task/3
    (mix 1.12.3) lib/mix/cli.ex:84: Mix.CLI.run_task/2

The fix is to set XDG_CACHE_HOME, but it took me a bit of work to figure that out. I found the GH issue where the switch from System.tmp_dir happened - #33 - and ironically it looks like the change was introduced to avoid a permissions issue.

I think what's going on in my situation is we're running our build on a jenkins server in docker and a) XDG_CACHE_HOME is not set in the container by default - this might be pretty common in docker b) It defaults to /.cache/phx-esbuild and for some reason (security set up of our docker environment probably?) I can't access that directory properly inside the container.

I don't think this is strictly an issue with this library, but I thought I'd report it in case anyone else experiences the same error and/or someone has an idea how to deal with this more elegantly (a better error message? a different default? just a callout in the docs?).

Thanks!

josevalim commented 2 years ago

Can you please try master and let us know if it installs successfully first try?

dantswain commented 2 years ago

@josevalim confirmed, thanks!!