Skip to content

fix: better package name validation and error messages for nargo new/init#8978

Merged
TomAFrench merged 7 commits intomasterfrom
ab/nargo-new-init-better-name-validation
Jun 20, 2025
Merged

fix: better package name validation and error messages for nargo new/init#8978
TomAFrench merged 7 commits intomasterfrom
ab/nargo-new-init-better-name-validation

Conversation

@asterite
Copy link
Copy Markdown
Collaborator

@asterite asterite commented Jun 19, 2025

Description

Problem

Resolves #8919
Resolves #4189

Summary

Also, since it was in the same codebase, now running nargo init on a directory that has a Nargo.toml file will not overwrite that file and give a proper error (like cargo init does).

The error messages are now similar to those used by cargo new/init, though I changed some minor things (they always surround chars and name with backticks, but I think it's more common to use single and double quotes respectively).

Some examples:

$ nargo new 'hello world'
Error: invalid character ' ' in package name "hello world", characters must be ASCII alphanumeric characters or '_' (underscore)
If you need a package name to not match the directory name, consider using the `--name` flag.

$ nargo new '1two'
Error: invalid character '1' in package name "1two", the name cannot start with a digit
If you need a package name to not match the directory name, consider using the `--name` flag.

$ nargo new '!hello'
Error: invalid character '!' in package name "!hello", the first character must be an ASCII alphabetic character or '_' (underscore)
If you need a package name to not match the directory name, consider using the `--name` flag.

$ nargo new 'test-noir'
Error: invalid character '-' in package name "test-noir", characters must be ASCII alphanumeric characters or '_' (underscore)
If you need a package name to not match the directory name, consider using the `--name` flag.

$ pwd
/Users/asterite/Sandbox/nargo_new/foo bar

$ nargo init
Error: invalid character ' ' in package name "foo bar", characters must be ASCII alphanumeric characters or '_' (underscore)
If you need a package name to not match the directory name, consider using the `--name` flag.

Additional Context

Documentation

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Compilation Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: c535ba8 Previous: 8a7046b Ratio
private-kernel-inner 2.774 s 2.304 s 1.20

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 19190ff Previous: 2cfc786 Ratio
rollup-merge 0.004 s 0.003 s 1.33

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

@asterite asterite requested a review from a team June 19, 2025 17:14
Copy link
Copy Markdown
Contributor

@aakoshh aakoshh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

FWIW I agree with not allowing - in the name. It takes out some of the guesswork when adding dependencies.

@TomAFrench TomAFrench added this pull request to the merge queue Jun 20, 2025
Merged via the queue into master with commit 06c73d7 Jun 20, 2025
118 checks passed
@TomAFrench TomAFrench deleted the ab/nargo-new-init-better-name-validation branch June 20, 2025 14:33
github-merge-queue bot pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jun 23, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix: increment reference counts when deduplicating calls which return
arrays (noir-lang/noir#8757)
fix: Add a aliased check for last stores
(noir-lang/noir#8955)
fix(LICM): Consider negative loop bounds before hoisting `div <const>
<induction-var>` (noir-lang/noir#8986)
fix: check "negate with overflow" in comptime code + allow u1 to be used
in comptime code (noir-lang/noir#8969)
fix: better package name validation and error messages for nargo
new/init (noir-lang/noir#8978)
feat(fuzz): Add comptime_vs_brillig_direct target
(noir-lang/noir#8924)
fix(expand): show references to ModuleDefId recursing on parents
(noir-lang/noir#8977)
feat(ssa_fuzzer): loops + signed
(noir-lang/noir#8881)
fix(fuzz): Do not take a mutable reference over immutable vars which
contain a mutable ref (noir-lang/noir#8971)
fix(fuzz): Avoid negating `i8::MIN` into `i8::MAX+1` which won't compile
(noir-lang/noir#8972)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <[email protected]>
Co-authored-by: Tom French <[email protected]>
github-merge-queue bot pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jun 23, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix: increment reference counts when deduplicating calls which return
arrays (noir-lang/noir#8757)
fix: Add a aliased check for last stores
(noir-lang/noir#8955)
fix(LICM): Consider negative loop bounds before hoisting `div <const>
<induction-var>` (noir-lang/noir#8986)
fix: check "negate with overflow" in comptime code + allow u1 to be used
in comptime code (noir-lang/noir#8969)
fix: better package name validation and error messages for nargo
new/init (noir-lang/noir#8978)
feat(fuzz): Add comptime_vs_brillig_direct target
(noir-lang/noir#8924)
fix(expand): show references to ModuleDefId recursing on parents
(noir-lang/noir#8977)
feat(ssa_fuzzer): loops + signed
(noir-lang/noir#8881)
fix(fuzz): Do not take a mutable reference over immutable vars which
contain a mutable ref (noir-lang/noir#8971)
fix(fuzz): Avoid negating `i8::MIN` into `i8::MAX+1` which won't compile
(noir-lang/noir#8972)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <[email protected]>
Co-authored-by: Tom French <[email protected]>
github-merge-queue bot pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jun 23, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix: increment reference counts when deduplicating calls which return
arrays (noir-lang/noir#8757)
fix: Add a aliased check for last stores
(noir-lang/noir#8955)
fix(LICM): Consider negative loop bounds before hoisting `div <const>
<induction-var>` (noir-lang/noir#8986)
fix: check "negate with overflow" in comptime code + allow u1 to be used
in comptime code (noir-lang/noir#8969)
fix: better package name validation and error messages for nargo
new/init (noir-lang/noir#8978)
feat(fuzz): Add comptime_vs_brillig_direct target
(noir-lang/noir#8924)
fix(expand): show references to ModuleDefId recursing on parents
(noir-lang/noir#8977)
feat(ssa_fuzzer): loops + signed
(noir-lang/noir#8881)
fix(fuzz): Do not take a mutable reference over immutable vars which
contain a mutable ref (noir-lang/noir#8971)
fix(fuzz): Avoid negating `i8::MIN` into `i8::MAX+1` which won't compile
(noir-lang/noir#8972)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <[email protected]>
Co-authored-by: Tom French <[email protected]>
github-merge-queue bot pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Jun 23, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix: increment reference counts when deduplicating calls which return
arrays (noir-lang/noir#8757)
fix: Add a aliased check for last stores
(noir-lang/noir#8955)
fix(LICM): Consider negative loop bounds before hoisting `div <const>
<induction-var>` (noir-lang/noir#8986)
fix: check "negate with overflow" in comptime code + allow u1 to be used
in comptime code (noir-lang/noir#8969)
fix: better package name validation and error messages for nargo
new/init (noir-lang/noir#8978)
feat(fuzz): Add comptime_vs_brillig_direct target
(noir-lang/noir#8924)
fix(expand): show references to ModuleDefId recursing on parents
(noir-lang/noir#8977)
feat(ssa_fuzzer): loops + signed
(noir-lang/noir#8881)
fix(fuzz): Do not take a mutable reference over immutable vars which
contain a mutable ref (noir-lang/noir#8971)
fix(fuzz): Avoid negating `i8::MIN` into `i8::MAX+1` which won't compile
(noir-lang/noir#8972)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <[email protected]>
Co-authored-by: Tom French <[email protected]>
danielntmd pushed a commit to danielntmd/aztec-packages that referenced this pull request Jul 16, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix: increment reference counts when deduplicating calls which return
arrays (noir-lang/noir#8757)
fix: Add a aliased check for last stores
(noir-lang/noir#8955)
fix(LICM): Consider negative loop bounds before hoisting `div <const>
<induction-var>` (noir-lang/noir#8986)
fix: check "negate with overflow" in comptime code + allow u1 to be used
in comptime code (noir-lang/noir#8969)
fix: better package name validation and error messages for nargo
new/init (noir-lang/noir#8978)
feat(fuzz): Add comptime_vs_brillig_direct target
(noir-lang/noir#8924)
fix(expand): show references to ModuleDefId recursing on parents
(noir-lang/noir#8977)
feat(ssa_fuzzer): loops + signed
(noir-lang/noir#8881)
fix(fuzz): Do not take a mutable reference over immutable vars which
contain a mutable ref (noir-lang/noir#8971)
fix(fuzz): Avoid negating `i8::MIN` into `i8::MAX+1` which won't compile
(noir-lang/noir#8972)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <[email protected]>
Co-authored-by: Tom French <[email protected]>
AztecBot added a commit to AztecProtocol/barretenberg that referenced this pull request Dec 3, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
fix: increment reference counts when deduplicating calls which return
arrays (noir-lang/noir#8757)
fix: Add a aliased check for last stores
(noir-lang/noir#8955)
fix(LICM): Consider negative loop bounds before hoisting `div <const>
<induction-var>` (noir-lang/noir#8986)
fix: check "negate with overflow" in comptime code + allow u1 to be used
in comptime code (noir-lang/noir#8969)
fix: better package name validation and error messages for nargo
new/init (noir-lang/noir#8978)
feat(fuzz): Add comptime_vs_brillig_direct target
(noir-lang/noir#8924)
fix(expand): show references to ModuleDefId recursing on parents
(noir-lang/noir#8977)
feat(ssa_fuzzer): loops + signed
(noir-lang/noir#8881)
fix(fuzz): Do not take a mutable reference over immutable vars which
contain a mutable ref (noir-lang/noir#8971)
fix(fuzz): Avoid negating `i8::MIN` into `i8::MAX+1` which won't compile
(noir-lang/noir#8972)
END_COMMIT_OVERRIDE

---------

Co-authored-by: AztecBot <[email protected]>
Co-authored-by: Tom French <[email protected]>
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.

Add to docs that hyphens are not allowed in project names Expand nargo init behavior resemblance of cargo init

3 participants