resolve ptyc path relative to daemon binary
The daemon now checks for ptyc at ../ptyc/bin/ptyc relative to its own binary location before falling back to PATH lookup. Fixes "ProcessException: No such file or directory. Command: ptyc" when ptyc is built but not on PATH. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+16
-1
@@ -142,9 +142,10 @@ Future<void> _runDaemon(List<String> args) async {
|
|||||||
socketPath: socketPath,
|
socketPath: socketPath,
|
||||||
dispatch: dispatcher.dispatch,
|
dispatch: dispatcher.dispatch,
|
||||||
);
|
);
|
||||||
|
final ptycPath = _resolvePtycPath();
|
||||||
final events = _ServerEventSink(server);
|
final events = _ServerEventSink(server);
|
||||||
final registry = PaneRegistry(events: events);
|
final registry = PaneRegistry(events: events);
|
||||||
registerPaneCommands(dispatcher, registry);
|
registerPaneCommands(dispatcher, registry, defaultPtycPath: ptycPath);
|
||||||
|
|
||||||
final files = FilesService.atCwd(events: events);
|
final files = FilesService.atCwd(events: events);
|
||||||
registerFilesCommands(dispatcher, files);
|
registerFilesCommands(dispatcher, files);
|
||||||
@@ -423,6 +424,20 @@ void _emitError({
|
|||||||
stderr.writeln(jsonEncode(err.toJson()));
|
stderr.writeln(jsonEncode(err.toJson()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _resolvePtycPath() {
|
||||||
|
final self = Platform.resolvedExecutable;
|
||||||
|
final binDir = File(self).parent.path;
|
||||||
|
final candidates = [
|
||||||
|
'$binDir/../ptyc/bin/ptyc',
|
||||||
|
'$binDir/ptyc',
|
||||||
|
'ptyc',
|
||||||
|
];
|
||||||
|
for (final c in candidates) {
|
||||||
|
if (File(c).existsSync()) return c;
|
||||||
|
}
|
||||||
|
return 'ptyc';
|
||||||
|
}
|
||||||
|
|
||||||
Never _die(String msg) {
|
Never _die(String msg) {
|
||||||
_emitError(
|
_emitError(
|
||||||
code: IpcExitCode.userError,
|
code: IpcExitCode.userError,
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import '../panes/pane.dart';
|
|||||||
import '../panes/registry.dart';
|
import '../panes/registry.dart';
|
||||||
import 'dispatcher.dart';
|
import 'dispatcher.dart';
|
||||||
|
|
||||||
void registerPaneCommands(DaemonDispatcher d, PaneRegistry registry) {
|
void registerPaneCommands(DaemonDispatcher d, PaneRegistry registry, {String defaultPtycPath = 'ptyc'}) {
|
||||||
d.register('pane.spawn', (req) => _spawn(req, registry));
|
d.register('pane.spawn', (req) => _spawn(req, registry, defaultPtycPath));
|
||||||
d.register('pane.list', (req) => _list(req, registry));
|
d.register('pane.list', (req) => _list(req, registry));
|
||||||
d.register('pane.close', (req) => _close(req, registry));
|
d.register('pane.close', (req) => _close(req, registry));
|
||||||
d.register('pane.write', (req) => _write(req, registry));
|
d.register('pane.write', (req) => _write(req, registry));
|
||||||
@@ -47,7 +47,7 @@ IpcResponse _notFound(String id, String message) => IpcResponse.err(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Future<IpcResponse> _spawn(IpcRequest req, PaneRegistry registry) async {
|
Future<IpcResponse> _spawn(IpcRequest req, PaneRegistry registry, String defaultPtycPath) async {
|
||||||
final args = req.args;
|
final args = req.args;
|
||||||
final rawArgv = args['argv'];
|
final rawArgv = args['argv'];
|
||||||
if (rawArgv is! List || rawArgv.isEmpty) {
|
if (rawArgv is! List || rawArgv.isEmpty) {
|
||||||
@@ -84,7 +84,7 @@ Future<IpcResponse> _spawn(IpcRequest req, PaneRegistry registry) async {
|
|||||||
cols: (args['cols'] as num?)?.toInt() ?? 80,
|
cols: (args['cols'] as num?)?.toInt() ?? 80,
|
||||||
rows: (args['rows'] as num?)?.toInt() ?? 24,
|
rows: (args['rows'] as num?)?.toInt() ?? 24,
|
||||||
title: args['title'] as String?,
|
title: args['title'] as String?,
|
||||||
ptycPath: (args['ptyc_path'] as String?) ?? 'ptyc',
|
ptycPath: (args['ptyc_path'] as String?) ?? defaultPtycPath,
|
||||||
);
|
);
|
||||||
return IpcResponse.ok(id: req.id, data: pane.toJson());
|
return IpcResponse.ok(id: req.id, data: pane.toJson());
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user