maiyama18 / LicensesPlugin

A Swift Package build tool plugin to collect licenses of the library used in your swift package
MIT License
76 stars 3 forks source link

Cannot find "cp" when executed from command line #17

Closed mornin-ystIUBqR closed 1 year ago

mornin-ystIUBqR commented 1 year ago

Currently, my project is configured with the following Package.swift.

let package = Package(
     ...
     .target(
            name: "Licence",
            plugins: [
                 .plugin(name: "LicensesPlugin", package: "LicensesPlugin")
            ]
     ),
     ...
     .executableTarget(
           name: "SomeBinary"
     )
)

When I try to use SomeBinary in a swift build, the following error occurs.

error: Plugin does not have access to a tool named "cp".

It seems that the location of the cp command has not been discovered.

This does not affect the execution of SomeBinary.

maiyama18 commented 1 year ago

@mornin-sculpture Thanks for reporting the issue! I could reproduce the issue by setting up according to Package.swift you provided. I didn't imagine that this plugin is used from executable target, but that usage is completely valid.

I'll fix the issue and create a new release soon.

maiyama18 commented 1 year ago

📝

I came up with three options to solve this issue.

  1. Add executable target to copy the file, and use it instead of cp command.
  2. Add binary target to copy the file, and use it instead of cp command.
  3. Specify absolute path of cp command. Replace try context.tool(named: "cp").path with Path("/bin/cp").

I tried 1 in #19 , it seemed that it worked well but there were some problem ref: #20 . And 2 and 3 seems solutions that far from ideal... 2 is too complicated and 3 can be not reliable.

maiyama18 commented 1 year ago

Fixed by 0.1.6