GithubHelp home page GithubHelp logo

Comments (7)

sourcefrog avatar sourcefrog commented on August 27, 2024

Hi, thanks for the report and reproduction.

I think the problem here is that cargo-mutants makes a copy of the tree before mutating it, so any paths relative to the original location won't work, as in your reproduction tree.

https://github.com/sourcefrog/cargo-mutants#:~:text=dependencies%20by%20a%20relative%20path

Using an absolute path should work, but that's not always convenient, and I'd like for it to just work without the user needing to make any prior adjustments.

There seem to be a few options:

  1. Rewrite Cargo.toml after copying to use absolute paths for any relative paths pointing out of the tree. Perhaps this is best. As a step towards this we could at least look for them and error cleanly.
  2. Give an option to mutate the tree in place (and put it back afterwards.) This would avoid any patch related issues, but there's some risk that the mutation is actually not cleaned up properly if the program stops abruptly -- and anyhow the user would have to work out to use this option, which is not ideal.
  3. An option to copy a larger, enclosing, directory, perhaps containing all the dependencies. But again the user needs to understand that they need it.

Probably rewriting paths in Cargo.toml is the best way to make it just work automatically. This also needs to handle the patch and .cargo/config.toml for overriding dependencies (https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html).

from cargo-mutants.

sourcefrog avatar sourcefrog commented on August 27, 2024
  • Find all Cargo.toml files in the tree to be copied: there might be some in subdirectories. (Possibly we should not copy nested crates and instead turn them into relative references?)
  • Parse Cargo.toml probably using https://docs.rs/toml/
  • Write out the possibly-modified file into the scratch directory.
  • Walk the toml looking for path attributes on dependencies.
  • Also look for patch or replace sections.
  • For every relative path, replace it with an absolute path, resolved from the directory where it occurs.
  • Also look for and modify .cargo/config.toml.

from cargo-mutants.

sourcefrog avatar sourcefrog commented on August 27, 2024

#43 fixes the particular case of path dependencies, although not yet all the other case. It does work on your reproduction repo. @dmoka , maybe you can try it on your bigger project?

from cargo-mutants.

dmoka avatar dmoka commented on August 27, 2024

Wow, many thanks for your detailed investigation and your quick fix, much appreciated, Martin @sourcefrog !

Absolutely, happy to give it a try. I see that the latest crate version is still the v0.2.7 which does not contain this latest fix, if I am not mistaken.

What is the easiest way to get the fixed version of the crate and trying out locally?

Thanks again, and have a great day!

from cargo-mutants.

sourcefrog avatar sourcefrog commented on August 27, 2024

Yep, it's not released yet. I'm pretty sure this works but let's check it:

  1. Clone this repo
  2. Switch to the 'relpath' branch
  3. cargo install --path .
  4. Run cargo mutants on your tree

from cargo-mutants.

dmoka avatar dmoka commented on August 27, 2024

Just checked it, and the relative-path issue has been indeed resolved.

Great job, thanks for the support!

from cargo-mutants.

sourcefrog avatar sourcefrog commented on August 27, 2024

ok this is released in 0.2.8

from cargo-mutants.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.