Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

Pathname#lchmod

(::Integer mode) -> ::Integer
lchmod(mode) → 1

Not supported on Linux or Windows (raises NotImplementedError).

When supported: like Pathname#chmod, but does not follow symbolic links, and therefore changes the mode of the entry specified by self:

“‘ruby file = Pathname(’t.tmp’) file.write(”) File.symlink(‘t.tmp’, ‘link’) symlink = Pathname(‘link’) file.lstat.mode.to_s(8) # => “100644” symlink.lstat.mode.to_s(8) # => “120755” symlink.lchmod(0777) file.lstat.mode.to_s(8) # => “100644” symlink.lstat.mode.to_s(8) # => “120777” file.delete symlink.delete ““

See also #join #lchown #has_trailing_separator? #lstat also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0