BUCKYVERSE

Briefly.NoRootDirectoryError Fix Documentation

Problem Summary

The test suite was failing with Briefly.NoRootDirectoryError and permission errors because:

  1. Incorrect Root Directory Configuration: The Briefly configuration in config/test.exs was pointing to config/tmp instead of the project root's tmp directory.
  2. System Temp Directory Fallback: Some code was still referencing system temp directories (/var/folders/.../T/) instead of the project-local tmp.
  3. Permission Issues: Potential permission problems with the tmp directory.

Fixes Applied

1. Fixed Configuration (config/test.exs)

Before:

config :briefly, root: Path.expand("tmp", Path.dirname(__ENV__.file))

This pointed to /Volumes/Storage/belmendo/Projects/codexis/config/tmp

After:

project_root = Path.dirname(Path.dirname(__ENV__.file))
tmp_dir = Path.expand("tmp", project_root)
config :briefly, 
  root: tmp_dir,
  directory: true,
  prefix: "codexis_test_"

This correctly points to /Volumes/Storage/belmendo/Projects/codexis/tmp

2. Added Robust Directory Creation and Permission Handling

The new configuration:

3. Enhanced Test Helper Functions (test/support/test_helpers.ex)

Added fallback mechanisms that:

4. Improved Debugging (test/test_helper.exs)

Enhanced the debug output to show:

Verification

Quick Test Script

Run the Briefly configuration test script:

cd /Volumes/Storage/belmendo/Projects/codexis
elixir test_briefly.exs

Permission Check Script

Run the permission verification script:

cd /Volumes/Storage/belmendo/Projects/codexis
chmod +x check_permissions.sh
./check_permissions.sh

Minimal Test Case

Run the Briefly-specific test:

cd /Volumes/Storage/belmendo/Projects/codexis
mix test test/briefly_config_test.exs --seed 0

Expected Behavior

After these fixes:

  1. All temporary files and directories should be created in /Volumes/Storage/belmendo/Projects/codexis/tmp
  2. No system temp directories should be used (/var/folders/.../T/)
  3. Tests should run without Briefly.NoRootDirectoryError
  4. Permission errors should be eliminated

Troubleshooting

If Briefly Still Fails

  1. Check directory permissions:

    ls -la /Volumes/Storage/belmendo/Projects/codexis/tmp
    
  2. Verify configuration is loaded:
    Run mix test test/briefly_config_test.exs and check the debug output

  3. Check for conflicting environment variables:

    echo $TMPDIR
    echo $TMP
    echo $TEMP
    
  4. Manual fallback test:
    The enhanced test helpers will automatically fall back to manual file creation if Briefly fails

If Tests Still Reference System Temp

  1. Check for hardcoded paths in test files
  2. Look for direct System.tmp_dir() calls that bypass Briefly
  3. Search for TMPDIR environment variable usage in the codebase

Performance Notes

Files Modified

  1. config/test.exs - Fixed Briefly root directory configuration
  2. test/test_helper.exs - Enhanced debugging and verification
  3. test/support/test_helpers.ex - Added fallback mechanisms
  4. test/briefly_config_test.exs - Added verification test (new)
  5. test_briefly.exs - Standalone test script (new)
  6. check_permissions.sh - Permission verification script (new)

Key Configuration Values

This comprehensive fix should resolve all Briefly-related issues and provide robust fallback mechanisms for any edge cases.