athityakumar/colorls

Ruby cannot close file directory when using `--git-status` (or `--gs`)

sravioli opened this issue · 5 comments

Description

Hello, when running $ colorls --git-status or $ colorls --gs the following line gets printed before any file gets listed:

C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/colorls-1.4.6/lib/colorls/git.rb:55: warning: cannot close fd before spawn

Compared with $ colorls:

immagine

--git-status with --tree

I have created a shell alias to combine the tree view with the status of the git repo:

alias lsgt='colorls --sort-dirs --git-status --tree'

When running $ lsgt the previous message will be printed as usual, it will then be printed after every occurrence of  dir/:

immagine

Compare with $ colorls --sort-dirs --tree:

immagine

--git-status on non git repos

The message will be printed even if the directory is not a git repo. Running $ colorls --almost-all --gs on the fish shell results in the following:

immagine

Environment

I am using Git Bash on Windows. This does occur also on PW, CMD and fish shell (on MINGW6/MSYS)


  • Relevant Issues : (none)
  • Relevant PRs : (none)
  • Type of issue :
    • Installation
    • Font-related
    • Feature request
    • Bug in existing feature
    • Developer mode : Code quality / Tests / Documentation
avdv commented

Thanks for the report. That's a warning from Ruby caused by some deficiency of your platform.

Try to set RUBYOPT=-W0 in your shell. This should supress all warnings.

Setting export RUBYOPT='-W0' in my .bashrc suppresses the warning in git bash, no luck on Powershell. I've tried set RUBYOPT='-W0' in my $profile but the warning is there.

avdv commented

A quick search revealed that you have to use $env:RUBYOPT = '-W0' in Powershell to set an env variable.

Cool! Now it works. Thanks :)

avdv commented

I'll fix this properly in the next release.

Setting the RUBYOPT variable is just a workaround.