tmm1/ripper-tags

Doesn't work well with cat's output

TG-KK opened this issue · 3 comments

TG-KK commented

Given my Gemfile is

gem 'cucumber'
gem 'rest-client'

And I export gem paths using

bundle list --paths > gem_list

Then I get gem_list as

$ cat gem_list
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/builder-3.2.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/bundler-1.10.6
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/cucumber-2.1.0
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/cucumber-core-1.3.0
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/diff-lcs-1.2.5
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/domain_name-0.5.25
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/ffi-1.9.10-x86-mingw32
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/gherkin3-3.1.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/http-cookie-1.0.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/mime-types-1.25.1
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/multi_json-1.11.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/multi_test-0.1.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/netrc-0.11.0
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/rest-client-1.8.0-x86-mingw32
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/unf-0.1.4
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/unf_ext-0.0.7.1-x86-mingw32

When I run ripper-tags using cat

ripper-tags -R `cat gem_list` -V

Then ripper-tags only processes the last gem path & then just stops

$ ripper-tags -R `cat gem_list` -V
Parsing file H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/unf_ext-0.0.7.1-x86-mingw32/ext/unf_ext/extconf.rb
Parsing file H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/unf_ext-0.0.7.1-x86-mingw32/lib/unf_ext/version.rb
Parsing file H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/unf_ext-0.0.7.1-x86-mingw32/lib/unf_ext.rb
Parsing file H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/unf_ext-0.0.7.1-x86-mingw32/test/helper.rb
Parsing file H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/unf_ext-0.0.7.1-x86-mingw32/test/test_unf_ext.rb

I can't reproduce this. Maybe this bug is something specific to Windows environment? Which ripper-tags -v do you have? What kind of shell do you run this command in?

What happens when you run this command:

ruby -e 'puts ARGV' `cat gem_list`
TG-KK commented

Yes its on Windows. I'm using GNU Bash shell that comes with Git, over ComEmu.

Ripper-tags : 0.3.0
Ruby : ruby 2.2.3p173 (2015-08-18 revision 51636) [i386-mingw32]
Windows : Win Server 2008 R2 Enterprise
Bash shell : GNU bash, version 4.3.42(2)-release (x86_64-pc-msys)
ConEmu : 150420

ruby -e 'puts ARGV' `cat gem_list`

gives

$ ruby -e 'puts ARGV' `cat gem_list`
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/builder-3.2.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/bundler-1.10.6
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/cucumber-2.1.0
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/cucumber-core-1.3.0
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/diff-lcs-1.2.5
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/domain_name-0.5.25
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/ffi-1.9.10-x86-mingw32
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/gherkin3-3.1.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/http-cookie-1.0.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/mime-types-1.25.1
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/multi_json-1.11.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/multi_test-0.1.2
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/netrc-0.11.0
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/rest-client-1.8.0-x86-mingw32
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/unf-0.1.4
H:/ruby-2.2.3-i386-mingw32/lib/ruby/gems/2.2.0/gems/unf_ext-0.0.7.1-x86-mingw32

OK so the problem is that gem_list file on Windows will have CRLF endings, meaning that lines end with \r\n. However, when you use that as arguments to an executable with cat gem_list, they will get split on \n only and each argument will remain with an extra \r in the end of the string—except the last argument. That's why only the last gem in the list was successfully indexed.

Furthermore, ripper-tags didn't issue warnings about non-existing files passed as arguments. The 0.3.1 release now does.

You are still responsible to strip the \r characters before passing arguments to ripper-tags. This should do the trick:

ripper-tags -R `sed '/\r$//' gem_list` -V

Try it and let me know!