Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add a dependent crate that is a subdirectory in a git repository?

I want to use an EDN parser but it is inside https://github.com/mozilla/mentat. https://github.com/mozilla/mentat/tree/master/edn has its own Cargo.toml.

I tried this:

[dependencies]
edn = { git = "https://github.com/mozilla/mentat/tree/master/edn" }

But it doesn't work.

Is it possible to add dependency to this crate inside the mentat repository?

like image 843
Vee Satayamas Avatar asked Oct 17 '17 09:10

Vee Satayamas


People also ask

What is subdirectory in git?

git. Git uses this special subdirectory to store all the information about the project, including all files and sub-directories located within the project's directory. If we ever delete the . git subdirectory, we will lose the project's history. Next, we will change the default branch to be called main .

How do I push a sub folder in github?

move everything from the subdirectory of the parent repo work tree to the child repo work tree. commit the child repo. replace the subdirectory in the parent repo with a submodule reference.

What are dependencies in Rust?

The [dependencies] section lets you add dependencies for your project. For example, suppose that we want our program to have a great CLI. You can find lots of great packages on crates.io (the official Rust package registry).

Where is cargo TOML located?

Cargo. toml and Cargo. lock are stored in the root of your project (package root). Source code goes in the src directory.


1 Answers

From the Cargo documentation:

Cargo will fetch the git repository at this location then look for a Cargo.toml for the requested crate anywhere inside the git repository (not necessarily at the root).

(emphasis mine)

This means that you can just say:

[dependencies]
edn = { git = "https://github.com/mozilla/mentat" }
like image 159
Lukas Kalbertodt Avatar answered Sep 22 '22 12:09

Lukas Kalbertodt