Use file_systen inside escript
pmartinezalvarez opened this issue · 7 comments
I am interested in using the library inside an escript. When I call {:ok, watcher_pid} = FileSystem.start_link(args)
from iex
evrithing is ok. But when I run the same code inside an escript it returns :ignore
Is there a way to deal with it?
Thanks.
Thanks!
@pmartinezalvarez I check the code, the issue is because we can't use :code.priv_dir
in escript, I'll think more about how to make it configurable and works with both escript and distillery.
Will do it this weekend.
Thanks @falood :) I have been thinking in loading the /mac_listener
at compilation time, on the fs_mac.ex
file, as suggested in https://elixirforum.com/t/is-it-possible-to-include-resource-files-when-packaging-my-project-using-mix-escript/730/10.
I tried to compile c_src to binary for fs_mac
at runtime if the executable file is not exists, but escript
runtime don't have application :file_system
, Mix
and the c_src
folder to compile.
So even though I added the way to config executable file path via config.exs
or FILESYSTEM_FSMAC_EXECUTABLE_FILE
env, the binary file should also be compiled manually with FILESYSTEM_FSMAC_EXECUTABLE_FILE=YOUR_EXECUTABLE_FILE_PATH mix file_system.fs_mac init
before run mix escript.build
.
It seems no better way to do everything automatic 😞
Thanks so much @falood! This is good enough for my use case.
file_system 0.1.4 released with this fix, enjoy ❤️