Skip to content

Conversation

hsy822
Copy link
Collaborator

@hsy822 hsy822 commented Oct 1, 2025

Problem

The previous compilation logic used a flexible search to locate Nargo.toml and determine the project root.
This could lead to unintended behavior, such as:

  • Zipping the entire workspace
  • Selecting the wrong directory for compilation
  • Errors when users did not follow a standard project structure

Solution

This PR modifies the logic to enforce a strict, conventional Noir project structure.

  • A .nr file must be located inside a src folder
  • A Nargo.toml file must exist in the parent directory of the src folder (the project root)
  • If these conditions are not met, the compilation process is aborted
  • A clear error message is shown to the user, guiding them to set up their project correctly

How to Test

Follow these steps to verify the new compilation logic:

  1. Create a project folder
    In your workspace, create a new folder named after your project (e.g., hello_noir).

  2. Create a src directory
    Inside the project folder, create a subfolder named src.

  3. Add a source file
    Inside src, create a file named main.nr and add the following content:

    fn main(x: Field, y: pub Field) {
        assert(x != y);
    }
  4. Add a project configuration file
    In the project root (the same level as src), create a file named Nargo.toml and add the following content:

    [package]
    name = "hello_noir"
    type = "bin"
    authors = [""]
  5. Compile the project
    Open the main.nr file in the editor, then click Compile in the Noir compiler.

  6. Check the build output
    If the compilation succeeds, a new folder named build should appear inside your project directory.
    The folder should contain:

    • program.json
    • prover.toml

If both files are generated, the test is successful.

Copy link

netlify bot commented Oct 1, 2025

Deploy Preview for reliable-cocada-166884 ready!

Name Link
🔨 Latest commit e01aaa8
🔍 Latest deploy log https://app.netlify.com/projects/reliable-cocada-166884/deploys/68eced81c44a310008dbd159
😎 Deploy Preview https://deploy-preview-6422--reliable-cocada-166884.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@hsy822 hsy822 added the ready-to-review PR ready to review label Oct 1, 2025
@hsy822 hsy822 force-pushed the fix-noir-compiler-fileupload branch from 4df66dd to f8b47e7 Compare October 9, 2025 05:32
Copy link
Collaborator

@ioedeveloper ioedeveloper left a comment

Choose a reason for hiding this comment

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

I get the error in the image below for a valid project structure.
Screenshot 2025-10-09 at 12 47 59

@hsy822 hsy822 force-pushed the fix-noir-compiler-fileupload branch from f8b47e7 to 23ac09d Compare October 10, 2025 03:46
@hsy822
Copy link
Collaborator Author

hsy822 commented Oct 10, 2025

I get the error in the image below for a valid project structure.

The project root detection logic has been updated to provide greater flexibility.

Previously, the compiler only supported projects nested within a dedicated folder (e.g., (workspace)/project/src). This commit enhances the logic to also handle projects located directly at the workspace root (e.g., (workspace)/src).

Both of the following structures are now correctly identified and supported:

  • (workspace)/project/src/...
  • (workspace)/src/...

@hsy822 hsy822 requested a review from ioedeveloper October 10, 2025 05:12
@hsy822 hsy822 force-pushed the fix-noir-compiler-fileupload branch from d55cd50 to e01aaa8 Compare October 13, 2025 12:15
@hsy822 hsy822 merged commit 1579491 into master Oct 13, 2025
33 checks passed
@hsy822 hsy822 deleted the fix-noir-compiler-fileupload branch October 13, 2025 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-review PR ready to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants