Skip to content

v2.3.14 is crashing: "The file “swiftinfo” couldn’t be opened because there is no such file." #56

@rogerluan

Description

@rogerluan

Hey 👋

After the latest release https://github.com/rockbruno/SwiftInfo/releases/tag/2.3.14 I couldn't get SwiftInfo to work.

On CI it triggers weird and misleading errors (e.g. Error: Unknown option '-u', although I'm not passing any -u option).
On my local machine, attempting to run the same command than CI (swiftinfo -release) I'm getting this:

Error: Unknown option '-r'
Usage: swiftinfo [--help] [--silent] [--verbose] [--print-sourcekit] [<arguments> ...]
  See 'swiftinfo --help' for more information.

I believe this has to do with the major refactor that happened here: #54

Attempting to run swiftinfo -version would work before. Now it throws:

Error: Unknown option '-e'

I'm assuming we should all forcefully adhere to the new API, so then this should work: swiftinfo --version, but:

Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=260 "The file “swiftinfo” couldn’t be opened because there is no such file." UserInfo={NSURL=swiftinfo -- file:///Users/rogerluan/Documents/Projects/redacted/, NSFilePath=/Users/rogerluan/Documents/Projects/redacted/swiftinfo, NSUnderlyingError=0x7fd9a4b04830 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}: file SwiftInfoCore/FileUtils.swift, line 39
[1]    76589 illegal hardware instruction  swiftinfo --version

I noticed that amongst other things, that PR changed instances of ProcessInfo.processInfo.arguments with CommandLine.arguments and those are not interchangeable. See:

#!/usr/bin/swift

import Foundation

print("ProcessInfo.processInfo.arguments.first = ", ProcessInfo.processInfo.arguments.first!)
print("CommandLine.arguments.first = ", CommandLine.arguments.first!)
print("FileManager.default.currentDirectoryPath = ", FileManager.default.currentDirectoryPath)

Outputs:

ProcessInfo.processInfo.arguments.first =  /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
CommandLine.arguments.first =  ./_test.swift
FileManager.default.currentDirectoryPath =  /Users/rogerluan/Documents/Projects/SwiftInfo

So that may be the root cause of the issue, but even after fixing that, I couldn't have it find my Infofile.swift anymore. At this point I'm just gonna rollback to the previous release that is stable and freeze it there for awhile 😞


Quick feedback

The last release should've been a major bump IMO, since it broke existing APIs (it was not backwards compatible). Moreover, looks like it wasn't well tested before being released 😬 I'm just leaving a constructive feedback here 🙈 🤗 We currently use this in production, so stability is important 🙏

Appreciate all the hard work towards this great tool! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions