fix: Enable launcher script to work from any directory via symlink#759
fix: Enable launcher script to work from any directory via symlink#759jbactad wants to merge 2 commits intoAutoMaker-Org:v0.14.0rcfrom
Conversation
- Add symlink resolution to find actual script location - Change to project directory before executing - Move .env loading after directory change - Allows script to be called from ~/.local/bin or any location
Summary of ChangesHello @jbactad, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the usability of the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@start-automaker.sh`:
- Line 12: APP_NAME is defined but unused; either remove the variable or replace
hardcoded "Automaker" usages with the variable. To fix, keep
APP_NAME="Automaker" and update references such as the show_help/header text and
any error or banner strings to use "$APP_NAME" (search for literal "Automaker"
occurrences and swap them), or delete the APP_NAME line if you prefer a literal;
ensure functions like show_help and any error messages reference APP_NAME when
present.
There was a problem hiding this comment.
Code Review
This pull request effectively resolves an issue where the launcher script would fail when run via a symlink from a different directory. The changes correctly implement symlink resolution to find the script's true location and then change into that directory, ensuring all relative paths work as expected. Additionally, the PR cleans up duplicated and fragile .env file loading logic, centralizing it into a more robust implementation at the start of the script. My review includes one suggestion to further improve the robustness of the symlink resolution by handling dangling symlinks gracefully.
| SOURCE="$(readlink "$SOURCE")" | ||
| [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" | ||
| done | ||
| SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" |
There was a problem hiding this comment.
To make the script more robust against dangling symlinks, it's good practice to verify that the resolved script path actually exists and is a file before proceeding. This prevents the script from silently running in the wrong directory if a symlink is broken, which can lead to confusing downstream errors.
| SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" | |
| if [ ! -f "$SOURCE" ]; then | |
| echo "Error: Script file not found after resolving symlinks: $SOURCE" >&2 | |
| exit 1 | |
| fi | |
| SCRIPT_DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" |
- Remove unused APP_NAME variable (flagged by Shellcheck SC2034) - Add validation for broken symlinks before proceeding - Improves error handling and script robustness
Summary
This PR fixes the launcher script (
start-automaker.sh) to work correctly when called from any directory, particularly when accessed via a symlink (e.g.,~/.local/bin/automaker).Changes
.envloading to after directory change to ensure it finds the file correctly.envloading in web mode (now loaded once at the top)Problem Solved
Previously, when users created a symlink like
~/.local/bin/automaker -> /path/to/automaker/start-automaker.sh, runningautomakerfrom any directory would fail because:SCRIPT_DIRwould resolve to the symlink location (~/.local/bin/) instead of the actual project directory.env,package.json, npm commands) would failTesting
.envfile is loaded correctlyautomaker --versionExample Usage
Related Issue
Fixes the issue where the launcher script depends on being run from the project directory.
Summary by CodeRabbit