Path name in Umbrella Apps

Hi, I’m having an issue with the Path.absname/1 function.

The function will return the absolute path of current umbrella app. Let’s say I have two app in an umbrella project called app1 and app2.

Path.absname(“something”) will return different result based on where I called it.

So how do I always get the result some_path/umbrella/apps/app1/something even if I called the function inside app2?

In theory it should be resolved relative to your current working dir, so I’m wondering why you get your apps in there…

1 Like

Just in case, remember that Path.absname/1 will not work as expected in releases. Use :code.priv_dir/1 or :code.get_path/0.

It will work exactly as expected, it will resolve the absolute name relative to the working dir, and it will fail if there is no working dir.

If though you don’t know about your current working dir, or how it affects started applications, then of course Path.absname/1 will always fail for you.

Maybe could you try Application.app_dir/2 ?

Application.app_dir(:app1, "something") should always return some_path/umbrella/apps/app1/something even if you call it from app2.

1 Like

It does not. Application.app_dir does internally also just use :code api and those point to the files in the _build directory and not the source directory.

2 Likes