Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Pathname#make_symlink
(::String | ::Pathname | ::_ToStr old) -> ::Integer
make_symlink(target_path) → 0
pathname_builtin.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/pathname_builtin.rb, line 1940
def make_symlink(old) File.symlink(old, @path) end
Not supported on some platforms.
Creates a symbolic link at the path in self to the entry at target_path:
Example
file_pn = Pathname('/etc/passwd') link_pn = Pathname('/tmp/foo') link_pn.make_symlink(file_pn) link_pn.readlink # => #<Pathname:/etc/passwd> file_pn.read == link_pn.read # => true
If the entry at target_path is itself a symbolic link, that link is not followed:
Example
link2_pn = Pathname('/tmp/bar') link2_pn.make_symlink(link_pn) link2_pn.readlink # => #<Pathname:/tmp/foo> link2_pn.read == file_pn.read # => true # Clean up. link_pn.delete link2_pn.delete