Skip to content

Conversation

@corybsa
Copy link

@corybsa corybsa commented Feb 2, 2026

Added a function to format paths for cross-platform compatibility. I am not well versed in Lua, please let me know if there is a better way to do this.

Added a function to format paths for cross-platform compatibility.
Comment on lines +19 to 21
format_path("%s", "tmp", "99-%d"),
vim.uv.cwd(),
math.floor(math.random() * 10000)
Copy link

Choose a reason for hiding this comment

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

Bug: The format_path function creates a path in a tmp subdirectory relative to the current working directory, which is unlikely to exist on Windows, causing file operations to fail.
Severity: HIGH

Suggested Fix

Instead of hardcoding a relative tmp directory, the code should be modified to use the system's actual temporary directory. Functions like vim.fn.tempname() or an equivalent method to get the OS-specific temp path (e.g., from the %TEMP% environment variable on Windows or /tmp on Unix-like systems) should be used to ensure temporary files are created in a valid, writable location.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: lua/99/utils.lua#L19-L21

Potential issue: The `format_path` function constructs a file path by joining components
with the platform-specific separator. On Windows, this results in a path like
`C:\Users\...\tmp\99-1234`. The code attempts to create a file in a `tmp` subdirectory
relative to the current working directory. This `tmp` directory is not a standard
Windows temporary location and is unlikely to exist, which will cause subsequent file
operations like `io.open()` to fail. The intended behavior was likely to use the
system's designated temporary directory.

Did we get this right? 👍 / 👎 to inform future reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant