# USD Plugins and Root Path

**URL:** <https://forum.aousd.org/t/usd-plugins-and-root-path/542>\
**Category:** USD\
**Created:** [August 31, 2023, 12:11am UTC](https://forum.aousd.org/t/usd-plugins-and-root-path/542 "2023-08-31T00:11:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![eslavin](https://avatars.discourse-cdn.com/v4/letter/e/34f0e0/32.png) [@eslavin](https://forum.aousd.org/u/eslavin)\
**Post date:** [August 31, 2023, 12:11am UTC](https://forum.aousd.org/t/usd-plugins-and-root-path/542/1 "2023-08-31T00:11:44Z")

</div>

In refining our schema build tools, I ran across a curious case that Plug didn’t like. As an example, consider I have the following plugin folder structure:

- schemas
  - bin
    - schemaA.dll
    - schemaB.dll

  - SchemaA
    - **init**.py

  - SchemaB
    - **init**.py

  - plugins
    - SchemaA
    - resources
      - plugInfo.json
      - generatedSchema.usda

    - SchemaB
    - resources
      - plugInfo.json
      - generatedSchema.usda

The contents of the `plugInfo.json` file for `SchemaA` was setup such that:

- Root = …/…/…
- ResourcesPath = plugins/SchemaA/resources
- LibraryPath = bin/SchemaA.dll

Similarly, the one for `SchemaB` was setup such that:

- Root = …/…/…
- ResourcesPath = plugins/SchemaB/resources
- LibraryPath = bin/SchemaB.dll

To register the plugins, either `PXR_PLUGINPATH_NAME` contained the paths:

- schemas/plugins/SchemaA/resources
- schemas/plugins/SchemaB/resources

(or they were individually sent to `RegisterPlugins` to register explicitly).

It turns out Plug refused to load both plugins - only the first would be loaded because there was an early out when checking the “Root” path of the plugins, and because this was the same path for SchemaA and SchemaB, plug decided it was the same plugin. Clearly these plugins are in their own location (which can be deduced by combining the root path with the resources path where the actual `plugInfo.json` file resides), so it is curious why this would be a restriction from the point of view of Plug? I find it more intuitive to say a plugin being registered is the same if the path to the `plugInfo.json` path is the same (which is the path you have to pass to `RegisterPlugins` or put in `PXR_PLUGINPATH_NAME` anyway). Is there a specific reason why this is not the case (and would something be lost if this behavior was changed)?

Obviously, I can change this such that SchemaA had:

- Root = “…”
- LibraryPath = “…/…/bin/SchemaA.dll”
- ResourcesPath = “resources”

and SchemaB had:

- Root = “…”
- LibraryPath = “…/…/bin/SchemaB.dll”
- ResourcesPath = “resources”

and then it’s fine because `Root` resolves to two different locations on disk. But I’m curious as to why there is a restriction on the Root path rather than where the `plugInfo.json` file actually is.

---

<div class="post-metadata">

**Author:** ![sunya](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@sunya](https://forum.aousd.org/u/sunya)\
**Post date:** [August 31, 2023, 8:01pm UTC](https://forum.aousd.org/t/usd-plugins-and-root-path/542/2 "2023-08-31T20:01:59Z")

</div>

At first blush this does seem like an oversight somewhere. Can you point me to the code in Plug that’s checking for the duplicated “Root” path? I did a quick look but couldn’t find anything like that.

---

<div class="post-metadata">

**Author:** ![eslavin](https://avatars.discourse-cdn.com/v4/letter/e/34f0e0/32.png) [@eslavin](https://forum.aousd.org/u/eslavin)\
**Post date:** [August 31, 2023, 8:41pm UTC](https://forum.aousd.org/t/usd-plugins-and-root-path/542/3 "2023-08-31T20:41:36Z")

</div>

sure, I believe it’s this block:

> <https://github.com/PixarAnimationStudios/OpenUSD/blob/10b62439e9242a55101cf8b200f2c7e02420e1b0/pxr/base/plug/plugin.cpp#L103>

---

<div class="post-metadata">

**Author:** ![sunya](https://avatars.discourse-cdn.com/v4/letter/s/9de053/32.png) [@sunya](https://forum.aousd.org/u/sunya)\
**Post date:** [September 5, 2023, 10:09pm UTC](https://forum.aousd.org/t/usd-plugins-and-root-path/542/4 "2023-09-05T22:09:27Z")

</div>

Huh, I haven’t looked too closely yet but naively I’d expect `metadata.pluginPath` to be the fully qualified path of the shared library, not just the root path. I’ll try to poke at this a little more, but if you could file an issue about it that’d be great too so I don’t lose track.
