Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Mangled generated path on `ln_s` with `relative: true`

Closed
#129 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
ruby
Domain
tooling

Research direction

Start with fileutils.rb around lines 709 and 760, where the stack trace shows FileUtils.ln_s and FileUtils.ln_sr handling the relative link. Reproduce the failing and working snippets with relative: true, checking both noop modes. Done means the higher-directory case produces the correct relative target in verbose output and creates the symlink successfully.

Written by the indexing model from the issue text.

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]
Dominant language
Ruby
Stars
69
Forks
37
Avg merge
3h 38m
Merged PRs (30d)
19

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ruby/fileutils

All issues in ruby/fileutils

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.