dartserverdart-shelfdart-api

`dart run` fails logging `Compilation did not produce any result...` and crashes with `PathNotFoundException`


I'm getting the following while trying to run my API built with Dart on the Ubuntu server:

root@veyilserver:~/veyilapi# dart run

Building package executable... (17.7s)
Compilation did not produce any result. Expected file at /root/veyilapi/.dart_tool/pub/bin/veyilapi/tmpCNPJMW/veyilapi.dart-3.3.4.snapshot.incremental.temp
Built veyilapi:veyilapi.
Cannot rename file to '/root/veyilapi/.dart_tool/pub/bin/veyilapi/veyilapi.dart-3.3.4.snapshot', path = '/root/veyilapi/.dart_tool/pub/bin/veyilapi/tmpCNPJMW/veyilapi.dart-3.3.4.snapshot.incremental.temp' (OS Error: No such file or directory, errno = 2)
PathNotFoundException: Cannot rename file to '/root/veyilapi/.dart_tool/pub/bin/veyilapi/veyilapi.dart-3.3.4.snapshot', path = '/root/veyilapi/.dart_tool/pub/bin/veyilapi/tmpCNPJMW/veyilapi.dart-3.3.4.snapshot.incremental.temp' (OS Error: No such file or directory, errno = 2)

Everything was functioning perfectly until I restarted the server yesterday. Now, it's completely broken. I tried uninstalling and reinstalling Dart SDK, also tried using a earlier versions (3.3.0 and 3.0.0) , couldn't get over this one.

Can somebody help with a workaround please?

I'm sorry but I'm kind of not sure if this is an issue with the language or Dart VM.

Here's more info about the server and Dart versions I'm using:

Dart version and tooling diagnostic info (dart info)

General info

Process info

No Dart processes found.

Operating System

Ubuntu 23.10 x64

Pubspec.yaml

name: veyilapi
description: A simple server setup
version: 1.0.0

environment:
  sdk: ">=3.0.0"

dependencies:
  args: ^2.5.0
  shelf: ^1.4.1
  shelf_router: ^1.1.4
  http: ^1.2.1

dev_dependencies:
  lints: ^3.0.0
  test: ^1.25.4

Also, when I tried to run dart compile the following error occurred:

root@veyilserver:~/veyilapi# dart compile exe bin/veyilapi.dart 
Error: AOT compilation failed
Generating AOT kernel dill failed!

What have I already done?

  1. Made sure all dependencies are upto date.
  2. Checked .dart_tools and found its empty.
  3. Deleted .dart_tools and ran dart pub get.
  4. Searched around the Internet and found an issue containing similar text dart-lang/sdk#55453 which led me to this particular line in the dart-lang/pub repository that logs the particular error line.
  5. Filed a new issue dart-lang/sdk#55639
  6. Uninstalled Dart SDK from the server and reinstalled.
  7. Downgraded Dart SDK to older versions and checked if it works.
  8. (May 5, 06:43) Tried running dart pub cache clean -> dart pub get -> dart run

Solution

  • After discussing in the Dart Community, finally I was able to get over this issue.

    For no good reason, dart compile with --verbose flag did work and generated the compiled .exe file and I was able to start the server without a problem.

    Note: The issue persists when I try to run dart compile or dart run alone.