Skip to content

Fix compiler deprecation warnings for Crystal 1.20+#1379

Merged
crimson-knight merged 1 commit into
amberframework:masterfrom
renich:fix-deprecation-warnings
Jun 11, 2026
Merged

Fix compiler deprecation warnings for Crystal 1.20+#1379
crimson-knight merged 1 commit into
amberframework:masterfrom
renich:fix-deprecation-warnings

Conversation

@renich

@renich renich commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Description of the Change

When compiling the Amber framework under modern Crystal versions (e.g. 1.20+), several deprecation warnings are emitted. This Pull Request updates the deprecated methods to their modern equivalents:

  • Updated Process::Status#exit_status to Process::Status#exit_code in src/amber/cli/commands/exec.cr.
  • Replaced Time.monotonic with Time.instant in src/amber/cli/helpers/process_runner.cr.
  • Replaced sleep 1 with the modern sleep 1.second span-based signature in src/amber/cli/helpers/process_runner.cr.
  • Replaced the deprecated double-brace macro splat syntax {{*args}} with {{args.splat}} in src/amber/dsl/router.cr.

Alternate Designs

None. These changes follow standard deprecation warnings emitted during compilation.

Benefits

  • Clean compilation of the amber CLI binary under modern Crystal versions with 0 deprecation warnings.

Possible Drawbacks

None.


Note: This PR was co-developed with the assistance of Gemini AI. The user (Rénich Bon Ćirić) has directed, reviewed, tested, and takes full responsibility for the code.

Issue: None

# Why is this change necessary?
* Modern Crystal versions generate several deprecation warnings for outdated methods (Process::Status#exit_status, Time.monotonic, splat macro syntax, ::sleep).

# How does it address the issue
* Updated `exit_status` to `exit_code` in `src/amber/cli/commands/exec.cr`.
* Replaced `Time.monotonic` with `Time.instant` in `src/amber/cli/helpers/process_runner.cr`.
* Replaced `sleep 1` with `sleep 1.second` in `src/amber/cli/helpers/process_runner.cr`.
* Replaced double-brace macro splat syntax `{{*args}}` with `{{args.splat}}` in `src/amber/dsl/router.cr`.

# What side effects does this change have?
* None. Fixes compilation deprecation warnings when building the amber CLI binary.

Co-developed-by: Gemini AI <renich+gemini@woralelandia.com>
Signed-off-by: Rénich Bon Ćirić <renich@woralelandia.com>
crimson-knight added a commit to amberframework/amber_cli that referenced this pull request Jun 10, 2026
…22)

* Harden editor invocation against shell injection; fix Crystal 1.20 deprecations

exec.cr and encrypt.cr previously called system("#{editor} #{filename}"),
allowing shell metacharacters in the EDITOR env var or filename to execute
arbitrary commands. Replace with Process.parse_arguments + Process.run so
the editor string is word-split (supporting "code -w", "vim -u none", etc.)
and the filename is passed as a literal argument with no shell involvement.
Add regression specs asserting shell metacharacters in editor/filename do
not execute.

Fix pattern contributed by @tcoatswo in amberframework/amber#1376.

process_runner.cr used Time.monotonic which is deprecated in Crystal 1.20.0
in favour of Time.instant (Time::Instant, introduced in 1.20.0). Replace
both call sites. The shard.yml crystal floor is raised to >= 1.20.0 to
match (see version bump commit).

Fix contributed by @renich in amberframework/amber#1379.

amber.js Channel.join/leave/push previously called this.socket.ws.send()
without error handling; a dead WebSocket throws an uncaught DOMException in
the browser. Wrap each send in try/catch with a fallback to _reconnect().

Fix pattern contributed by @jonsilverman50-star in amberframework/amber#1375.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Bump version to 2.0.1; raise Crystal floor to >= 1.20.0

Time.instant (used in process_runner.cr) was introduced in Crystal 1.20.0.
Raise the shard.yml crystal constraint from >= 1.10.0 to >= 1.20.0 to
reflect this requirement. Bump shard version 2.0.0 -> 2.0.1 to signal the
patch release containing the exec/encrypt hardening and deprecation fixes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@crimson-knight

Copy link
Copy Markdown
Member

Thanks for tracking down these deprecation warnings. Cleaning up exit_statusexit_code, Time.monotonicTime.instant, sleep 1sleep 1.second, and the double-brace macro splat is exactly the maintenance that keeps v1.x compilable as Crystal moves forward.

Merging this into v1. For context on where these land in V2: the CLI was removed from the framework core entirely (exec.cr and process_runner.cr now live in the standalone amber_cli), and the router macro was rewritten with explicit named parameters, so the splat fix is superseded by design there. Your Time.monotonic fix was also needed in amber_cli — it shipped in amber_cli#22 (released in v2.0.1) with credit to this PR.

V2 is now public if you want to see where things are heading: #1383. We'd welcome the help.

@crimson-knight crimson-knight merged commit 3b675ff into amberframework:master Jun 11, 2026
@renich renich deleted the fix-deprecation-warnings branch June 12, 2026 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants