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

Manifest::new() doesn't work with relative manifest path #7596

Closed
magmast opened this issue Nov 15, 2019 · 0 comments · Fixed by #8321
Closed

Manifest::new() doesn't work with relative manifest path #7596

magmast opened this issue Nov 15, 2019 · 0 comments · Fixed by #8321
Labels
A-cargo-api Area: cargo-the-library API and internal code issues C-bug Category: bug

Comments

@magmast
Copy link

magmast commented Nov 15, 2019

Problem

I'm using cargo as dependency in my project. The function Workspace::new used with relative manifest_path does return error with message invalid path url `` . The same code, but using absolute manifest_path is working correctly.

Steps

  1. Create project and add cargo as a dependency
  2. Try to load workspace using relative manifest_path

Possible Solution(s)

If it's expected behavior it should be mentioned in documentation. Otherwise Workspace::new could transform relative path to absolute before using it.

Notes

Output of cargo version: dependency is defined like that cargo = "0.40".

Example code that isn't working:

use cargo::core::Workspace;
use cargo::Config;

fn main() {
    let manifest_path = "Cargo.toml";
    let config = Config::default().unwrap();
    let workspace = Workspace::new(manifest_path.as_ref(), &config).unwrap();

    for member in workspace.members() {
        println!("{}", member.name());
    }
}

Example of working code:

use cargo::core::Workspace;
use cargo::Config;

use std::env;

fn main() {
    let manifest_path = env::current_dir().unwrap().join("Cargo.toml");
    let config = Config::default().unwrap();
    let workspace = Workspace::new(&manifest_path, &config).unwrap();

    for member in workspace.members() {
        println!("{}", member.name());
    }
}
@magmast magmast added the C-bug Category: bug label Nov 15, 2019
@ehuss ehuss added the A-cargo-api Area: cargo-the-library API and internal code issues label Dec 3, 2019
@bors bors closed this as completed in de31a34 Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cargo-api Area: cargo-the-library API and internal code issues C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants