Bottom line: please change usages of “readlink” to “realpath” in leafctl scripts.
I’m attempting to make a self-contained, ready-to-run, build environment that can exist in any “environment” root folder (env) on a developer machine, accessed from a container, etc.
The leafctl directory is in /opt/leafctl
The leafctl script link is /bin/leafctl
The leafctl script link points to “…/opt/leafctl/leafctl.sh”
Note that the link is relative. Normally leafctl link is absolute: /opt/leafctl/leafctl.sh
Leafctl does not work with the relative link. The leafctl.sh script uses “readlink” to figure out where the link is pointing and uses this to determine the leafctl working directory. Readlink returns the logical (relative) path "…/opt/leafctl/leafctl.sh. But when executed the path is relative to the user’s current directory, not the original link directory.
Using “realpath” instead of “readlink” will return the (absolute) resolved path of the link. This way, the leafctl link can be relative for installation flexibility, and the absolute paths are determined at runtime.
There are three instances in “readlink” in leafctl - two scripts and the README.md file.
Hopefully this change will work on all your supported platforms.
Thanks.
Dan Ray
I’ll take a closer look and give this thread an update. We might be able to sneak this in as I think it would be a small change. Thanks for the report! Will echo Chris in that the best way to make sure requests are formally considered is to go through that link
So I took a closer look and it looks like Mac doesn’t get realpath for free… and we can’t easily just go grab it with Homebrew because we are on managed machines. I asked around and I think there is a way we could hack around that limitation on Mac, but the solution becomes less trivial. I suppose we could also add some logic to check what os we’re currently operating in so that you could use it for your (non-Mac… probably Ubuntu?) environment while Mac would continue to only support absolute paths for now…
TLDR: Unfortunately the solution isn’t as trivial as I thought as we are supporting a couple of operating systems. Please submit a feature request so that it can be discussed in our backlog grooming and properly prioritized.
Checked the man pages for readlink on mac and doesn’t appear that it has a corresponding flag (or anything about canonicalization really)
Thanks for the feature request! I still don’t think it would be a huge ask to get this working, even if there needs to be slightly different logic across supported OS’s and I’ll say as much at our backlog grooming.