Skip to content

Troubleshooting

This page lists known problems, with the text you see, the cause and the fix.

The native HTTP library did not load

Symptom: The app stops at start with this error:

Unsupported operation: dox_http_native did not load: <reason>.
Fix: install Rust (cargo, see https://rustup.rs), then run the app again ...

At build time (dart pub get, dox serve or dox build) you may also see one of these:

dox_http_native: no native library for <os>-<arch>. Install Rust (cargo) to build it from source.
dox_http_native: download dox_http_native-<os>-<arch>.<ext>: 404
dox_http_native: download dox_http_native-<os>-<arch>.<ext> failed: <error>
dox_http_native: sha256 of dox_http_native-<os>-<arch>.<ext> does not match
dox_http_native: cargo build failed

Cause: The package could not find, download or build its native library. Common reasons:

  • There was no internet during dart pub get, or there is no ready build for your OS and CPU. Ready builds exist for macOS arm64 and x64, Linux x64 and arm64, and Windows x64.
  • Rust is not installed, so the library can not be built from source.
  • You compiled with dart compile exe. It does not run build hooks, so the binary has no native library.
  • The reason is native library ABI <x>, expected <y>: the library on disk is from another version of the package.

Fix: Pick one:

  1. Install Rust with rustup and run dart pub get again. Dox then builds the library with cargo.
  2. If the reason is an ABI mismatch and you set lib_path, rebuild that library: run cargo build --release in the native folder of the dox-http-native repo.
  3. Download the library yourself from the GitHub releases, and point to it in the root pubspec.yaml:

    hooks:
      user_defines:
        dox_http_native:
          lib_path: /path/to/libdox_http_native.so
    
  4. Build with dox build, not with dart compile exe.

The native database drivers load their library the same way. When it does not load, the app stops with:

dox_postgres_native did not load: <reason>.
dox_mysql_native did not load: <reason>.

The fix is the same as above, with the dox-postgres-native or dox-mysql-native repo.

See Native server, Postgres native and MySQL native.

Port already in use

Symptom: At start:

SocketException: dox_http_native: bind failed (<code>) (OS Error: errno = <errno>), port = 3000

The errno is 48 on macOS and 98 on Linux.

Cause: Another process listens on the port, like an old bin/server.dart or a second copy of the app.

Fix: Find and stop the process, or use another port:

lsof -i :3000          # macOS and Linux: who has the port
kill <pid>

Or set APP_PORT=3001 in .env.

build_runner: conflicting outputs

Symptom: dox build_runner:build, dox serve or dox build stops with a build_runner message that starts with Conflicting outputs were detected, and names files like lib/generated/dtos.g.dart or lib/app/models/user/user.model.g.dart.

Cause: The generated .g.dart files are on disk, but .dart_tool/build does not know them. This happens after a git clone with committed .g.dart files, after deleting .dart_tool, or after a Dart SDK update.

Fix: Delete the build cache and build again:

rm -rf .dart_tool/build
dart run build_runner build

If that is not enough, delete the .g.dart files that the message names, and build again.

Ambiguous import: Uuid, Name or Schema

Symptom: The analyzer or the build says a name like Uuid, Name, Range, Image or Schema is an "ambiguous import".

Cause: dox_core exports the validation rules (Uuid, Name, Range, Image, ...) and the Schema class. Another import has a class with the same name, like package:uuid. dox_orm also has a Schema class.

Fix: Hide the name you do not use in that file:

import 'package:dox_core/dox_core.dart' hide Uuid;
import 'package:dox_orm/dox_orm.dart' hide Schema;

A .env value with #

A # after a space starts a comment. The comment is not part of the value.

APP_PORT=3000 # dev port   -> 3000
DB_PASSWORD=abc#123        -> abc#123 (no space before the #)
DB_PASSWORD="abc # 123"    -> abc # 123 (quotes keep the #)

When a value must have # in it (a space, then #), put the value in quotes. The quotes are removed.

Hash.make throws on a long password

Symptom: Saving a user, or registering, gives a 500. The log shows:

Invalid argument(s) (password): The password is too long. bcrypt takes at most 72 bytes.

Cause: Hash.make() and Hash.makeAsync() use bcrypt, which takes at most 72 bytes. So Dox throws an ArgumentError for a longer password.

Fix: Refuse long passwords in your DTO, before you hash them:

@MaxLength(72)
final String password;

@MaxLength counts characters, not bytes, so a password with non-ASCII characters can still be over 72 bytes. See Hashing.

MySQL 8 login fails

Symptom: The connection to MySQL 8 is refused at login, while the same user works from the mysql client. Often the user was made with the default caching_sha2_password plugin.

Cause: caching_sha2_password needs either TLS or the server RSA public key to send the password. A client that has neither can not log in.

Fix: The Dox MySQL driver supports this plugin. Check these settings of the connection in lib/config/database.dart:

Setting What to do
Remote host without TLS Turn on useSSL: true.
useSSL: true The server must have TLS on.
host, port, user, password A wrong value gives the same login error. DB_PORT is 3306 by default for MySQL.

As a last resort, change the user on the server:

ALTER USER 'app'@'%' IDENTIFIED WITH mysql_native_password BY 'secret';

SQLite: the database file

Symptom: An SqliteException with unable to open database file, or an empty database after dox build.

Cause: A relative path starts from the folder where you start the app. After dox build you run the app from build/bundle, where the database is a new empty file. Also, SQLite makes a missing file, but not a missing folder.

Fix:

  • Use an absolute path, or make the folder first.
  • Set it with DB_NAME, like DB_NAME=/var/lib/my_app/dox.sqlite.
  • Migrations read DB_DATABASE or DB_NAME as the path too, so use the same value.
  • Do not use :memory: with more than one isolate. Each isolate gets its own empty database.

dox: command not found after dart pub global activate

Symptom:

zsh: command not found: dox

right after dart pub global activate dox.

Cause: The dox script is in $HOME/.pub-cache/bin, and that folder is not in your path.

Fix: Add it to your shell profile and open a new terminal:

export PATH="$PATH":"$HOME/.pub-cache/bin"

On Windows the folder is %LOCALAPPDATA%\Pub\Cache\bin.

Next steps