Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I'm getting InvalideEditBlock #456

Closed
nielsbosma opened this issue Jan 25, 2024 · 2 comments
Closed

I'm getting InvalideEditBlock #456

nielsbosma opened this issue Jan 25, 2024 · 2 comments
Labels
question Further information is requested

Comments

@nielsbosma
Copy link

When asking questions or reporting issues, it is very helpful if you can include:

PS D:\Repos> aider
Aider v0.22.0
Model: gpt-4-0613 using diff edit format
Git repo: none
Repo-map: using 1024 tokens
Use /help to see in-chat commands, run with --help to see cmd line args

I keep getting these errors:

<<<<<<< SEARCH
var options = ScriptOptions.Default
.WithImports("System")
.WithMetadataResolver(ScriptMetadataResolver.Default
.WithBaseDirectory(AppDomain.CurrentDomain.BaseDirectory)
.WithSearchPaths(AssemblyLoadContext.Default.Assemblies
.Select(a => Path.GetDirectoryName(a.Location))));

var loadContext = AssemblyLoadContext.GetLoadContext(Assembly.GetExecutingAssembly());
loadContext.Resolving += (context, name) =>
{
return context.Assemblies.FirstOrDefault(a => a.FullName == name.FullName);
};

var options = ScriptOptions.Default
.WithImports("System")
.WithMetadataResolver(ScriptMetadataResolver.Default
.WithBaseDirectory(AppDomain.CurrentDomain.BaseDirectory)
.WithSearchPaths(loadContext.Assemblies
.Select(a => Path.GetDirectoryName(a.Location))));

REPLACE

This change will make the ScriptOptions use the assemblies loaded in the same AssemblyLoadContext as the plugin for
resolving types, which should include the TestPlugin assembly loaded by the plugin.

Committing TestPlugin\Plugin.cs before applying edits.
Commit 2e28b2c Add System.Runtime.Loader to script metadata resolver search paths.
Malformed response #4, aborting.
InvalidEditBlock: edit failed!

TestPlugin\Plugin.cs does not contain the exact chunk of SEARCH lines you specified.
Try again.
DO NOT skip blank lines, comments, docstrings, etc!
The SEARCH block needs to be EXACTLY the same as the lines in TestPlugin\Plugin.cs with nothing missing!

TestPlugin\Plugin.cs does not contain these 6 exact lines in a row:

var options = ScriptOptions.Default
            .WithImports("System")
            .WithMetadataResolver(ScriptMetadataResolver.Default
                .WithBaseDirectory(AppDomain.CurrentDomain.BaseDirectory)
                .WithSearchPaths(AssemblyLoadContext.Default.Assemblies
                    .Select(a => Path.GetDirectoryName(a.Location))));
@paul-gauthier paul-gauthier added the question Further information is requested label Jan 25, 2024
@paul-gauthier
Copy link
Collaborator

Thanks for trying aider and filing this issue.

Are those lines in your file? Or are there similar lines, but not quite exactly the same? If so, can you share the actual chunk of the file that it seems to be trying to edit?

You could also try switching to GPT-4 Turbo and see if it works better with your code.

@paul-gauthier
Copy link
Collaborator

I'm going to close this issue for now, but feel free to add a comment here and I will re-open or file a new issue any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants