Skip to content

fix: Enable launcher script to work from any directory via symlink#759

Open
jbactad wants to merge 2 commits intoAutoMaker-Org:v0.14.0rcfrom
jbactad:fix/launcher-symlink-support
Open

fix: Enable launcher script to work from any directory via symlink#759
jbactad wants to merge 2 commits intoAutoMaker-Org:v0.14.0rcfrom
jbactad:fix/launcher-symlink-support

Conversation

@jbactad
Copy link

@jbactad jbactad commented Feb 7, 2026

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

  • Symlink resolution: Added logic to follow symlinks to find the actual script location
  • Directory change: Script now changes to the project directory before executing
  • Improved .env loading: Moved .env loading to after directory change to ensure it finds the file correctly
  • Removed duplicate: Cleaned up duplicate .env loading 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, running automaker from any directory would fail because:

  1. SCRIPT_DIR would resolve to the symlink location (~/.local/bin/) instead of the actual project directory
  2. Relative paths (.env, package.json, npm commands) would fail

Testing

  • Tested running script directly from project directory
  • Tested running script via symlink from different directories
  • Verified .env file is loaded correctly
  • Confirmed version command works: automaker --version

Example Usage

# Create symlink (one-time setup)
ln -s /path/to/automaker/start-automaker.sh ~/.local/bin/automaker

# Now works from any directory
cd /tmp
automaker --version  # ✅ Works!
automaker            # ✅ Launches correctly!

Related Issue

Fixes the issue where the launcher script depends on being run from the project directory.

Summary by CodeRabbit

  • Chores
    • Improved startup reliability with robust path resolution and streamlined initialization to handle different execution contexts.
    • Ensured environment configuration is loaded earlier and more consistently during startup, reducing startup errors and simplifying runtime behavior.

- 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
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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 start-automaker.sh launcher script by addressing issues related to its execution from arbitrary directories, particularly when invoked via a symlink. The changes ensure that the script consistently identifies its true project location and correctly loads necessary environment variables and resources, providing a more flexible and reliable user experience.

Highlights

  • Symlink Resolution: Implemented robust logic to resolve the true path of the start-automaker.sh script, correctly following any symlinks to determine the actual project directory.
  • Project Directory Change: The script now explicitly changes its current working directory to the resolved project root, ensuring all relative paths for resources like .env files and npm commands function correctly regardless of where the script is invoked from.
  • Improved .env Loading: The .env file loading mechanism has been relocated to occur after the script has changed into the project directory, guaranteeing that the correct .env file is always found and loaded.
  • Duplicate .env Loading Removed: A redundant .env loading block specifically within the 'web' mode execution path has been removed, streamlining the script and preventing potential issues from double-loading environment variables.

🧠 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
  • start-automaker.sh
    • Added logic to resolve the script's source path, including following symlinks, to accurately determine the SCRIPT_DIR.
    • Introduced a cd command to change the current working directory to the resolved SCRIPT_DIR at the script's start.
    • Moved the .env file loading block to execute after the directory change, ensuring it loads from the correct project root.
    • Removed a duplicate .env loading block from within the web mode case, as it is now handled globally at the script's initialization.
Activity
  • Pull request created by jbactad.
  • Initial commit pushed with changes to start-automaker.sh.
  • Automated checks initiated for the proposed changes.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

The start-automaker.sh startup sequence was restructured to resolve symlinks to determine the script directory (SCRIPT_DIR), change into that directory with error handling, and source a .env file during startup. APP_NAME and the web-mode re-export of .env variables were removed.

Changes

Cohort / File(s) Summary
Script Initialization
start-automaker.sh
Added symlink-resolving logic to set SCRIPT_DIR, cd into resolved directory with error handling, source .env earlier in startup; removed APP_NAME and the web-mode re-export block.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

Bug

Suggested reviewers

  • Shironex

Poem

I nibble paths and follow the thread,
Unravel symlinks where scripts are led,
I hop to the folder, load .env with care,
No APP_NAME banner — just tidy startup fare,
Hooray for clean starts! 🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: enabling the launcher script to work from any directory via symlink resolution. It is specific, concise, and directly reflects the primary objective of the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant