Pub finished with exit code 64

Query- pub finished with exit code 64

When you encounter the error message “pub finished with exit code 64” while running the pub command, it indicates that there was an error in the build process of your Dart application or package. Exit code 64 generally refers to an unhandled exception in your code. This error can occur due to a variety of reasons, and it’s crucial to understand the possible causes to resolve it effectively.

Possible Causes:

  1. Code Issue: There might be an unhandled exception or error occurring during the execution of your Dart application. These exceptions can include null pointer exceptions, type errors, or other types of runtime errors. It’s essential to carefully review your code for any potential issues that could trigger such exceptions.

    Here’s an example of a Dart code snippet containing a potential error:

              
                import 'dart:async';
    
                void main() {
                  // Triggering a null pointer exception
                  String? name;
                  print(name!.length);
                }
              
            

    In this example, accessing the “length” property of a nullable variable “name” without checking for null can cause a null pointer exception and lead to the “pub finished with exit code 64” error.

  2. Dependency Issue: Your Dart application or package may have dependencies that are either missing or incompatible with your current Dart SDK version. Ensure that all the required dependencies are correctly updated and compatible with your project.

    For example, consider a situation where a certain package version is not compatible with your current Dart SDK version. It might lead to runtime errors, causing the “pub finished with exit code 64” error.

  3. Tooling Issue: Sometimes, the error might be caused by an issue with the Dart SDK, pub tool, or related build tools. Ensure that you have the latest version of Dart SDK and pub installed. You can also try running “pub upgrade” to update all the dependencies and resolve any potential tooling-related issues.

Resolution:

To resolve the “pub finished with exit code 64” error, follow these steps:

  1. Review your code for any potential errors and fix them accordingly. Carefully examine the stack trace provided in the error message to identify the specific line of code causing the exception.
  2. Check your dependencies and ensure that they are correctly specified in your project’s pubspec.yaml file. Update any outdated dependencies and ensure their compatibility with your Dart SDK version.
  3. Verify that you have the latest version of Dart SDK installed on your machine. If not, update it to the latest stable version.
  4. Run “pub upgrade” command to update all the dependencies in your project.
  5. If the issue persists, consider seeking help from the Dart community forums, official documentation, or relevant support channels for further assistance.

By following these steps and addressing any code, dependency, or tooling issues, you should be able to resolve the “pub finished with exit code 64” error and successfully build your Dart application or package.

Leave a comment