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

nugets_pack with nuget_gem_exe path problem #186

Closed joelwilson closed 7 years ago

joelwilson commented 8 years ago

I tried to use the nuget gem today when creating a nugets_pack task. It turns out that albacore improperly constructs the path to nuget.exe:

Errno::EINVAL: Invalid argument - c:\Users\jwilson\Code\MediaManager\c:\opscode\chefdk\embedded\lib\ruby\gems\2.1.0\gems\nuget-2.8.60717.93\bin\nuget.exe

The problem appears to be that the path_to method is written to handle relative paths only. However, the find_nuget_gem_exe method returns the absolute path to the executable.

At least, this is my experience on Windows.

haf commented 8 years ago

/cc @wallymathieu

We should change path_to to only expand relative paths.

wallymathieu commented 8 years ago

Perhaps something like

require 'pathname'
...
      def path_to path, cwd
        if (Pathname.new path).absolute?
           return path
        else
           File.expand_path( File.join(@opts.get(:original_path), path), cwd )
       end

?

haf commented 8 years ago

Sounds like a good solution! @joelwilson – do you want to do the honours?

joelwilson commented 8 years ago

I can try out the fix but not until I get back to a Windows machine on Monday. On Sep 12, 2015 2:21 AM, "Henrik Feldt" notifications@github.com wrote:

Sounds like a good solution! @joelwilson https://github.com/joelwilson – do you want to do the honours?

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

haf commented 8 years ago

No rush :). Try it out Monday and send a PR then.

wallymathieu commented 8 years ago

Sounds good!

haf commented 8 years ago

@joelwilson Any progress on this :)?

joelwilson commented 8 years ago

@haf sorry I haven't been working with ruby or albacore in a while. Does someone else want to make this change?

haf commented 8 years ago

I think you were onto something with the specific gems for paket and/or nuget.

VoX commented 8 years ago

This is still pretty annoying if you just want to run nuget.exe as found in the path.

nugets_restore works as expected

nugets_restore :nuget_restore => [:check_nuget] do |p|
    p.out = 'packages'
    p.exe = 'nuget.exe'
end

But nugets_pack does not. It concats the executable name to the working directory causing it to fail

nugets_pack :pack do |p|
    p.files   = 'project.csproj'
    p.out     = 'build'
    p.exe = 'nuget.exe'
end

Albacore::CommandNotFoundError: Command failed with status (127) - number 127 in particular means that the operating system could not find the executable: C:\dev\project\nuget.exe

wallymathieu commented 8 years ago

So it would be nice to normalise the behaviour.

On Tue, 26 Jan 2016 19:52 Ian Hills notifications@github.com wrote:

This is still pretty annoying if you just want to run nuget.exe as found in the path.

This works as expected nugets_restore :nuget_restore => [:check_nuget] do |p| p.out = 'packages' p.exe = 'nuget.exe' end

This concats the executable name to the working directory causing it to fail

nugets_pack :pack do |p| p.files = 'project.csproj' p.out = 'build' p.exe = 'nuget.exe' end

Albacore::CommandNotFoundError: Command failed with status (127) - number 127 in particular means that the operating system could not find the executable: C:\dev\project\nuget.exe

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

wallymathieu commented 8 years ago

@haf what's the status on this one? The path_to logic should perhaps be moved to "paths.rb" and amended with http://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby ?

haf commented 8 years ago

It should use the PATH. Good catch.

haf commented 7 years ago

Ping; what's the consensus? We should default to PATH and then go towards folder-local files?

haf commented 7 years ago

Timed out.