Skip to content

Conversation

claspell
Copy link
Collaborator

@claspell claspell commented Jun 18, 2025

Draft Powered by Pull Request Badge

Summary

Replace custom RuntimeWorkdirManager directory logic with the standard dirs.dev library for better cross-platform directory handling.

Changes

  • ✅ Replaced custom directory resolution with dirs.dev factory methods
  • ✅ Fixed compilation errors from private constructor usage
  • ✅ Implemented missing obtainWorkdir() and workSubdir() methods
  • ✅ Build tests passing

Impact

  • Better cross-platform directory handling (Windows, macOS, Linux)
  • Reduced maintenance burden by using standard library
  • More reliable user config/cache directory detection

Fixes #1286

Testing

  • CI/CD checks pass
  • Manual testing on different platforms (optional)

- Update version catalog to use official dev.dirs:directories:26
- Add directories-jvm imports to RuntimeWorkdirManager
- Replace custom directory logic with dirs.dev providers
- Simplify userConfigDirectory and cachesDirectory implementations
- Comment out platform-specific helper functions

Progress towards #1286
@sgammon sgammon added enhancement New feature or request 🚧 WIP Works-in-progress. Blocks merge labels Jun 18, 2025
@sgammon sgammon added this to Elide Jun 18, 2025
@sgammon sgammon added this to the Release R16: Beta milestone Jun 18, 2025
@sgammon sgammon moved this to In Progress in Elide Jun 18, 2025
@claspell claspell changed the title [WIP] chore: migrate to dirs.dev library [WIP] chore: switch to dirs.dev library Jun 19, 2025
claspell added 2 commits June 20, 2025 16:34
- Build successful with 'elide build'
- Functionality verified with 'elide info'
- All directory paths resolving correctly
- Ready for review

Fixes #1286
Copy link

codecov bot commented Jun 26, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 6 lines in your changes missing coverage. Please review.

Project coverage is 40.91%. Comparing base (4e26cf3) to head (aecb0b1).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
...main/kotlin/elide/tool/io/RuntimeWorkdirManager.kt 66.66% 3 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1482      +/-   ##
==========================================
- Coverage   41.99%   40.91%   -1.08%     
==========================================
  Files         680      692      +12     
  Lines       31366    32335     +969     
  Branches     4386     4519     +133     
==========================================
+ Hits        13172    13230      +58     
- Misses      16627    17532     +905     
- Partials     1567     1573       +6     
Flag Coverage Δ
jvm 40.91% <66.66%> (-1.08%) ⬇️
lib 40.91% <66.66%> (-1.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...main/kotlin/elide/tool/io/RuntimeWorkdirManager.kt 63.44% <66.66%> (+0.38%) ⬆️

... and 28 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4e26cf3...aecb0b1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claspell claspell changed the title [WIP] chore: switch to dirs.dev library chore: switch to dirs.dev library Jun 26, 2025
@claspell
Copy link
Collaborator Author

@sgammon Ready for review

Should I clean up the commented-out legacy code, or do you want to keep it for reference during review?

@claspell claspell marked this pull request as ready for review June 26, 2025 18:51
@claspell claspell requested a review from sgammon as a code owner June 26, 2025 18:51
dirs = "bf76af41b9"
dirs = "26"
Copy link
Member

Choose a reason for hiding this comment

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

this override was in place because we needed to fork the lib to build with updated deps (i think?). anyway, it's probably worth keeping, or figuring out why we forked and making a decision based on that (if we forked to add features, are those features worth keeping? for fixes, are the fixes still needed?)

Comment on lines +56 to +63
// private const val nixTempPath = "/tmp/elide-runtime"
// private const val runtimeDirPrefix = "elide-runtime-"
// private const val elideHomeDirectory = ".elide"
//private const val elideConfigDirectory = "elide"
//private const val configDirectory = ".config"

// private val linuxCachesPath = "~/elide/caches/v${Elide.version()}"
// private val darwinCachesPath = "/Library/caches/elide/v${Elide.version()}"
Copy link
Member

Choose a reason for hiding this comment

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

const val must be listed literally, because it's "constant." on the other hand, const can be dropped and you can just use @JvmStatic val, which is a "static value," that is computed at program startup time, instead of build time.

Comment on lines +103 to +108
// private fun currentSharedTempPrefix(): String {
// return StringBuilder().apply {
// append(runtimeDirPrefix)
// append(Elide.version())
// }.toString()
// }
Copy link
Member

Choose a reason for hiding this comment

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

this will get easier to review, and easier to work with, if you remove code instead of commenting. i get the impulse

Comment on lines +183 to 191
private fun obtainWorkdir(): Path {
if (!this::rootDirectory.isInitialized) {
rootDirectory = Path.of(projectDirectories.cacheDir)
if (!rootDirectory.exists()) {
Files.createDirectories(rootDirectory)
}
}
return rootDirectory
}
Copy link
Member

Choose a reason for hiding this comment

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

your code here improves on what was here, but the approach could use some tuning. i wonder if we can avoid checking the existence / creating the path on first access? maybe we can create a wrapper type for this? ill connect with you on discord about it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🚧 WIP Works-in-progress. Blocks merge
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Switch to dirs.dev
2 participants