-
Notifications
You must be signed in to change notification settings - Fork 806
Description
Bug Description
When installing agent-browser globally via Volta, the resulting agent-browser binary symlink is broken, causing the CLI to fail with a "No such file or directory" error.
Environment
- Volta version: 2.0.2 (likely affects all versions)
- Node version: 22.22.0 (managed by Volta)
- OS: Linux x64 (likely affects macOS as well)
- agent-browser version: 0.8.5
Steps to Reproduce
- Install Volta:
curl https://get.volta.sh | bash - Install agent-browser globally:
volta install agent-browser - Try to run:
agent-browser --help
Expected: CLI runs successfully
Actual: bash: /root/.volta/bin/agent-browser: No such file or directory
Root Cause Analysis
1. Volta's Staging Directory Mechanism
Volta uses a staging directory pattern during package installation:
- Package is first installed to a temp directory:
/root/.volta/tmp/image/packages/.tmpXXXXXX/ - After all scripts complete, the directory is renamed to the final location:
/root/.volta/tools/image/packages/agent-browser/
This is a deliberate design to ensure atomic installations (see Volta source).
2. The Conflict
The postinstall.js script's fixUnixSymlink() function:
- Gets the npm prefix via
npm prefix -g→ returns the staging directory - Creates an absolute symlink to the native binary using this staging path
- Volta then moves the package to its final location
- The symlink now points to a non-existent directory
# The broken symlink
$ ls -la /root/.volta/tools/image/packages/agent-browser/bin/agent-browser
agent-browser -> /root/.volta/tmp/image/packages/.tmpf5Mfos/lib/node_modules/agent-browser/bin/agent-browser-linux-x64
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# This directory no longer exists!Proposed Solution
Detect the Volta environment and skip the symlink optimization, allowing Volta to manage shims as intended:
async function fixUnixSymlink() {
// Skip optimization in Volta environment - Volta uses a staging directory
// that gets renamed after postinstall, breaking absolute symlinks
if (process.env.VOLTA_HOME) {
console.log('ℹ Volta detected: skipping bin optimization (Volta manages shims)');
return;
}
// ... existing code
}The same check should be added to fixWindowsShims().
This is safe because:
VOLTA_HOMEis always set when running under Volta- Volta's shim system handles binary invocation automatically
- The JS wrapper fallback still works correctly
Workaround
Users can manually fix the symlink after installation:
cd /root/.volta/tools/image/packages/agent-browser/bin
rm agent-browser
ln -s agent-browser-linux-x64 agent-browserOr reinstall with npm instead of Volta.
Related
This is a common issue when packages modify symlinks during postinstall. Similar problems have been reported with other package managers that use staging directories.