Set the long path bit for embedded interpreters too

`rb_w32_sysinit` is documented as being for `ruby(1)`, so a program which embeds libruby may skip it and keep the 260 character limit while `ruby.exe` does not. Call the same initialization from `ruby_setup`, which every embedder reaches through `ruby_init`.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Hiroshi SHIBATAandClaude Opus 5 authored and Hiroshi SHIBATA committed 2026-08-19 16:31:10 +09:00
1 parent bb847847ae
commit b81e0d4888
4 files changed
+24 -7
Notes: git 2026-08-19 07:31:44 +00:00

No files matched your search

+4 -3
View File
@@ -245,9 +245,10 @@ Ruby 4.0 bundled RubyGems and Bundler version 4. see the following links for det
* BSD/OS (BSDi)
* Windows 10 1703 or later no longer needs the `LongPathsEnabled` registry
value to use paths longer than 260 characters. Each path component is still
limited to 255 characters, and a child process still starts with the
`MAX_PATH` limited current directory. [[Bug #18947]]
value to use paths longer than 260 characters. This applies to any process
running the interpreter, including a program which embeds libruby. Each path
component is still limited to 255 characters, and a child process still
starts with the `MAX_PATH` limited current directory. [[Bug #18947]]
## Compatibility issues
+3
View File
@@ -76,6 +76,9 @@ ruby_setup(void)
*/
#if defined(__linux__) && defined(PR_SET_THP_DISABLE)
prctl(PR_SET_THP_DISABLE, 1, 0, 0, 0);
#endif
#if defined(_WIN32)
rb_w32_init_long_paths();
#endif
Init_BareVM();
rb_vm_encoded_insn_data_table_init();
+5
View File
@@ -64,6 +64,11 @@
/* internal/symbol.h */
#define rb_sym_intern_ascii_cstr(...) rb_nonexistent_symbol(__VA_ARGS__)
#ifdef _WIN32
/* win32/win32.c */
void rb_w32_init_long_paths(void);
#endif
/* MRI debug support */
+12 -4
View File
@@ -851,19 +851,27 @@ static int w32_cmdvector(const WCHAR *, char ***, UINT, rb_encoding *);
* when that registry value is set, so the manifest alone is not enough on a
* stock machine. Undocumented, and taken from initLongPathSupport in Go's
* runtime <https://go.dev/src/runtime/os_windows.go>, whose maintainers have
* proposed to drop it <https://github.com/golang/go/issues/66560>. */
static void
init_long_path_support(void)
* proposed to drop it <https://github.com/golang/go/issues/66560>.
*
* Called from rb_w32_sysinit, which runs before the VM exists, and from
* ruby_setup, so that a program which embeds libruby without calling
* ruby_sysinit gets it as well. */
void
rb_w32_init_long_paths(void)
{
/* PEB.BitField, and the IsLongPathAwareProcess bit in it */
enum {peb_bit_field_offset = 3, is_long_path_aware_process = 0x80};
typedef long (WINAPI version_func)(OSVERSIONINFOW *);
typedef void *(WINAPI peb_func)(void);
static int done = 0;
version_func *pRtlGetVersion;
peb_func *pRtlGetCurrentPeb;
OSVERSIONINFOW osvi;
BYTE *bit_field;
if (done) return;
done = 1;
pRtlGetVersion = (version_func *)get_proc_address("ntdll.dll", "RtlGetVersion", NULL);
if (!pRtlGetVersion) return;
memset(&osvi, 0, sizeof(osvi));
@@ -892,7 +900,7 @@ rb_w32_sysinit(int *argc, char ***argv)
SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX);
get_version();
init_long_path_support();
rb_w32_init_long_paths();
//
// subvert cmd.exe's feeble attempt at command line parsing