Closed LostKobrakai closed 3 years ago
Provided values for the use
statement in examples are just for demonstration purposes. If you want to have app_dir
, feel free to use it
defmodule MyClient do
use Avrora.Client,
schemas_path: Application.app_dir(:my_elixir_app, "./path/to/schemas")
end
Or you can configure something under config/
folder and use it the same way in the example above ⬆️
That's what we tried, but that will be hardcoded into the module at compile time. Application.app_dir
will run at compile time, which will not be the correct path if the release is moved elsewhere afterwards.
I can confirm the issue and that the proposed fix works.
release is moved elsewhere afterwards
~Another solution would be to expand the path in runtime, which will give you a semi-dynamic solution~. I don't like the idea to use app_dir
because it requires to know app
, which is not the knowledge library should have
UPD: I can take a look is there a way to add a dynamic resolution to the schemas_path
I will try to reproduce an issue. Is it correct that I will need to create a release (let's say distillery) and then I move the project to the docker in a different folder. Will it be enough to reproduce the issue?
@LostKobrakai @mdwaud I've tried to compile a project with distillery and every time I move the binary around it was working fine, the path was changing every time to path expanded from the new folder I run it.
I would like to ask you for help with a test setup that will show the issue, so far I can't reproduce it. Don't hesitate to open a new issue where we can discuss our approach 👍🏼
Hardcoding a path to schemas at compile time doesn't work well when using releases. This change would allow for the following notation (used by many elixir libraries e.g. see Plug.Static)
schemas_path: {:my_app, "priv/schemas"}
, which is then at runtime converted to the proper path.