Albacore / albacore

Albacore is a professional quality suite of Rake tasks for building .NET or Mono based systems.
www.albacorebuild.net
221 stars 64 forks source link

Exec can't handle commands with space in it #117

Closed chester89 closed 10 years ago

chester89 commented 10 years ago

I'm using albacore 1.0.0.rc3 gem and tried to use exec task to invoke NuGet restore on Mono. Here's my task:

exec :downloadNugets do |cmd|
  runtime = "mono "
  cmd.command = runtime + "tools/nuget/nuget.exe"
  cmd.parameters = ["restore solution.sln", "-PackagesDirectory packages"]
end

When I invoke it, Rake says that path was not found. I assume that's because there's a space inside it? When I try to surround path with single quotes, the error stays the same. Is there a workaround?

AnthonyMastrean commented 10 years ago

That's odd. We try to be thorough about quoting anything that might be a path or have spaces. You can see that the RunCommand class does quote the property.

cmd = "\"#{executable}\""

It does some other funky stuff on expanding the path and whatnot... would you turn on verbose logging and see what Albacore thinks the full path of that command is? (please copy that here when you get it)

Albacore.configure do |config|
  config.log_level = :verbose
end

And check whether it truly exists on your system

$ irb
irb> File.exist?("full/path/to/cmd/file")
chester89 commented 10 years ago

The thing is - when I execute this in the console by hand, it works fine, so file is present. By the way, the same thing with XBuild - when I type 'xbuild mysolution.sln /p:Configuration=Debug' in the console, it works. But not the rake task. Very odd. I'll answer the questions as soon as I get back to the Linux machine (first thing after weekend).

2014-07-05 0:06 GMT+04:00 Anthony Mastrean notifications@github.com:

That's odd. We try to be thorough about quoting anything that might be a path or have spaces. You can see that the RunCommand class https://github.com/Albacore/albacore/blob/legacy/lib/albacore/support/runcommand.rb#L40 does quote the property.

cmd = "\"#{executable}\""

It does some other funky stuff on expanding the path and whatnot... would you turn on verbose logging https://github.com/Albacore/albacore/wiki/Configuration#logging and see what Albacore thinks the full path of that command is? (please copy that here when you get it)

Albacore.configure do |config| config.log_level = :verboseend

And check whether it truly exists on your system

$ irb irb> File.exist?("full/path/to/cmd/file")

— Reply to this email directly or view it on GitHub https://github.com/Albacore/albacore/issues/117#issuecomment-48068171.

С уважением, Чермённов Глеб, тел. (916) 314-9324

chester89 commented 10 years ago

Here's rake task I use:

exec :downloadNugets do |cmd|
  cmd.working_directory = Dir.pwd
  runtime = "mono "
  cmd.command = runtime + "tools/nuget/nuget.exe"
  cmd.parameters = ["restore MonoExamples.sln", "-PackagesDirectory packages"]
end

here's the actual output:

DEBUG -- : Executing Exec: "mono tools/nuget/nuget.exe" restore solution.sln -PackagesDirectory packages
sh: 1: mono tools/nuget/nuget.exe: not found

I guess albacore treats whole string 'mono tools/nuget/nuget.exe' as a file path, and that's the problem.

haf commented 10 years ago

It's per design. Use sh if you want other behaviour.

chester89 commented 10 years ago

Fine. But what about xbuild? Because the following task still gives me an error.

xbuild :monobuild => :downloadNugets do |cmd|
  cmd.solution = "solution.sln"
  cmd.targets = [:Build]
  cmd.properties = {:Configuration => "Debug"}
end
haf commented 10 years ago

I'm going to let @AnthonyMastrean answer that. Otherwise, you've very welcome to v2.0 =)

chester89 commented 10 years ago

@haf I'm planning to look at 2.0 closer, yes.

2014-07-08 11:25 GMT+04:00 Henrik Feldt notifications@github.com:

I'm going to let @AnthonyMastrean https://github.com/AnthonyMastrean answer that. Otherwise, you've very welcome to v2.0 =)

— Reply to this email directly or view it on GitHub https://github.com/Albacore/albacore/issues/117#issuecomment-48280178.

С уважением, Чермённов Глеб, тел. (916) 314-9324

AnthonyMastrean commented 10 years ago

From your debug output, it looks like the command is not being quoted or expanded.

DEBUG -- : Executing Exec: "mono tools/nuget/nuget.exe" restore solution.sln -PackagesDirectory packages

Could you give me the fully-qualified path of that file, btw, so I can construct some similar tests? I haven't touched the RunCommand class yet, but maybe it's time. I was sooo close to releasing 1.0 ;)

chester89 commented 10 years ago

Sure, I'll post it as soon as I can.

2014-07-08 20:37 GMT+04:00 Anthony Mastrean notifications@github.com:

From your debug output, it looks like the command is not being quoted or expanded.

DEBUG -- : Executing Exec: "mono tools/nuget/nuget.exe" restore solution.sln -PackagesDirectory packages

Could you give me the fully-qualified path of that file, btw, so I can construct some similar tests? I haven't touched the RunCommand class yet, but maybe it's time. I was sooo close to releasing 1.0 ;)

— Reply to this email directly or view it on GitHub https://github.com/Albacore/albacore/issues/117#issuecomment-48365094.

С уважением, Чермённов Глеб, тел. (916) 314-9324

chester89 commented 10 years ago

Seems I messed up with directory permissions - because running xbuild with --trace option says 'Permission denied'. That's me being dumb, sorry guys

AnthonyMastrean commented 10 years ago

No way, these computers rarely behave! This might be a good lead for someone else later on. Thanks for sticking with it and finding the root cause :)