Repository navigation
fix(integrations): keep shared scripts executable when the default integration changes - #5425
Conversation
…tegration changes `integration use`, every `integration switch` path, and `integration uninstall` of the default integration refresh shared infrastructure through `_set_default_integration()`. The refresh rewrites `.specify/scripts/bash/*.sh` with the packaged mode (0644) and nothing restored the execute bits, so the scripts that generated commands and skills run directly failed with "Permission denied". Restore them after the refresh, as init, install and upgrade already do. Assisted-by: Codex (model: gpt-6.1-sol, autonomous) Assisted-by: Claude Code (model: claude-opus-5-5, autonomous)
There was a problem hiding this comment.
🔵 Needs a closer look
Human confirmation is needed because the shared transition changes permissions across use, switch, uninstall, and rollback, with interactions involving lifecycle journaling, partial-refresh recovery, and POSIX/Windows behavior.
No open issues 🎉
What changed in this PR
This PR fixes a permissions regression where integration changes rewrote shared POSIX scripts without execute permissions, causing directly invoked generated commands to fail. It restores executable bits after default-integration refreshes and adds regression coverage.
Changes:
- Restore execute permissions in
_set_default_integration()after shared infrastructure refreshes. - Test
integration switch,integration use, and default-integration fallback duringintegration uninstall. - Cover new, installed, and current-default switch paths, including refresh options.
| File | Description |
|---|---|
| tests/specify_cli/integrations/test_command_use.py | Verifies that integration use preserves executable permissions on shared scripts. |
| tests/specify_cli/integrations/test_command_uninstall.py | Verifies that fallback shared scripts remain executable after uninstalling the default integration. |
| tests/specify_cli/integrations/test_command_switch.py | Covers executable permissions across new, installed, and current-default integration switch paths. |
| src/specify_cli/integrations/_helpers.py | Restores executable permissions after default-integration shared infrastructure refreshes. |
Review effort: Lite (dynamic)
…n write The previous commit restored execute bits with `ensure_executable_scripts()` after the default-integration refresh. That scan follows a symlinked `.specify/scripts` or `.specify/extensions` root and changes modes outside the lifecycle journal, so a rollback could not undo it. Give `.sh` files that start with a shebang their execute bits in the mode `install_shared_infra()` already passes to `_write_shared_bytes()`. The mode is applied to the temp file before the atomic replace, behind the same symlink checks and journal calls as the content, and only files the refresh writes are touched. Drop the scan from `_set_default_integration()`. Assisted-by: Claude Code (model: claude-fable-5-2, autonomous)
|
Both Copilot findings are addressed in 13ff151. They came from the same thing: the first commit restored the bits with New test One side effect: Drafted on behalf of @kartsan03 by Claude Code (model: claude-fable-5-2, autonomous); it also wrote the change and ran the tests. |
There was a problem hiding this comment.
🟡 Changes recommended
Test coverage is missing for permission-mode rules and exclusions, and for transactional rollback restoring a managed script’s original mode and content after a later failure.
2 open issues
2 resolved since last review
Review effort: Max
Unit tests for `_shared_script_mode()`: an execute bit for each class that can read a `.sh` file with a shebang, and the packaged mode for a shebang-less `.sh`, other file types and Windows. A failed switch away from an external adapter restores the mode and content of the scripts the refresh rewrote. Assisted-by: Claude Code (model: claude-fable-5-2, autonomous)
|
Both test requests from the last Copilot pass are covered in 3f7bdc0 (tests only, no source change).
The three touched test files pass (716 tests) and ruff is clean. The full suite ran on 13ff151; I did not rerun it for this test-only commit. Drafted on behalf of @kartsan03 by Claude Code (model: claude-fable-5-2, autonomous); it also wrote the tests and ran them. |
The refresh keeps the packaged script's group and other bits, so a checkout with group-writable scripts (0664) produces 0775 and the exact 0755 check failed before the simulated commit error. The mode mapping itself is covered by tests/test_shared_infra_script_mode.py. Assisted-by: Claude Code (model: claude-opus-5-5, autonomous)
|
The rollback test's exact 0755 check is fixed in b5b100f (one test line, no source change). The refresh keeps the packaged script's group and other bits, so with group-writable sources it writes 0775. The failing step now checks only the owner execute bit, and Drafted on behalf of @kartsan03 by Claude Code (model: claude-opus-5-5, autonomous); it also changed the test and ran it. |
There was a problem hiding this comment.
🔵 Needs a closer look
Human assessment is needed because the regression tests depend on inherited script permissions and can pass without the fix, leaving their ability to detect the original bug uncertain.
2 open issues
1 resolved since last review
Review effort: Max
|
Please address Copilot feedback |
The execute-bit tests read the packaged scripts from the checkout, so a checkout whose scripts already had execute bits made them pass without the fix. A fixture now serves a copy with every file at 0644, as the wheel ships them, so they fail on main whatever modes the checkout has. Assisted-by: Claude Code (model: claude-opus-5-5, autonomous)
|
The last Copilot pass is addressed in 1ae9c47 (tests only). Its point was that the execute-bit tests took the packaged scripts' mode from the checkout, so they could pass without the fix. They now use a With Drafted on behalf of @kartsan03 by Claude Code (model: claude-opus-5-5, autonomous); it also wrote the fixture and ran the tests. |
|
Please address Copilot feedback |
…xecutable ensure_executable_scripts() skips a script with any execute bit, but the refresh's mode rule added bits for every class that could read it, so a packaged 0744 or 0754 script came out 0755. Add execute bits only when the packaged script has none, as ensure_executable_scripts() does. Assisted-by: Claude Code (model: claude-opus-5-5, autonomous)
|
The latest Copilot pass is addressed in b43008b.
Drafted on behalf of @kartsan03 by Claude Code (model: claude-opus-5-5, autonomous); it also changed the mode rule and its tests and ran the suite. |
There was a problem hiding this comment.
🔵 Needs a closer look
Executable-permission changes span initialization and integration lifecycle commands, with interactions involving managed-file preservation, symlink safety, and external-adapter rollback requiring broader review.
2 open issues
Review effort: Max
|
Please address Copilot feedback |
|
The 20:27 Copilot pass on b43008b has no new finding. The two issues it still lists as open are the test requests from the second pass, and both are covered on this head. I've answered each in its thread with the test and what it does with On b43008b the mode and rollback tests pass (190 in the five touched test files). With Drafted on behalf of @kartsan03 by Claude Code (model: claude-opus-5-5, autonomous); it reran the tests and wrote this reply. |
|
Thank you! |



Description
After
specify integration switch <key>,specify integration use <key>, orspecify integration uninstallof the default integration (when another installed one takes over), every script in.specify/scripts/bash/has mode 0644. The generated commands and skills tell the agent to run them directly (.specify/scripts/bash/setup-plan.sh --jsoninspeckit-plan, and so on), so on macOS and Linux each of those steps now fails withPermission denied(exit 126).All three commands go through
_set_default_integration()inintegrations/_helpers.py. It refreshes shared infrastructure with_install_shared_infra(..., refresh_managed=True), which writes the scripts with their packaged mode, 0644.init,integration install,integration upgradeand the first refresh inswitchcallensure_executable_scripts()after they write the scripts._set_default_integration()didn't. Inswitchthe existing call (command_switch.py:293) runs before the final default refresh, and that refresh writes the scripts a second time.This PR makes the refresh itself write the scripts executable.
install_shared_infra()already passes a mode to_write_shared_bytes(); for a.shfile that starts with a shebang, that mode now gets an execute bit for each class that can read it (the ruleensure_executable_scripts()uses). The mode is set on the temp file before the atomic replace, so it goes through the same symlink checks and the same lifecycle journal as the content. Nothing outside the files the refresh writes is touched. On Windows the mode is unchanged.The first version of this PR called
ensure_executable_scripts()after the refresh instead. That scan follows a symlinked.specify/scriptsand isn't journaled, so I dropped it here; the existing callers of the scan are unchanged.Repro with the real CLI:
main(2ee2b1e)integration switch codexintegration install codex --script sh, thenintegration use codexintegration install codex --script sh, thenintegration uninstall claudeRelease 1.3.3 behaves the same for all three. #5377 added one more path:
switch <current default> --refresh-shared-infranow refreshes too, so it also drops the bits.With this change, the next
use,switchoruninstallalso fixes the unmodified shared scripts of a project that is already affected, because the refresh rewrites them. A script the user edited is preserved by the refresh, so it keeps its current mode;specify integration upgradefixes those, as it does onmain.init,installandupgradego through the same writer, so they now write the scripts executable too, before their ownensure_executable_scripts()call.Testing
.venv/bin/specify --help.venv/bin/python -m pytest tests -qNew CLI tests, one per command, in the files
design/cli.mdassigns them to. Each checks the scripts are executable before the command and still executable after it:test_command_switch.py:TestIntegrationSwitch::test_switch_keeps_shared_scripts_executable, for a new target, an installed target, and the current default with--forceand with--refresh-shared-infratest_command_use.py:TestIntegrationUse::test_use_keeps_shared_scripts_executable, andtest_use_changes_modes_only_on_scripts_it_writes: a user's 0644 shebang script next to the shared ones keeps its mode, also when.specify/scriptsis a symlink to a directory outside the projecttest_command_uninstall.py:TestIntegrationUninstall::test_uninstall_default_keeps_fallback_scripts_executabletests/test_shared_infra_script_mode.py: the mode rule itself (0644 → 0755, 0640 → 0750; packaged mode kept without a shebang, for other suffixes and on Windows)test_installed_adapters.py::test_failed_switch_restores_shared_script_mode_and_content: a switch away from an external adapter that fails after the refresh restores each script's mode and contentWith
shared_infra.pyreverted tomain, the 6 execute-bit cases fail, for exampleAssertionError: switch left shared scripts non-executable: ['check-prerequisites.sh', 'common.sh', 'create-new-feature.sh', 'resolve-template.sh', 'setup-plan.sh', 'setup-tasks.sh']. With the fix, all 8 cases pass. The two mode cases fail on this PR's first commit (the scan made the user's script 0755 in both). They are skipped on Windows, like #3723's test.Full suite on Linux, Python 3.13: 16275 passed, 566 skipped, 1 failed (
uv sync --extra test, thenpytest -n 2, 9 min). The failure,test_version_execution.py::TestWindowsUvToolEnvironment::test_non_windows_uv_tool_dry_run_still_previews_installer, fails the same way onmainhere: Rich wraps the dry-run output, and my checkout's venv path is long enough to be split mid-path. Ruff 0.15.0 (ruff check src tests) passes. I haven't run it on Windows or macOS.AI Disclosure
AI disclosure: Codex CLI (model: gpt-6.1-sol, reasoning effort xhigh, autonomous, offline sandbox) found the dropped execute bits while comparing release 1.3.3 and
mainon the same commands, and wrote a first patch. Claude Code (model: claude-opus-5-5, autonomous) traced every affected command to_set_default_integration(), rewrote the fix and the tests, reran the repro with the real CLI onmainand the branch, ran the full suite and lint, and drafted this description. After the Copilot review of the first commit, Claude Code (model: claude-fable-5-2, autonomous) moved the execute bits into the refresh's own write, added the two mode cases, reran the repro and the full suite, and updated this description. Each commit carries itsAssisted-by:trailers.