Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
  • 한국어
GitHub

Nushell 0.114.1

Today, we're releasing version 0.114.1 of Nu. This patch release fixes issues found after enforce-runtime-annotations became opt-out in the last version, improving runtime type checks and error reporting.

Where to get it

Nu 0.114.1 is available as pre-built binaries or from crates.io. If you have Rust installed you can install it using cargo install nu.

As part of this release, we also publish a set of optional plugins you can install and use with Nushell.

Table of contents

Highlights and themes of this release [toc]

Follow-up fixes for runtime annotation checks [toc]

In Nushell 0.114.0, we promoted enforce-runtime-annotations from an opt-in experimental option to an opt-out experimental option. That is the usual path for experimental options: more people try them, we get better feedback, and the feature gets closer to being stable.

As expected, that wider testing found some rough edges. Some came from invalid signatures, some from type checks that were too strict, and some from checks that were simply not accurate enough. We are tracking those reports in issue #18528, and this patch release fixes a number of them, mostly thanks to @Bahex. Thank you!

More issues may still turn up. Please report them if you run into anything suspicious. If enforce-runtime-annotations blocks your workflow, you can disable just that option before Nushell starts:

NU_EXPERIMENTAL_OPTIONS=enforce-runtime-annotations=false nu

Or pass it as a command-line flag:

nu --experimental-options enforce-runtime-annotations=false

See the nu-experimental user documentation for more details.

We still encourage everyone to keep as many experimental options enabled as possible. It helps us find bugs earlier and make Nushell better for future releases.

Changes [toc]

Bug fixes [toc]

More helpful errors for failed assignments with enforce-runtime-annotations [toc]

PR #18531 by @Bahex

With enforce-runtime-annotations enabled, assignments with incorrect types raise errors.

Previously this error was nu::shell::cant_convert originally used for unsuccessful type coercions of command arguments. Unfortunately, this error only pointed at the assigned values origin and not at the failed assignment.

This error has been switched to nu::shell::type_mismatch and now points to the failed assignment in addition to the value's origin.

Example 1
Code
mut execution_time = -1
$execution_time = $env.CMD_DURATION_MS
Before
Error: nu::shell::cant_convert

  × Can't convert to int.
   ╭─[Host Environment Variables:1:1]
 1 │ "ALLUSERSPROFILE"="C:\\ProgramData"
   · ▲
   · ╰── can't convert string to int
 2 │ "ANDROID_AVD_HOME"="B:\\AndroidAVDs"
   ╰────
After
Error: nu::shell::type_mismatch

  × Type mismatch.
   ╭─[repl_entry #3:1:17]
 1 │ $execution_time = $env.CMD_DURATION_MS
   ·                 ┬
   ·                 ╰── expected int, got string
   ╰────
Example 2
Code
# delibarete type erasure
# we need to bypass parse-time
# type checking for this example
let stuff: any = {
	foo: "bar"
}

mut x = 1

$x = $stuff.foo
Before
Error: nu::shell::cant_convert

  × Can't convert to int.
   ╭─[repl_entry #5:1:24]
 1 │ let stuff: any = {foo: "bar"}
   ·                        ──┬──
   ·                          ╰── can't convert string to int
   ╰────
After
Error: nu::shell::type_mismatch

  × Type mismatch.
   ╭─[repl_entry #5:1:24]
 1 │ let stuff: any = {foo: "bar"}
   ·                        ──┬──
   ·                          ╰── the value is a string
   ╰────
   ╭─[repl_entry #7:1:4]
 1 │ $x = $stuff.foo
   ·    ┬
   ·    ╰── expected int, got string
   ╰────

Closure's input type is not inherited from the surrounding scope [toc]

PR #18540 by @Bahex

With last release, pipeline input type and how it affects various expressions are being tracked in a lot more cases.

In fact, at least one too many:

def mk-add-suffix [suffix: string]: nothing -> closure {
	{|| $in ++ $suffix }
}
Error: nu::parser::operator_unsupported_type

  × The '++' operator does not work on values of type 'nothing'.
   ╭─[repl_entry #8:2:5]
 1 │ def mk-add-suffix [suffix: string]: nothing -> closure {
 2 │ {|| $in ++ $suffix }}
   ·     ─┬─ ─┬
   ·      │   ╰── does not support 'nothing'
   ·      ╰── nothing
   ╰────

This is now fixed, and closures' input type will be inferred as any, the way it was before 0.114.0.

Add list input type to more date commands [toc]

PR #18536 by @fdncred

Allow more date commands to have a list as input -> output. These are the commands that were updated:

  • date humanize
  • date from-human
  • date to-timezone
  • format date
  • into datetime

Other fixes [toc]

  • Fixed input listen's output type signature to match actual returned value. With the incorrect signature (and enforce-runtime-annotations on) let x = input listen would raise an error due to $x's inferred type (based on input listen's signature) not matching the value assigned to it. (#18535)
  • Type checking treats table and list<record> as compatible (provided the columns aren't disjoint), but that did not extend to list<oneof<record, ...>>. This has been fixed. (#18560)
  • Runtime type checking of non-stream pipeline data is now more accurate. (#18560)
  • Fixed uname's output type signature to match its actual output. Previously it was table, now it's record<...> and also includes its columns. (#18568)
  • Fixed an issue where run script.nu --some-flag could bind the value to the wrong flag of the script's main when main declared multiple flags, causing shifted positional arguments or a value being accepted into a flag of the wrong type. Flags passed to run are now matched to main parameters by name. (#18533)
  • Fixed an incorrect idx search --help example. (#18550)
  • Type checking of lists are relaxed. (#18555)
  • Fixed an issue in for loops where type of the looping variable was inferred incorrectly when iterating over a value/stream with a union type (oneof<list, table, binary>). This could manifest as a runtime type checking error with enforce-runtime-annotations enabled. (#18551)

Hall of fame [toc]

Thanks to all the contributors below for helping us solve issues, improve documentation, refactor code, and more! 🙏

authorchangelink
@cptpiepmatzcargo update crossbeam crates#18554
@Juhan280Initialize start_time for MCP only in MCP mode to avoid cargo warning#18530

Full changelog [toc]

authortitlelink
@Alb-Ofix(idx): correct search context help example#18550
@Alb-Ofix(parser): infer for loop items from iterable unions#18551
@Bahexfix: assignment errors point to the assignment#18531
@Bahexfix: input listen's output type#18535
@Bahexfix: closure's input type shouldn't be inherited from scope#18540
@Bahexfix: relax assignability of list types#18555
@Bahexfix type comparisons between table and list&lt;oneof&gt;#18560
@Bahexfix: uname signature, and add detailed column info#18568
@Juhan280fix(mcp): initialize start_time for MCP only in MCP mode to avoid cargo warning#18530
@cptpiepmatzcargo update crossbeam crates#18554
@fdncredadd list input type to more date commands#18536
@hexbinoctFix run binding forwarded flags to the wrong parameter#18533
Edit this page on GitHub
Contributors: Piepmatz