Hexaville icon indicating copy to clipboard operation
Hexaville copied to clipboard

`Proc.init()` throws NSInvalidArgumentException

Open mitsuyoshi-yamazaki opened this issue 7 years ago • 1 comments

Agenda

When exetutablePath is not valid (say "No such file or directory"), Proc.init(exetutablePath: arguments: environment:) throws NSInvalidArgumentException and crashes.

process.launch() inside of Proc.init(exetutablePath: arguments: environment:) throws it.

How to reproduce

Call Proc.init(exetutablePath: arguments: environment:) with invalid exetutablePath.

In my case, Docker was not installed on the local environment and accessing /usr/local/bin/docker causes crash.

Error log

Generating Routing Manifest file....
2017-05-27 12:03:54.258 Hexaville[33233:3548978] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'launch path not accessible'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff886472cb __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x00007fff9d45248d objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff886c5c3d +[NSException raise:format:] + 205
	3   Foundation                          0x00007fff8a06faae -[NSConcreteTask launchWithDictionary:] + 414
	4   Hexaville                           0x0000000108919108 _TFV9Hexaville4ProcCfTSSGSaSS_11environmentGVs10DictionarySSSS__S0_ + 648
	5   Hexaville                           0x000000010893ccaa _TFC9Hexaville8LauncherP33_AE9A0DFC07420EBD599599C2A94E31DD10buildSwiftfzT_VS_11BuildResult + 1674
	6   Hexaville                           0x000000010893e1b6 _TFC9Hexaville8LauncherP33_AE9A0DFC07420EBD599599C2A94E31DD9launchForfzT3awsVS_19AWSLauncherProvider_T_ + 3766
	7   Hexaville                           0x000000010893bcb7 _TFC9Hexaville8Launcher6launchfzT5debugSb18shouldDiscardCacheSb_T_ + 13863
	8   Hexaville                           0x0000000108916c6d _TFC9Hexaville6Deploy7executefzT_T_ + 12797
	9   Hexaville                           0x0000000108917ff4 _TTWC9Hexaville6Deploy8SwiftCLI7CommandS_FS2_7executefzT_T_ + 52
	10  Hexaville                           0x0000000110670522 _TZFC8SwiftCLI3CLIP33_DB3E12785B4EFBF4897480866430FB322gofT4withCS_12ArgumentList_Vs5Int32 + 1106
	11  Hexaville                           0x00000001106700c9 _TZFC8SwiftCLI3CLI2gofT_Vs5Int32 + 41
	12  Hexaville                           0x00000001089097ad main + 461
	13  libdyld.dylib                       0x00007fff9dd37235 start + 1
	14  ???                                 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException
[1]    33233 abort      ~/Documents/projects/Hexaville/.build/debug/Hexaville deploy Hellp

Recovery suggestion

Process.launch() does NOT throw Swift exceptions but Obj-C exceptions, those we can't handle in Swift codes. There's a way to convert Obj-c exceptions to Swift exceptions like this but it needs Obj-C implementation, I don't know it's possible to build Obj-C code with $ swift build

mitsuyoshi-yamazaki avatar May 27 '17 04:05 mitsuyoshi-yamazaki

Thanks for your reporting!

I'll consider some solutions for avoiding Obj-C exceptions without using Objective-C code. Because this is a specific Issue on MacOS and If we consider portability with other platforms(such as Linux) the Objective-C code should not be there.

noppoMan avatar May 28 '17 13:05 noppoMan