Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Mangled generated path on ln_s with relative: true #129

Open
@delfianto

Description

I found this accidently when trying to wrote a dotfile linker utility.

Seems like FileUtils.ln_s will fail when the resulting relative path contains ../ (one directory hierarchy higher) as the relative path being generated is mangled.

Sample snippets to reproduce:

FileUtils.ln_s(
 "/home/mipan/.dotfiles/zsh", "/home/mipan/.config/zsh",
 verbose: true, noop: true, relative: true
)
Output: ln -s /home/mipan/.config/zsh/zsh

And this is not a pure logging bug, when the noop set to false:

FileUtils.ln_s(
 "/home/mipan/.dotfiles/zsh", "/home/mipan/.config/zsh",
 verbose: true, noop: false, relative: true
)
ln -s /home/mipan/.config/zsh/zsh
/usr/lib/ruby/3.4.0/fileutils.rb:760:in 'File.symlink': No such file or directory @ rb_file_s_symlink - (, /home/mipan/.config/zsh/zsh) (Errno::ENOENT)
	from /usr/lib/ruby/3.4.0/fileutils.rb:760:in 'block in FileUtils.ln_sr'
	from /usr/lib/ruby/3.4.0/fileutils.rb:765:in 'FileUtils.ln_sr'
	from /usr/lib/ruby/3.4.0/fileutils.rb:709:in 'FileUtils.ln_s'
	from ./dot_linker.rb:362:in '<main>'

Sample for working parameters:

FileUtils.ln_s(
 "/home/mipan/.dotfiles/zsh", "/home/mipan/zsh",
 verbose: true, noop: true, relative: true
)
Output: ln -s .dotfiles/zsh /home/mipan/zsh

Ruby version:

❯ ruby --version
ruby 3.4.4 (2025年05月14日 revision a38531fd3f) +PRISM [x86_64-linux]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /