Fix Gemini OAuth: resolve multi-level symlink chain#497
Fix Gemini OAuth: resolve multi-level symlink chain#497LeoLin990405 wants to merge 2 commits intosteipete:mainfrom
Conversation
The Homebrew gemini binary has a 4-level symlink chain:
/usr/local/bin/gemini → /opt/homebrew/bin/gemini
→ ../Cellar/gemini-cli/0.32.1/bin/gemini
→ ../libexec/bin/gemini → ...
The previous code only resolved one level, landing at
/opt/homebrew/bin which lacks the libexec/ tree.
Now collects all intermediate paths and tries each one,
finding oauth2.js from the Cellar-level resolution.
|
Thanks for the fix. I tried to validate this on a Homebrew install here, and Gemini works for me on main, so I haven’t been able to reproduce the failure yet. Could you share the exact install layout/version and either repro steps or logs showing how the old path resolution fails? A |
|
Thanks for taking the time to investigate, @ratulsarna! After digging deeper, I found the root cause — it's specific to my setup but I think still worth considering. Root CauseI have a custom symlink at How to Reproduce
Why You Can't ReproduceIf My TakeI understand this is an edge case caused by my own setup. That said, users who put |
|
Thanks, this helps. I could reproduce Gemini working on Your explanation makes sense though: this only breaks when That sounds like a real edge case, not a general Homebrew issue. We're fine with supporting it, but can you add a regression test for this exact setup before we merge and ensure lint and all tests pass? |
Extract resolveOAuthFileContent(from:) as an internal static method so it can be tested directly. Add four test cases: 1. Standard 2-level Homebrew symlink chain (baseline) 2. 3-level chain with extra /usr/local/bin symlink (the bug scenario) 3. Non-symlinked binary (direct npm install) 4. Missing oauth2.js returns nil gracefully Tests create real symlinks in a temp directory to exercise the actual FileManager.destinationOfSymbolicLink resolution loop.
|
Hi @steipete, Thank you for the thoughtful review and for requesting regression tests — fully agreed that this kind of symlink resolution logic should be well covered. I've added a dedicated test suite ( Regression Tests Added
Each test creates a complete directory tree mimicking the real Homebrew Cellar layout (including multi-level relative symlinks like To make this testable, I extracted the symlink resolution + file search logic into an CI ResultsAll 4 regression tests pass on macOS-latest in GitHub Actions (Run #23041932123): Screenshot — GeminiOAuthSymlinkTests (4/4 passed): Screenshot — Overall test summary: Note on the Single Unrelated FailureThe CI run shows 919 out of 920 tests passed. The sole failure is Root cause: The CI ran on a branch that also includes new provider registrations ( Why this cannot be caused by PR #497: This PR only modifies two files — Screenshot — Failure analysis: Please let me know if there's anything else you'd like me to adjust. Thank you for maintaining such a high quality bar for CodexBar! |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |



Summary
geminiCLI has a 4-level symlink chain:/usr/local/bin/gemini→/opt/homebrew/bin/gemini→../Cellar/gemini-cli/0.32.1/bin/gemini→../libexec/bin/gemini. CodexBar only resolves one level usingdestinationOfSymbolicLink, so it lands at/opt/homebrew/bin/which lacks thelibexec/tree containingoauth2.js. This causes Gemini OAuth credential detection to fail silently.libexec/path is found regardless of how many symlink levels Homebrew uses.Test plan