ChiliProject is not maintained anymore. Please be advised that there will be no more updates.
We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.
quotes around path when shelling out does not work on Windows (Bug #891)
Description
I encountered the following error when running rake test on Windows 7 with CP 3.0.0 repository cloned:
D:/programs/Ruby187/bin/ruby.exe -I"lib;test" -I"D:/programs/Ruby187/lib/ruby/gems/1.8/gems/rake-0.9.2.2/lib" "D:/programs/Ruby187/lib/ ruby/gems/1.8/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/functional/**/*_test.rb" NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01. Gem.source_index called from D:/programs/Ruby187/lib/ruby/gems/1.8/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21. D:/sources/OSS/IT/chiliproject/lib/redmine/scm/adapters/abstract_adapter.rb:214:in `shellout': No such file or directory - "git" --git- dir='D:/sources/OSS/IT/chiliproject/.git' rev-parse --short=9 HEAD (Redmine::Scm::Adapters::CommandFailed) from D:/sources/OSS/IT/chiliproject/lib/chili_project/version.rb:46:in `send'
When running the command without the single quotes in the git-dir it works fine.
Felix mentioned that GitAdapter doesn't have them either so they are probably not needed.
Associated revisions
- Norwegian added (Kai Olav Fredriksen)
- Finnish updated (Antti Perkiömäki)
- Czech updated (Maxim Krušina)
- Russian updated (Michael Pirogov)
- Polish updated (Mariusz Olejnik)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1289 e93f8b46-1217-0410-a6f0-8f06a7374b81
Correct quotation #891
The Windows shell doesn't seem to support single quotes…
Contributed by Dies Koper, Luke Carrier
Switch to GitAdapter for quoting #891
Fixes problems with paths containing quotes (sic)
History
Updated by Dies Koper at 2012-02-17 01:42 am
FYI, by simply removing the quotes in version.rb I was able to confirm all tests pass on Windows Server 2003 SE SP2 with pg 0.9.0 and 0.13.1.
712 tests, 2199 assertions, 0 failures, 0 errors ... 1181 tests, 2141 assertions, 0 failures, 0 errors
Updated by Felix Schäfer at 2012-02-17 12:48 pm
Just removing the quotes probably won't be enough because it will probably break as soon as there's a space in the path, but it's a good starting point. I don't know windows enough, could you see if it works if double instead of single quotes?
Updated by Dies Koper at 2012-02-20 03:19 am
You're probably right. I've done the tests again, even renamed my CP installation directory to contain a few spaces ("d:\sources\OSS\IT\dir with spaces\chiliproject"), with double quotes and all passed.
I've also run the tests on CentOS with this change to confirm it didn't break anything there.
This is what I now have in version.rb:
git.send(:shellout, "#{git.sq_bin} --git-dir=\"#{git_dir}\" rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp
I'd push a patch but git is giving me weird errors.
Updated by Luke Carrier at 2012-02-29 11:02 pm
I promise I'll actually start writing my own fixes soon...haha. Here's another patch, it's working perfectly for me on a couple of RedHat 5/6 boxes:
diff --git a/lib/chili_project/version.rb b/lib/chili_project/version.rb index 8065451..894e807 100644 --- a/lib/chili_project/version.rb +++ b/lib/chili_project/version.rb @@ -43,7 +43,7 @@ module ChiliProject git_dir = Rails.root.join('.git') if File.directory? git_dir - git.send(:shellout, "#{git.sq_bin} --git-dir='#{git_dir}' rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp + git.send(:shellout, "#{git.sq_bin} --git-dir=\"#{git_dir}\" rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp end end end
Updated by Felix Schäfer at 2012-02-29 11:43 pm
As this shouldn't change anything on unixes and has been confirmed by Dies to work on Windows, committed in 4b5271f, thanks to you both!
Luke: I don't care much whose problems you tackle, even going through the "low-hanging" issues and confirming/consolidating fixes is a huge help, thanks :-)
- Status changed from Open to Closed
Updated by Toshi MARUYAMA at 2012-03-01 03:45 am
This commit cannot work on Linux path with double-quote.
$ pwd /REDMINE/WORK-DIR-NO-RAID/git-workdir/chili"project $ LC_ALL=C ruby script/server -e test -p 7000 => Booting WEBrick => Rails 2.3.14 application starting on http://0.0.0.0:7000 NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01. Gem.source_index called from /home/moriya/.rvm/gems/ruby-1.8.7-p357/gems/rails-2.3.14/lib/rails/gem_dependency.rb:21. sh: -c: line 0: unexpected EOF while looking for matching `"' sh: -c: line 1: syntax error: unexpected end of file => Call with -d to detach => Ctrl-C to shutdown server [2012-03-01 12:43:33] INFO WEBrick 1.3.1 [2012-03-01 12:43:33] INFO ruby 1.8.7 (2011-12-28) [i686-linux] [2012-03-01 12:43:33] INFO WEBrick::HTTPServer#start: pid=7262 port=7000
- Status changed from Closed to Open
Updated by Felix Schäfer at 2012-03-01 07:55 am
Toshi MARUYAMA wrote:
This commit cannot work on Linux path with double-quote.
Indeed, but it wouldn't have worked with a single-quote in the path before that either :-)
Thanks for noticing and reporting, I'll see about that before the next release.
Updated by Luke Carrier at 2012-03-01 09:05 pm
Perhaps something like this instead?
diff --git a/lib/chili_project/version.rb b/lib/chili_project/version.rb index 8065451..894e807 100644 --- a/lib/chili_project/version.rb +++ b/lib/chili_project/version.rb @@ -43,7 +43,7 @@ module ChiliProject git_dir = Rails.root.join('.git') if File.directory? git_dir - git.send(:shellout, "#{git.sq_bin} --git-dir='#{git_dir}' rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp + git.send(:shellout, "#{git.sq_bin} --git-dir=\"#{git_dir.gsub(/["]/, "\\\\\"")}\" rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp end end end
Updated by Felix Schäfer at 2012-03-01 11:40 pm
Luke Carrier wrote:
Perhaps something like this instead?
Like this yes, exactly that probably won't work as (if memory serves) you'd be calling gsub
on a Pathname
, Pathname#gsub
is a private method though.
I think the best approach is to just use the shell_quote
method available from the SCM adapters, i.e. git.shell_quote "string"
in this case.
- Category deleted (
Testing)
Updated by Felix Schäfer at 2012-03-01 11:50 pm
OK, this works on OS X with "
and '
in the path, Dies (or anyone else), could you try this patch (against current master) on windows?
1diff --git a/lib/chili_project/version.rb b/lib/chili_project/version.rb
2index 894e807..2afb5a4 100644
3--- a/lib/chili_project/version.rb
4+++ b/lib/chili_project/version.rb
5@@ -43,7 +43,7 @@ module ChiliProject
6 git_dir = Rails.root.join('.git')
7
8 if File.directory? git_dir
9- git.send(:shellout, "#{git.sq_bin} --git-dir=\"#{git_dir}\" rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp
10+ git.send(:shellout, "#{git.sq_bin} --git-dir=#{git.shell_quote git_dir.to_s} rev-parse --short=9 HEAD") { |io| io.read }.to_s.chomp
11 end
12 end
13 end
Updated by Dies Koper at 2012-03-05 05:41 am
I have applied the patch to today's master and reran the tests on Windows 7 in a directory name with spaces. All tests passed.
Updated by Felix Schäfer at 2012-03-05 05:23 pm
Dies, thanks for testing, committed in ef5dddf.
- Assignee deleted (
Felix Schäfer) - Status changed from Open to Closed