Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đã đóng
#129 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
68/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
ruby
Lĩnh vực
tooling

Hướng nghiên cứu

Bắt đầu với fileutils.rb quanh dòng 709 và 760, nơi stack trace cho thấy FileUtils.ln_s và FileUtils.ln_sr xử lý liên kết tương đối. Tái hiện các snippet bị lỗi và hoạt động với relative: true, kiểm tra cả hai chế độ noop. Công việc được hoàn tất khi trường hợp thư mục cấp cao hơn tạo ra đích tương đối chính xác trong đầu ra verbose và tạo symlink thành công.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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]
Ngôn ngữ chính
Ruby
Star
69
Fork
37
Merge trung bình
3 giờ 38 phút
Pull request đã merge (30 ngày)
19

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ruby/fileutils

Tất cả issue của ruby/fileutils

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.