Skip to content

File.path doesn't raise Encoding::CompatibilityError for ASCII-incompatible string #9120

@nobu

Description

@nobu

Environment Information

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)
    jruby 10.0.2.0 (3.4.2) 2025-08-07 cba6031bd0 Java HotSpot(TM) 64-Bit Server VM 21.0.8+12-LTS-250 on 21.0.8+12-LTS-250 +indy +jit [arm64-darwin]

  • Operating system and platform (e.g. uname -a)
    Darwin mac.local 25.1.0 Darwin Kernel Version 25.1.0: Mon Oct 20 19:30:01 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6031 arm64 arm Darwin

Other relevant info you may wish to add:

  • Installed or activated gems
  • Application/framework version (e.g. Rails, Sinatra)
  • Environment variables

Expected Behavior

CRuby raises an Encoding::CompatibilityError.

$ ruby -e 'p File.path("a".encode("UTF-32BE"))'
ruby 4.0.0dev (2025-12-06T11:11:40Z master 0346206d3e) +PRISM [arm64-darwin25]
-e:1:in 'File.path': path name must be ASCII-compatible (UTF-32BE): "a" (Encoding::CompatibilityError)
	from -e:1:in '<main>'

Actual Behavior

JRuby doesn't.

$ jruby -v -e 'p File.path("a".encode("UTF-32BE"))'
jruby 10.0.2.0 (3.4.2) 2025-08-07 cba6031bd0 Java HotSpot(TM) 64-Bit Server VM 21.0.8+12-LTS-250 on 21.0.8+12-LTS-250 +indy +jit [arm64-darwin]
"a"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions