point-source / dart_ping

Multi-platform network ping utility for Dart
30 stars 13 forks source link

ProcessException: No such file or directory #50

Closed RedFox64 closed 11 months ago

RedFox64 commented 1 year ago

sdk: 3.0.0 dart_ping: ^8.0.1

Unhandled exception: ProcessException: No such file or directory Command: ping -O -n -W 2 -i 1 -t 255 -c 5 google.com

0 _ProcessImpl._start (dart:io-patch/process_patch.dart:401:33)

1 Process.start (dart:io-patch/process_patch.dart:38:20)

2 BasePing.platformProcess (package:dart_ping/src/ping/base_ping.dart:71:62)

3 BasePing._onListen (package:dart_ping/src/ping/base_ping.dart:86:22)

4 _runGuarded (dart:async/stream_controller.dart:815:24)

5 _StreamController._subscribe. (dart:async/stream_controller.dart:694:7)

6 _BufferingStreamSubscription._guardCallback (dart:async/stream_impl.dart:415:13)

7 _StreamController._subscribe (dart:async/stream_controller.dart:693:18)

8 _ControllerStream._createSubscription (dart:async/stream_controller.dart:828:19)

9 _StreamImpl.listen (dart:async/stream_impl.dart:471:9)

10 main (file:///app/bin/script.dart:16:15)

11 _delayEntrypointInvocation. (dart:isolate-patch/isolate_patch.dart:294:33)

12 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)

point-source commented 1 year ago

What OS?

tomassasovsky commented 11 months ago

Getting the same error on Debian inside a Docker container

point-source commented 11 months ago

Ah yep, that makes sense. I need to add a check to ensure the ping binary is installed. Try installing the ping binary via iputils or similar package.

tomassasovsky commented 11 months ago

Any idea how I could do that? I'm guessing in the Dockerfile? amazing response time, btw!

point-source commented 11 months ago

Sure do. Common issue: https://stackoverflow.com/questions/39901311/docker-ubuntu-bash-ping-command-not-found

Thanks!

tomassasovsky commented 11 months ago

Issue persists :( Here's my output:

root@pve-controller ~/proxmox_controller.dart/build# docker run --env-file .env 78b627e49b7e
[dotenv] Load failed: file not found: File: '.env'
Starting server on InternetAddress('::', IPv6):8080
Using proxmox username: root
Unhandled exception:
ProcessException: No such file or directory
  Command: ping -O -n -W 1 -i 1 -t 255 -c 1 172.17.0.1
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:401)
#1      Process.start (dart:io-patch/process_patch.dart:38)
#2      BasePing.platformProcess (package:dart_ping/src/ping/base_ping.dart:71)
#3      BasePing._onListen (package:dart_ping/src/ping/base_ping.dart:86)
#4      _runGuarded (dart:async/stream_controller.dart:815)
#5      _StreamController._subscribe.<anonymous closure> (dart:async/stream_controller.dart:694)
#6      _BufferingStreamSubscription._guardCallback (dart:async/stream_impl.dart:415)
#7      _StreamController._subscribe (dart:async/stream_controller.dart:693)
#8      _ControllerStream._createSubscription (dart:async/stream_controller.dart:828)
#9      _StreamImpl.listen (dart:async/stream_impl.dart:471)
#10     _StreamIterator._initializeOrDone (dart:async/stream_impl.dart:942)
#11     _StreamIterator.moveNext (dart:async/stream_impl.dart:918)
#12     HostScanner._getHostFromPing (package:network_tools/src/host_scanner.dart)
#13     HostScanner.getAllPingableDevices (package:network_tools/src/host_scanner.dart:41)
<asynchronous suspension>
#14     connectToProxmox (file:///app/main.dart:42)
<asynchronous suspension>
#15     run (file:///app/main.dart:20)
<asynchronous suspension>
#16     createServer (file:///app/bin/server.dart:22)
<asynchronous suspension>

And my Dockerfile:

# Official Dart image: https://hub.docker.com/_/dart
# Specify the Dart SDK base image version using dart:<version> (ex: dart:2.17)
FROM dart:stable AS build

WORKDIR /app

RUN apt-get update -y
RUN apt-get install -y iputils-ping

# Copy Dependencies

# Install Dependencies

# Resolve app dependencies.
COPY pubspec.* ./
RUN dart pub get

# Copy app source code and AOT compile it.
COPY . .
# Ensure packages are still up-to-date if anything has changed
RUN dart pub get --offline
RUN dart compile exe bin/server.dart -o bin/server

# Build minimal serving image from AOT-compiled `/server` and required system
# libraries and configuration files stored in `/runtime/` from the build stage.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/bin/server /app/bin/
COPY --from=build /app/.env /app/

# Start server.
CMD ["/app/bin/server"]
point-source commented 11 months ago

Open an interactive shell in your container and just try to use the ping binary. You can also issue which ping to see where it installed to, assuming it's in your path variable.

Overall, this is something to troubleshoot outside of dart/dart_ping since the issue is that you need the docker image to end up having ping installed and available in the path prior to running any dart code.

Dumb question but just making sure, you did rebuild the container and image after modifying the dockerfile, right?

tomassasovsky commented 11 months ago

Yep, did rebuild it. It's definitely coming from that:

root@pve-controller ~/proxmox_controller.dart/build# docker exec -it 8cff34d5dce86a4723667d9508073c22c2965983e46806eb624636ec4c1dd52a which ping OCI runtime exec failed: exec failed: unable to start container process: exec: "which": executable file not found in $PATH: unknown root@pve-controller ~/proxmox_controller.dart/build# docker exec -it 8cff34d5dce86a4723667d9508073c22c2965983e46806eb624636ec4c1dd52a where ping OCI runtime exec failed: exec failed: unable to start container process: exec: "where": executable file not found in $PATH: unknown root@pve-controller ~/proxmox_controller.dart/build# docker exec -it 8cff34d5dce86a4723667d9508073c22c2965983e46806eb624636ec4c1dd52a ping OCI runtime exec failed: exec failed: unable to start container process: exec: "ping": executable file not found in $PATH: unknown

tomassasovsky commented 11 months ago

This still happens even outside Docker. Here's my shell output:

root@pvehackintosh:~/proxmox_controller# dart build/bin/server.dart 
Starting server on InternetAddress('::', IPv6):8080
Using proxmox username: root
Unhandled exception:
ProcessException: 
  Command: ping -O -n -W 1 -i 1 -t 255 -c 1 192.168.0.203
#0      _ProcessImpl._start (dart:io-patch/process_patch.dart:401:33)
#1      Process.start (dart:io-patch/process_patch.dart:38:20)
#2      BasePing.platformProcess (package:dart_ping/src/ping/base_ping.dart:71:62)
#3      BasePing._onListen (package:dart_ping/src/ping/base_ping.dart:86:22)
#4      _runGuarded (dart:async/stream_controller.dart:815:24)
#5      _StreamController._subscribe.<anonymous closure> (dart:async/stream_controller.dart:694:7)
#6      _BufferingStreamSubscription._guardCallback (dart:async/stream_impl.dart:415:13)
#7      _StreamController._subscribe (dart:async/stream_controller.dart:693:18)
#8      _ControllerStream._createSubscription (dart:async/stream_controller.dart:828:19)
#9      _StreamImpl.listen (dart:async/stream_impl.dart:471:9)
#10     _StreamIterator._initializeOrDone (dart:async/stream_impl.dart:942:33)
#11     _StreamIterator.moveNext (dart:async/stream_impl.dart:918:12)
#12     HostScanner._getHostFromPing (package:network_tools/src/host_scanner.dart)
#13     HostScanner.getAllPingableDevices (package:network_tools/src/host_scanner.dart:41:9)
<asynchronous suspension>
#14     connectToProxmox (file:///root/proxmox_controller/build/main.dart:42:3)
<asynchronous suspension>
#15     run (file:///root/proxmox_controller/build/main.dart:20:29)
<asynchronous suspension>
#16     createServer (file:///root/proxmox_controller/build/bin/server.dart:22:18)
<asynchronous suspension>
^C
root@pvehackintosh:~/proxmox_controller# ping
ping: usage error: Destination address required
root@pvehackintosh:~/proxmox_controller# ^C
root@pvehackintosh:~/proxmox_controller# ping -O -n -W 1 -i 1 -t 255 -c 1 192.168.0.203
PING 192.168.0.203 (192.168.0.203) 56(84) bytes of data.

--- 192.168.0.203 ping statistics ---
1 packets transmitted, 0 received, 100% packet loss, time 0ms
point-source commented 11 months ago

That's a different error, possibly related to permissions. Notice it's missing the message about a missing file and instead just says "Process exception".

You can copy/ paste the command it outputs into your proxmox shell and try it: ping -O -n -W 1 -i 1 -t 255 -c 1 192.168.0.203.

Oftentimes, hardened systems don't allow ping without admin/root privilege.

tomassasovsky commented 11 months ago

I did, it fails the ping but runs OK. Keep in mind I'm running the dart command as root as well.

point-source commented 11 months ago

So I ran these commands on my local machine (macOS) to validate that the dart_ping library works on a dart:stable container image:

These commands produced this output within the container:

Running command: ping -O -n -W 2 -i 1 -t 255 -c 5 google.com
PingResponse(seq:1, ip:142.250.72.142, ttl:62, time:349.0 ms)
PingResponse(seq:2, ip:142.250.72.142, ttl:62, time:28.4 ms)
PingResponse(seq:3, ip:142.250.72.142, ttl:62, time:56.3 ms)
PingResponse(seq:4, ip:142.250.72.142, ttl:62, time:32.1 ms)
PingResponse(seq:5, ip:142.250.72.142, ttl:62, time:33.6 ms)
PingSummary(transmitted:5, received:5), time: 4016 ms

This leads me to believe that the library and your dockerfile should be working fine. I recommend trying to reproduce this on your proxmox server's docker instance in case this is specific to something in the way docker is running on proxmox or the way you are using dart_ping in your binary.

tomassasovsky commented 11 months ago

I ended up fixing my Proxmox server to a static DHCP in my router settings - Makes my whole setup way easier to config and way faster for my server to connect to the SSH server. Thanks for the help though!

point-source commented 11 months ago

No problem! Safe to close then?

tomassasovsky commented 11 months ago

Yep, good on my end :)