@@ -213,7 +213,12 @@ pub fn crate_name(orig_name: &str) -> Result<FoundCrate, Error> {
213213 & cache_entry. crate_names
214214 } ,
215215 btree_map:: Entry :: Vacant ( entry) => {
216- let workspace_manifest_path = workspace_manifest_path ( & manifest_path) ?;
216+ // If `workspace_manifest_path` returns `None`, we are probably in a vendored deps
217+ // folder and cargo complaining that we have some package inside a workspace, that isn't
218+ // part of the workspace. In this case we just use the `manifest_path` as the
219+ // `workspace_manifest_path`.
220+ let workspace_manifest_path =
221+ workspace_manifest_path ( & manifest_path) ?. unwrap_or_else ( || manifest_path. clone ( ) ) ;
217222 let workspace_manifest_ts = cargo_toml_timestamp ( & workspace_manifest_path) ?;
218223
219224 let cache_entry = entry. insert ( read_cargo_toml (
@@ -235,7 +240,7 @@ pub fn crate_name(orig_name: &str) -> Result<FoundCrate, Error> {
235240 . clone ( ) )
236241}
237242
238- fn workspace_manifest_path ( cargo_toml_manifest : & Path ) -> Result < PathBuf , Error > {
243+ fn workspace_manifest_path ( cargo_toml_manifest : & Path ) -> Result < Option < PathBuf > , Error > {
239244 let stdout = Command :: new ( env:: var ( "CARGO" ) . map_err ( |_| Error :: CargoEnvVariableNotSet ) ?)
240245 . arg ( "locate-project" )
241246 . args ( & [ "--workspace" , "--message-format=plain" ] )
@@ -246,7 +251,15 @@ fn workspace_manifest_path(cargo_toml_manifest: &Path) -> Result<PathBuf, Error>
246251
247252 String :: from_utf8 ( stdout)
248253 . map_err ( |_| Error :: FailedGettingWorkspaceManifestPath )
249- . map ( |s| s. trim ( ) . into ( ) )
254+ . map ( |s| {
255+ let path = s. trim ( ) ;
256+
257+ if path. is_empty ( ) {
258+ None
259+ } else {
260+ Some ( path. into ( ) )
261+ }
262+ } )
250263}
251264
252265fn cargo_toml_timestamp ( manifest_path : & Path ) -> Result < SystemTime , Error > {
0 commit comments