Skip to content

feat: Windows Compability#479

Open
isaui wants to merge 10 commits intorailwayapp:mainfrom
isaui:feat/windows-support
Open

feat: Windows Compability#479
isaui wants to merge 10 commits intorailwayapp:mainfrom
isaui:feat/windows-support

Conversation

@isaui
Copy link

@isaui isaui commented Mar 9, 2026

Adds Windows compatibility for running railpack on Windows hosts.

Changes

Mise installation

  • Add RAILPACK_MISE_DIR and RAILPACK_MISE_TEST_DIR env vars for custom install paths
  • Windows doesn't have /tmp, so users can configure their own directory
  • Document all env vars in .env.example

Path handling

  • Use path.Join instead of filepath.Join for container paths (always forward slash)
  • Fix getImageName to handle both / and \ separators
  • Fix workspace glob patterns in node provider
  • Fix container copy commands in golang provider

Tested on Windows

  • railpack info
  • railpack plan
  • railpack build

Notes

  • Some tests related to dockerignore and Linux file permissions fail on Windows

isaui added 6 commits March 8, 2026 23:36
…tall path

- Add GetInstallDir() and GetTestInstallDir() functions
- Check RAILPACK_MISE_DIR and RAILPACK_MISE_TEST_DIR env vars
- Fallback to default /tmp/railpack/mise paths
- Add .env.example documenting env vars
…geName

- Normalize backslashes to forward slashes before splitting
- Fix test to use hardcoded / instead of filepath.Separator
- Ensures consistent behavior across platforms
…geName

- Normalize backslashes to forward slashes before splitting
- Fix test to use hardcoded / instead of filepath.Separator
- Ensures consistent behavior across platforms
- golang: use path.Join for container copy commands
- node: use path.Join for workspace glob patterns and package paths
- Fixes Windows test failures in workspace pattern tests
@isaui isaui changed the title Windows Compability feat: Windows Compability Mar 9, 2026
Copy link
Collaborator

@iloveitaly iloveitaly left a comment

Choose a reason for hiding this comment

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

I'd love to better support Windows. Thanks so much for your contribution here.

Left a couple of comments since I really don't understand what the requirements are to get this running on Windows. One thing I would like to do if we're going to support Windows is try to run mise on a Windows machine. We should be able to do that through GitHub Actions

// Create parent directories for the file
parentDir := filepath.Dir(cmd.Path)
// Use path.Dir for container paths (always forward slash)
parentDir := path.Dir(cmd.Path)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did you need to make this change?

Copy link
Author

Choose a reason for hiding this comment

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

image

This function generates mkdir commands that will be executed inside the Linux container by BuildKit. When running railpack on Windows, filepath.Dir returns paths with backslashes, which are invalid in Linux. Using path.Dir ensures the mkdir instruction sent to BuildKit always uses forward slashes, regardless of the host OS.

I tested this by temporarily reverting to filepath.Dir then the build failed with mkdir /app/\etc\mise (backslash), then succeeded with path.Dir.

// resolvePaths determines source and destination paths based on the include path and whether it's local.
// For local paths, only the basename is preserved when copying to /app directory.
// For container paths, the full relative path structure is preserved under /app.
// Note: Uses path.Join (not filepath.Join) for container paths to ensure forward slashes on all platforms.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this important?

Copy link
Author

Choose a reason for hiding this comment

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

The comment explains the technical reason (forward slashes), but let me clarify:

resolvePaths generates copy commands that BuildKit executes inside Linux containers. When running railpack on Windows, filepath.Join would create paths like /app\config\file.json (backslash), which are invalid in Linux. This causes BuildKit to fail when processing the copy instructions.

Using path.Join ensures all paths use forward slashes regardless of host OS, so the same build plan works on Windows, macOS, and Linux.

If you prefer clean code, i can remove that comment.

.env.example Outdated
@@ -0,0 +1,17 @@
# Mise installation directories (Windows: use C:\tmp\railpack\mise)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not the right place to put these sort of variables. checkout the mise [env] config section.

Copy link
Author

Choose a reason for hiding this comment

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

noted

IdiomaticVersionFileTools = "python,node,ruby,elixir,go,java,yarn"
)

// GetInstallDir returns the mise install directory, checking RAILPACK_MISE_DIR env var first
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you help me understand why this is required?

Copy link
Author

Choose a reason for hiding this comment

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

Windows doesn't have a /tmp directory. Without this env var, mise installation fails on Windows because the default path /tmp/railpack/mise doesn't exist and can't be created.

This allows Windows users to specify an alternative path like C:\tmp\railpack\mise. The env var is checked first, falling back to the default /tmp/railpack/mise on Unix systems.

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.

2 participants