simonbs / dependency-graph

🕸️ dependency-graph is a command-line tool that can visualize the dependencies of packages.
MIT License
268 stars 11 forks source link

Uncaught exception #27

Open tapokoff opened 7 months ago

tapokoff commented 7 months ago

What happened?

Hi,

Then i try to use your tool on my large project with SPM, i receive this error output:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'working directory doesn't exist.' First throw call stack: ( 0 CoreFoundation 0x0000000187e76ccc __exceptionPreprocess + 176 1 libobjc.A.dylib 0x000000018795e788 objc_exception_throw + 60 2 Foundation 0x0000000188fa0a80 -[NSConcreteTask launchWithDictionary:error:] + 4284 3 dependency-graph 0x000000010507e2f8 $s22ShellCommandRunnerLiveAAV3run13withArguments16fromDirectoryURL0abC00aB6OutputVSaySSG_10Foundation0J0VtFTf4nnd_n + 448 4 dependency-graph 0x0000000105061858 $s22DumpPackageServiceLiveAAV04dumpB033_33DF866953EC50C8C73DEAC71694AABCLL2at10Foundation4DataVAF3URLV_tKF + 260 5 dependency-graph 0x000000010506168c $s22DumpPackageServiceLiveAAV04dumpb8ForSwiftB4File2at10Foundation4DataVAE3URLV_tKF + 248 6 dependency-graph 0x0000000105061980 $s22DumpPackageServiceLiveAAV0abC0Aca2CP04dumpb8ForSwiftB4File2at10Foundation4DataVAG3URLV_tKFTW + 12 7 dependency-graph 0x0000000105073dcc $s26PackageSwiftFileParserLiveAAC09justParseC033_A17BD4055C4467321940459E7754879DLL2at0abC0AFV10Foundation3URLV_tKF + 172 8 dependency-graph 0x000000010507413c $s26PackageSwiftFileParserLiveAAC0abcD0Aca2CP05parseC02at0abC0AGV10Foundation3URLV_tKFTW + 184 9 dependency-graph 0x00000001050731fc $s26PackageSwiftFileParserLive0abC6MapperV3map33_EE38B89A39AD106C0853D66BE4501831LLy0abC0AFV10DependencyOAA012IntermediateabC0VAHOKF + 596 10 dependency-graph 0x0000000105072ea4 $s26PackageSwiftFileParserLive0abC6MapperV3mapy0abC0AEVAA012IntermediateabC0VKF + 1124 11 dependency-graph 0x0000000105073eb4 $s26PackageSwiftFileParserLiveAAC09justParseC033_A17BD4055C4467321940459E7754879DLL2at0abC0AFV10Foundation3URLV_tKF + 404 12 dependency-graph 0x000000010507413c $s26PackageSwiftFileParserLiveAAC0abcD0Aca2CP05parseC02at0abC0AGV10Foundation3URLV_tKFTW + 184 13 dependency-graph 0x000000010515c238 $s28XcodeProjectGraphBuilderLive015AllDependenciescD0V05buildC04from08DirectedC0AFC0aB0AHV_tKF + 956 14 dependency-graph 0x000000010515d458 $s28XcodeProjectGraphBuilderLiveAAC05buildC04from08DirectedC0AEC0aB0AGV_tKF + 192 15 dependency-graph 0x000000010515d56c $s28XcodeProjectGraphBuilderLiveAAC0abcD0Aca2CP05buildC04from08DirectedC0AGC0aB0AIV_tKFTW + 20 16 dependency-graph 0x00000001050628f8 $s12GraphCommandAAV3run9withInput6syntaxySS_AA6SyntaxOtKF + 1216 17 dependency-graph 0x00000001050640cc $s4Main15DependencyGraphV3runyyKF + 320 18 dependency-graph 0x00000001050643b8 $s4Main15DependencyGraphV14ArgumentParser15ParsableCommandAadEP3runyyKFTW + 64 19 dependency-graph 0x00000001050645e4 Main_main + 96 20 dyld 0x000000018799a0e0 start + 2360 ) libc++abi: terminating due to uncaught exception of type NSException

What are the steps to reproduce?

Really large project + SPM

What is the expected behavior?

Without error

simonbs commented 7 months ago

The following error message doesn't indicate to me that this has anything to do with the size of the project.

  • Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'working directory doesn't exist.'

Are you sure that:

  1. You are passing a valid path to the tool?
  2. You are running the project from a valid directory?
tapokoff commented 7 months ago

