Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions conductor-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/bash
set -e # Exit on any error

echo "🚀 Setting up Rails workspace..."

# Load mise if available
if command -v mise &> /dev/null; then
eval "$(mise activate bash)"
fi

# Check for required tools
if ! command -v ruby &> /dev/null; then
echo "❌ Ruby is not installed. Please install Ruby first."
exit 1
fi

# Check Ruby version
RUBY_VERSION=$(ruby -v | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
REQUIRED_VERSION="3.2.0"

if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$RUBY_VERSION" | sort -V | head -n1)" != "$REQUIRED_VERSION" ]; then
echo "❌ Ruby version $RUBY_VERSION is too old. Rails 8.0.3 requires Ruby >= $REQUIRED_VERSION"
echo " Please update Ruby using a version manager like rbenv, rvm, or asdf."
exit 1
fi
Comment on lines +21 to +25
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Non‑portable Ruby version check (‘sort -V’ breaks on macOS/BSD)

sort -V isn’t available on BSD/macOS; the check can falsely fail. Compare via Ruby’s Gem::Version instead.

-RUBY_VERSION=$(ruby -v | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
-REQUIRED_VERSION="3.2.0"
-
-if [ "$(printf '%s\n' "$REQUIRED_VERSION" "$RUBY_VERSION" | sort -V | head -n1)" != "$REQUIRED_VERSION" ]; then
-    echo "❌ Ruby version $RUBY_VERSION is too old. Rails 8.0.3 requires Ruby >= $REQUIRED_VERSION"
-    echo "   Please update Ruby using a version manager like rbenv, rvm, or asdf."
-    exit 1
-fi
+REQUIRED_VERSION="${REQUIRED_VERSION:-3.2.0}"
+if ! ruby -e "exit(Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('$REQUIRED_VERSION') ? 0 : 1)"; then
+  echo "❌ Ruby $(ruby -v) is too old. Requires Ruby >= $REQUIRED_VERSION."
+  echo "   Please update Ruby via mise, rbenv, rvm, or asdf."
+  exit 1
+fi
🤖 Prompt for AI Agents
In conductor-setup.sh around lines 21 to 25, the current Ruby version check uses
sort -V which is not portable on macOS/BSD; replace it with a Ruby-based
comparison using Gem::Version: invoke a small ruby -e snippet that reads
REQUIRED_VERSION and RUBY_VERSION (export or pass as ENV), compares
Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(REQUIRED_VERSION) and exit
non‑zero when the check fails; then use that exit status to print the existing
error messages and exit 1. Ensure the script remains POSIX-compatible by calling
ruby instead of relying on GNU sort.


if ! command -v bundle &> /dev/null; then
echo "❌ Bundler is not installed. Please install Bundler first."
exit 1
fi

# Copy environment files from root if they exist
if [ -f "$CONDUCTOR_ROOT_PATH/.env" ]; then
echo "📋 Copying .env file from root..."
cp "$CONDUCTOR_ROOT_PATH/.env" .env
fi

if [ -f "$CONDUCTOR_ROOT_PATH/.env.local" ]; then
echo "📋 Copying .env.local file from root..."
cp "$CONDUCTOR_ROOT_PATH/.env.local" .env.local
fi
Comment on lines +33 to +41
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Potentially wrong source path and destructive overwrites for .env files

  • If CONDUCTOR_ROOT_PATH is unset, you may read from “/.env”.
  • cp overwrites existing local env files.
-# Copy environment files from root if they exist
-if [ -f "$CONDUCTOR_ROOT_PATH/.env" ]; then
-    echo "📋 Copying .env file from root..."
-    cp "$CONDUCTOR_ROOT_PATH/.env" .env
-fi
-...
-if [ -f "$CONDUCTOR_ROOT_PATH/.env.local" ]; then
-    echo "📋 Copying .env.local file from root..."
-    cp "$CONDUCTOR_ROOT_PATH/.env.local" .env.local
-fi
+# Copy environment files from repo root (non-destructive)
+ROOT_PATH="${CONDUCTOR_ROOT_PATH:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
+for f in .env .env.local; do
+  if [ -f "$ROOT_PATH/$f" ]; then
+    if [ -e "$f" ]; then
+      echo "⚠️  $f already exists locally; leaving it unchanged."
+    else
+      echo "📋 Copying $f from root..."
+      cp -n "$ROOT_PATH/$f" "$f"
+    fi
+  fi
+done
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ -f "$CONDUCTOR_ROOT_PATH/.env" ]; then
echo "📋 Copying .env file from root..."
cp "$CONDUCTOR_ROOT_PATH/.env" .env
fi
if [ -f "$CONDUCTOR_ROOT_PATH/.env.local" ]; then
echo "📋 Copying .env.local file from root..."
cp "$CONDUCTOR_ROOT_PATH/.env.local" .env.local
fi
# Copy environment files from repo root (non-destructive)
ROOT_PATH="${CONDUCTOR_ROOT_PATH:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
for f in .env .env.local; do
if [ -f "$ROOT_PATH/$f" ]; then
if [ -e "$f" ]; then
echo "⚠️ $f already exists locally; leaving it unchanged."
else
echo "📋 Copying $f from root..."
cp -n "$ROOT_PATH/$f" "$f"
fi
fi
done
🤖 Prompt for AI Agents
In conductor-setup.sh around lines 33 to 41, the script risks reading from
"/.env" when CONDUCTOR_ROOT_PATH is unset and will unconditionally overwrite
local .env files; fix by first ensuring CONDUCTOR_ROOT_PATH is non-empty and
points to an existing directory (e.g. check [ -n "$CONDUCTOR_ROOT_PATH" ] && [
-d "$CONDUCTOR_ROOT_PATH" ]), construct safe source paths like
src="$CONDUCTOR_ROOT_PATH/.env" and only proceed if [ -f "$src" ], and replace
destructive cp with a non-overwriting strategy (use cp -n to skip if target
exists, or create a timestamped backup of the existing local file before
copying) while keeping all path variables quoted to handle spaces.


