whoami
Lucas Jenß
cat /etc/motd
The Coding Journal ツ — Notes taken on an epic coding journey. Technical solutions, debugging notes, and practical guides from the trenches of software development.
ls -la ~/languages/
- drwxr-xr-x
- ▶ PHP
- ▶ Ruby
- ▶ Scala
- ▶ C#
- ▶ JavaScript
- ▶ Objective-C
- ▶ Shell Scripting
ls -la ~/toolchain/
- drwxr-xr-x
- ▶ Typo3
- ▶ Akka
- ▶ Capistrano
- ▶ Git
- ▶ MAMP
- ▶ Adobe Illustrator
- ▶ NSTrackingArea (Cocoa)
uname -a
- drwxr-xr-x
- ▶ Mac OS X
- ▶ Unix
Fixing a Capistrano deploy with stale Git submodules
A Capistrano deploy that fails due to missing Git submodule updates often leaves the main application at the correct commit while a library, theme, or build asset stays on an old revision. Capistrano can report success because the parent repository cloned cleanly; the defect then appears during boot, testing, or content rendering. Treating submodule checkout as a separate release step makes the failure visible at the point where it should be fixed.
The repair below covers a conventional Capistrano 3 Git workflow, including recursive submodules, private remotes, and repositories whose .gitmodules file has changed. It also fits teams hosting in Australian cloud regions or connecting through a local jump host, where an apparently successful SSH command may still conceal an authentication or connectivity problem. Verify the running release rather than trusting the deploy log alone.
Where the deploy actually breaks
Git stores a submodule reference as a gitlink: the parent commit names an exact commit in another repository, but it does not contain that repository’s files. During a normal clone, Git can create the directory without populating it. A later git submodule update --init --recursive resolves every gitlink, initialises missing entries, and checks out each recorded revision. Without that operation, the application directory can look present while its contents are absent or stale.
Common symptoms include an undefined constant from a shared package, a missing template directory, or a native build that cannot find headers. A publishing project may keep copy, themes, or static assets in a separate repository; keeping that separation visible in independent publishing workflows is sound, but only if deployment restores the pinned submodule commit rather than merely creating its path. “Not initialised”, “wrong commit”, and “inaccessible remote” require different fixes, so check the status before changing anything.
Reproduce the missing checkout
Reproduce the release with the same branch and environment used by the failing application, then inspect the release directory directly:
bundle exec cap production deploy
ssh deploy@app.example.com 'cd /var/www/myapp/current && git submodule status --recursive'
A leading - means the submodule has not been initialised. A leading + means its current commit differs from the gitlink recorded by the parent repository. U indicates a merge conflict inside the submodule. A clean expected commit normally has no prefix.
If the status is unexpectedly empty, inspect .gitmodules and the recorded tree. git ls-tree HEAD path/to/submodule reveals the expected gitlink, while git config --get-regexp '^submodule\..*\.url$' exposes any previously configured remote URL. Capistrano’s debug output should also show whether the recursive checkout command ran on the same release path that became current.
Update submodules during every release
The safest approach is to add an idempotent task after Capistrano has checked out the new parent revision:
namespace :deploy do
after :deploy:updated, "app:submodules"
end
namespace :app do
task :submodules do
on release_roles(:all) do
within release_path do
run "git submodule sync --recursive"
run "git submodule update --init --recursive"
end
end
end
end
The sync command aligns configured submodule URLs with .gitmodules, while update --init --recursive populates missing repositories and checks out their pinned commits. Running the task against release_path ensures it applies to the candidate release. If checkout fails, Capistrano should stop before that release becomes the active current symlink.
A recursive clone is not a permanent substitute for this step. Capistrano may reuse a cached superproject, and the gitlinks can change between releases. Run the recursive update after every parent checkout so the deployment reflects the exact commits selected by the newly published commit.
Handle changed submodule definitions
Changes to .gitmodules are often the trigger for an apparently random failure. Moving a submodule, changing its URL, or switching from HTTPS to SSH can leave old configuration in the repository’s local .git/config. The sync --recursive step resolves this mismatch, and Git also interprets relative submodule URLs relative to the superproject’s default remote.
Never repair a release by editing .gitmodules on the server. Commit the definition change, include the new gitlink, and let the next release recreate the working tree. Compare git ls-tree HEAD path/to/submodule with the revision reported inside that directory. If a renamed path continues to fail, use a fresh Capistrano release instead of carrying ambiguous state into the active deployment.
Secure access to private repositories
Private submodules require the server to authenticate separately from the parent repository. Use a read-only deploy key for each Git host, install its public key in the relevant account, and confirm that non-interactive SSH works. Agent forwarding can simplify access, but a compromised server or build process may gain broader authority than intended. A dedicated key with repository read access is easier to audit and revoke.
Avoid embedding personal access tokens in .gitmodules, Capistrano variables, or command output because committed URLs and logs are easy to expose. The journal’s PHP session corruption fix demonstrates how successful application requests can conceal faulty assumptions between nodes. Apply the same scepticism here: a reachable parent repository does not prove that the server can read every nested remote.
Verify the deployed revision
Check the active symlink and compare both the superproject and its children with the expected release:
readlink -f /var/www/myapp/current
cd /var/www/myapp/current
git rev-parse HEAD
git submodule status --recursive
git submodule foreach --recursive 'git status --short'
Run the same recursive checkout in CI and staging so failures occur before production changes. Lessons from NDK build troubleshooting reinforce the value of matching toolchains and dependencies across environments; a successful workstation build cannot prove that a server has the required compiler, headers, or libraries.
Local conditions deserve explicit tests. Australian teams commonly place production in AWS Sydney (ap-southeast-2) or Melbourne (ap-southeast-4) to meet data-residency expectations, while developers work from Brisbane or Perth. An NBN or business-broadband outage should not turn a laptop into the only deployment trigger, so run Capistrano from CI or a hosted bastion. Store timestamps in UTC, while remembering that Brisbane observes AEDT and Adelaide observes ACST. Schedule release windows around Australia Day, Anzac Day, and the Christmas shutdown rather than assuming overseas support hours.
Make the release repeatable
Use this diagnostic matrix to separate the common failure states:
| Observed state | What it indicates | Corrective action |
|---|---|---|
- before the commit |
Submodule is not initialised | Run git submodule update --init --recursive |
+ before the commit |
Checked-out revision differs from the gitlink | Update after every superproject checkout |
U before the commit |
Submodule contains a merge conflict | Resolve the conflict or recreate the release |
| SSH or permission error | The server cannot read a private remote | Grant a read-only deploy key and verify the URL |
Directory exists but has no .git |
Stale or manually created directory | Use a clean Capistrano release |
Make verification part of the deployment policy, not an optional manual check. Record the parent and submodule hashes, reject prefixed status output, and smoke-test the application after the new symlink is published. A rollback changes which release is active but does not repair a broken checkout, so redeploy a known-good pinned commit when an emergency release fails.
Add the recursive checkout hook now, deploy it to staging, and confirm that git submodule status --recursive is clean on the running release. Then use the same task for production, with a dedicated read-only key, UTC logs, and an automated verification step that prevents an incomplete repository from becoming the active application.
cat ~/interests.json
| Key | Value |
|---|---|
| editor | Terminal-first workflow |
| os | Mac OS X / Unix |
| vcs | Git, distributed version control |
| deploy | Capistrano, cron automation |
| graphics | SVG, Adobe Illustrator troubleshooting |
| networking | IP validation, SSH, VPN |
git log --oneline --reverse
Solving SVG import issues in Adobe Illustrator CS6 and CC
When importing an SVG into Illustrator, the operation fails with an unknown error [CANT]. A workaround for this Adobe-side bug.
Solving NDK build issues on OS X
Troubleshooting native development kit compilation problems on Mac OS X.
Programmatically adding PHP generated TypoScript to the backend configuration
Integrating dynamically generated TypoScript into Typo3 backend setups using PHP.
ArgumentError: Could not parse PKey: no start line
Debugging an SSH key parsing error encountered during deployment.
Validating IP-Addresses in PHP
Using PHP filter functions with flags like FILTER_FLAG_IPV4 and FILTER_FLAG_IPV6, and understanding how filter_var handles reserved IP addresses.
Cocoa: Using NSTrackingArea
A short tutorial on using Cocoa's NSTrackingArea to capture mouseEntered and mouseExited events.
cat ~/contact.txt