bitwalker/toml-elixir

Toml.Provider path

adkron opened this issue · 6 comments

When building a release with mix release the path is relative to where I am running mix. When starting the release the same path is relative to where I run the bin/app file from. This is quite confusing and tough to deal with. I'm not sure of a better way to handle it at the moment. It would be nice if it could use some set path.

It uses Config.Provider.resolve_config_path internally (with 1.9+), so I would expect the behavior to match any other config provider. My assumption is that absolute paths will also not be treated as relative to the release root, so you can always provide your own absolute path if that works better.

The way I think about it is that the config path (when relative) is loaded relative to the project root, in a release that just happens to be the directory that contains the bin, lib, etc., directories. That seems fairly intuitive to me, unless I'm misunderstanding the behavior you are seeing.

It is relative to where I start from. If I start from the bin directory it is relative to there. If I use a path when starting “bin/project start” it is relative to my pwd.

Is this with the new 1.9 releases or Distillery? That's definitely a bug in my opinion, but Distillery always sets the current working directory for its commands to the release root directory when executing its shell script, so I wouldn't expect it to be a problem there.

1.9 releases. I guess it would be the shell script that the bin calls that would set the working directory.

@adkron You could report the issue to Elixir, but as a temporary workaround, the env.sh produced by the 1.9 releases can be used to set the current working directory to $RELEASE_ROOT_DIR, which should accomplish the same goal. Personally, I think the core release scripts should do that automatically, but I can imagine situations where you want to reference files in the directory you are currently in (say you want to eval an elixir script); so it may be a deliberate choice on the core team's part.

I'm going to close this for now, since this isn't really a toml-elixir issue, but if you want to follow up here as well, that may help others who find the issue the same way you did.

@fkumro, would you like to create the other ticket to follow since the deployment is with you now that I'm moving on?