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
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 1553
def lchmod(mode) File.lchmod(mode, @path) end
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 ““