# Install Ruby dependencies
echo "📦 Installing Ruby gems..."
bundle install

# Clear logs and temp files
echo "🧹 Cleaning logs and temp files..."
bin/rails log:clear tmp:clear

echo "✅ Setup complete! Click the Run button to start the Rails server."
Comment on lines +4 to +51
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Overall: solid flow; minor polish will improve portability and safety

Nice linear setup with clear messages. Address the above to make it cross‑platform and idempotent.

Run this script to validate assumptions and files:


🏁 Script executed:

#!/bin/bash
set -Eeuo pipefail
echo "Repo root: $(git rev-parse --show-toplevel 2>/dev/null || pwd)"
echo "Ruby: $(command -v ruby || echo 'missing')"
ruby -v || true
echo "Bundler: $(command -v bundle || echo 'missing')"
bundle -v || true
echo "bin/rails present? $( [ -x bin/rails ] && echo yes || echo no )"
echo "bin/dev present? $( [ -x bin/dev ] && echo yes || echo no )"
echo "Procfile.dev present? $( [ -f Procfile.dev ] && echo yes || echo no )"
echo ".ruby-version: $( [ -f .ruby-version ] && cat .ruby-version || echo 'absent')"
echo "Gemfile ruby directive:"
sed -nE 's/^\s*ruby\s+["'\'']([^"'\'']+)["'\''].*/\1/p' Gemfile || true

Length of output: 292


Enable strict mode and compute CONDUCTOR_ROOT_PATH
At the very top of conductor-setup.sh, add:

set -Eeuo pipefail
readonly CONDUCTOR_ROOT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"

Improve idempotency (optional)

  • Use cp -n instead of cp for .env files to avoid overwriting existing copies.
  • Replace bundle install with bundle check || bundle install so rerunning skips if gems are already satisfied.
🤖 Prompt for AI Agents
In conductor-setup.sh around lines 4 to 51, add strict Bash failure modes and
compute a reliable CONDUCTOR_ROOT_PATH at the top of the script (use set -Eeuo
pipefail and define readonly CONDUCTOR_ROOT_PATH by resolving the script
directory to the repo root) so errors are caught and path references work; also
make copies idempotent by using cp -n for .env and .env.local to avoid
overwrites if target exists, and replace the unconditional bundle install with a
guarded invocation (bundle check || bundle install) so rerunning the script
skips installing gems when already satisfied.

8 changes: 8 additions & 0 deletions conductor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"scripts": {
"setup": "./conductor-setup.sh",
"run": "bin/dev",
"archive": ""
Comment on lines +3 to +5
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Validate run target prerequisites

Ensure bin/dev exists and that a compatible Procfile (e.g., Procfile.dev) is present; otherwise “Run” will no‑op/fail.


🏁 Script executed:

#!/bin/bash
set -Eeuo pipefail
[ -x bin/dev ] && echo "bin/dev: OK" || echo "bin/dev: MISSING"
[ -f Procfile.dev ] && echo "Procfile.dev: OK" || echo "Procfile.dev: MISSING"
rg -n '^web:|rails' Procfile* || true

Length of output: 83


Add missing Procfile.dev
Procfile.dev is currently absent, so although bin/dev exists, running without a defined process (e.g. a web: entry) will no-op/fail. Add a Procfile.dev or adjust the run value in conductor.json accordingly.

🤖 Prompt for AI Agents
In conductor.json around lines 3 to 5, the repo references bin/dev but lacks a
Procfile.dev so process managers no-op; add a Procfile.dev at the repo root
containing a "web: bin/dev" entry (or alternatively update conductor.json.run to
invoke the required command directly) so that running the development process
starts the web server via bin/dev.

},
"runScriptMode": "nonconcurrent"
}
Loading