#276 portable readlink -f via abspath function - #276
Open
VasilevNStas wants to merge 1 commit into
Open
Conversation
readlink -f is not available on macOS by default (only Linux/GNU coreutils). This breaks local development on macOS for anyone testing entry.sh changes. Replace it with a portable abspath function that: - Resolves symlinks (same as readlink -f) - Works on both Linux and macOS - Uses only POSIX commands and basic bash (cd + pwd -P) The while-loop handles chains of symlinks, making it equivalent to readlink -f behaviour. Note: entry.sh runs in Linux Docker containers in production, so readlink -f worked there. This fix improves the developer experience for macOS users without changing production behaviour.
VasilevNStas
force-pushed
the
276-readlink-portable
branch
from
June 29, 2026 17:04
b7c7c21 to
d05e4ed
Compare
Contributor
Author
|
@yegor256 — readlink -f is a GNU extension that doesn't exist on macOS. This means anyone developing on a Mac (including CI maintainers and contributors) gets an immediate error when testing entry.sh locally. The abspath() function replaces it with pure POSIX cd + pwd -P, preserving symlink resolution. The existing test test_resolves_real_path_when_invoked_via_symlink validates this behaviour. Low risk, high impact for developer experience. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
readlink -fis a GNU coreutils extension not available on macOS by default. This makes local development on macOS impossible —entry.shimmediately fails with"readlink: illegal option -- f".What this PR does
Replaces the single
readlink -fcall with a portableabspath()function:readlink -fabspath()illegal option -- fWhy not
realpath?realpathfrombrew install coreutilswould require an external dependency. Thecd + pwd -Papproach is pure bash/POSIX and works everywhere.Existing test coverage
The existing test
test_resolves_real_path_when_invoked_via_symlinkvalidates exactly this behaviour — it creates a symlink toentry.sh, invokes it, and asserts the resolved paths point to the real project directories.Checklist
bundle exec rubocop— 0 offencesbundle exec rake— all tasks pass@yegor256 please review