Yes, I'm sure i pass a correct project path (I tried pass a .xcodeproj and just project folder, results are the same). The reason why I'm so sure, its because before that error message, i receive this warning:

warning: 'XXXXXXX': /Users/XXXXXXX/Developer/XXXXXXX/XXXXXXX/XXXXXXX/Package.swift:23:10: warning: 'package(name:url::)' is deprecated: use package(url::) instead .package( ^

( Changed paths to "XXXXXXX" )

shatodj commented 7 months ago

Same here:


$ dependency-graph XXX.xcodeproj
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'working directory doesn't exist.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000018dd20570 __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x000000018d811eb4 objc_exception_throw + 60
    2   Foundation                          0x000000018ee212f8 -[NSConcreteTask launchWithDictionary:error:] + 4208
    3   dependency-graph                    0x000000010286c4f0 $s22ShellCommandRunnerLiveAAV3run13withArguments16fromDirectoryURL0abC00aB6OutputVSaySSG_10Foundation0J0VtFTf4nnd_n + 448
    4   dependency-graph                    0x000000010284fe88 $s22DumpPackageServiceLiveAAV04dumpB033_33DF866953EC50C8C73DEAC71694AABCLL2at10Foundation4DataVAF3URLV_tKF + 156
    5   dependency-graph                    0x000000010284fd24 $s22DumpPackageServiceLiveAAV04dumpb8ForSwiftB4File2at10Foundation4DataVAE3URLV_tKF + 260
    6   dependency-graph                    0x000000010284ffa0 $s22DumpPackageServiceLiveAAV0abC0Aca2CP04dumpb8ForSwiftB4File2at10Foundation4DataVAG3URLV_tKFTW + 12
    7   dependency-graph                    0x00000001028622d4 $s26PackageSwiftFileParserLiveAAC09justParseC033_A17BD4055C4467321940459E7754879DLL2at0abC0AFV10Foundation3URLV_tKF + 172
    8   dependency-graph                    0x0000000102862630 $s26PackageSwiftFileParserLiveAAC0abcD0Aca2CP05parseC02at0abC0AGV10Foundation3URLV_tKFTW + 164
    9   dependency-graph                    0x0000000102861640 $s26PackageSwiftFileParserLive0abC6MapperV3mapy0abC0AEVAA012IntermediateabC0VKF + 1892
    10  dependency-graph                    0x00000001028623bc $s26PackageSwiftFileParserLiveAAC09justParseC033_A17BD4055C4467321940459E7754879DLL2at0abC0AFV10Foundation3URLV_tKF + 404
    11  dependency-graph                    0x0000000102862630 $s26PackageSwiftFileParserLiveAAC0abcD0Aca2CP05parseC02at0abC0AGV10Foundation3URLV_tKFTW + 164
    12  dependency-graph                    0x0000000102941634 $s28XcodeProjectGraphBuilderLive015AllDependenciescD0V05buildC04from08DirectedC0AFC0aB0AHV_tKF + 864
    13  dependency-graph                    0x00000001029427d0 $s28XcodeProjectGraphBuilderLiveAAC05buildC04from08DirectedC0AEC0aB0AGV_tKF + 192
    14  dependency-graph                    0x00000001029428e4 $s28XcodeProjectGraphBuilderLiveAAC0abcD0Aca2CP05buildC04from08DirectedC0AGC0aB0AIV_tKFTW + 20
    15  dependency-graph                    0x0000000102850f18 $s12GraphCommandAAV3run9withInput6syntaxySS_AA6SyntaxOtKF + 1216
    16  dependency-graph                    0x00000001028527c4 $s4Main15DependencyGraphV3runyyKF + 320
    17  dependency-graph                    0x0000000102852b14 $s4Main15DependencyGraphV14ArgumentParser15ParsableCommandAadEP3runyyKFTW + 64
    18  dependency-graph                    0x0000000102852d6c Main_main + 96
    19  dyld                                0x000000018d84d0e0 start + 2360
)
libc++abi: terminating due to uncaught exception of type NSException
zsh: abort      dependency-graph XXX.xcodeproj/
cbot commented 6 months ago

Looks like I've got the same problem here.

dependency-graph --packages-only --node-spacing 0.75 --rank-spacing 4 .                                                                                   [develop]
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'working directory doesn't exist.'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000194e8accc __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x0000000194972788 objc_exception_throw + 60
    2   Foundation                          0x0000000195fb4a80 -[NSConcreteTask launchWithDictionary:error:] + 4284
    3   dependency-graph                    0x0000000100b8c4f0 $s22ShellCommandRunnerLiveAAV3run13withArguments16fromDirectoryURL0abC00aB6OutputVSaySSG_10Foundation0J0VtFTf4nnd_n + 448
    4   dependency-graph                    0x0000000100b6fe88 $s22DumpPackageServiceLiveAAV04dumpB033_33DF866953EC50C8C73DEAC71694AABCLL2at10Foundation4DataVAF3URLV_tKF + 156
    5   dependency-graph                    0x0000000100b6fd24 $s22DumpPackageServiceLiveAAV04dumpb8ForSwiftB4File2at10Foundation4DataVAE3URLV_tKF + 260
    6   dependency-graph                    0x0000000100b6ffa0 $s22DumpPackageServiceLiveAAV0abC0Aca2CP04dumpb8ForSwiftB4File2at10Foundation4DataVAG3URLV_tKFTW + 12
    7   dependency-graph                    0x0000000100b822d4 $s26PackageSwiftFileParserLiveAAC09justParseC033_A17BD4055C4467321940459E7754879DLL2at0abC0AFV10Foundation3URLV_tKF + 172
    8   dependency-graph                    0x0000000100b82630 $s26PackageSwiftFileParserLiveAAC0abcD0Aca2CP05parseC02at0abC0AGV10Foundation3URLV_tKFTW + 164
    9   dependency-graph                    0x0000000100b81640 $s26PackageSwiftFileParserLive0abC6MapperV3mapy0abC0AEVAA012IntermediateabC0VKF + 1892
    10  dependency-graph                    0x0000000100b823bc $s26PackageSwiftFileParserLiveAAC09justParseC033_A17BD4055C4467321940459E7754879DLL2at0abC0AFV10Foundation3URLV_tKF + 404
    11  dependency-graph                    0x0000000100b82630 $s26PackageSwiftFileParserLiveAAC0abcD0Aca2CP05parseC02at0abC0AGV10Foundation3URLV_tKFTW + 164
    12  dependency-graph                    0x0000000100c6202c $s28XcodeProjectGraphBuilderLive012PackagesOnlycD0V05buildC04from08DirectedC0AFC0aB0AHV_tKFTf4xn_n + 796
    13  dependency-graph                    0x0000000100c62780 $s28XcodeProjectGraphBuilderLiveAAC05buildC04from08DirectedC0AEC0aB0AGV_tKF + 112
    14  dependency-graph                    0x0000000100c628e4 $s28XcodeProjectGraphBuilderLiveAAC0abcD0Aca2CP05buildC04from08DirectedC0AGC0aB0AIV_tKFTW + 20
    15  dependency-graph                    0x0000000100b70f18 $s12GraphCommandAAV3run9withInput6syntaxySS_AA6SyntaxOtKF + 1216
    16  dependency-graph                    0x0000000100b727c4 $s4Main15DependencyGraphV3runyyKF + 320
    17  dependency-graph                    0x0000000100b72b14 $s4Main15DependencyGraphV14ArgumentParser15ParsableCommandAadEP3runyyKFTW + 64
    18  dependency-graph                    0x0000000100b72d6c Main_main + 96
    19  dyld                                0x00000001949ae0e0 start + 2360
)
libc++abi: terminating due to uncaught exception of type NSException
cameroncooke commented 4 months ago

I'm having this problem too, but in my case, it seems to be related to some of the local dependencies in my Package.swift that use relative paths. On debugging dependency-graph I can see that crash happens because the computed file path directoryURL points to a non-existent path.

Given my /Users/cameron/packages/somepackage/Package.swift:

// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
    name: "SomePackage",
    dependencies: [
        .package(path: "../another_package"),
    ],
...

The other package dependency is located at: /Users/cameron/packages/another_package/Package.swift yet the computed directoryURL is file:///Users/cameron/another_package/ when it should, in fact, be file:///Users/cameron/packages/another_package/

cameroncooke commented 4 months ago

On further investigation, this seems it might be because we have dependencies of dependencies that share the same dependency but resolve it at different relative paths.

Live:

../SharedDep < Package A
../../SharedDep < Some-subdirectory/Package B

In both these examples SharedDep is in the same absolute path.

cameroncooke commented 4 months ago

Ok so looks like "user error" 😳 - Turns out the other package had the wrong relative path, for some reason this didn't cause errors in Xcode because the module was already resolved by an earlier package sharing the same dependency.

Fixed the package issues and now it's working 😄