# Missing @Path("buildDir") in NativeBinaryRules#assignTools rule

**URL:** <https://discuss.gradle.org/t/missing-path-builddir-in-nativebinaryrules-assigntools-rule/18858>\
**Category:** Bugs\
**Tags:** issue-resolved, gradle-3523\
**Created:** [August 8, 2016, 5:54pm UTC](https://discuss.gradle.org/t/missing-path-builddir-in-nativebinaryrules-assigntools-rule/18858 "2016-08-08T17:54:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_L](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/daniel_l/32/6420_2.png) [@Daniel\_L](https://discuss.gradle.org/u/Daniel_L)\
**Post date:** [August 8, 2016, 5:54pm UTC](https://discuss.gradle.org/t/missing-path-builddir-in-nativebinaryrules-assigntools-rule/18858/1 "2016-08-08T17:54:50Z")

</div>

There seems to be a bug at line 32 of file NativeBinaryRules.java [1]. The rule assume only one node will be of type File which maps to buildDir (the @Path is commented out). This is problematic when trying to follow the same pattern and have root element for reports directory and possibly more. The following code show the failure:

```
class Rules extends RuleSource {
  @Model
  File reportsDir(@Path("buildDir") File buildDir) {
    return new File(buildDir, "reports")
  }
}
apply plugin: Rules
apply plugin: "cpp"

model {
  toolChains {
    msvc(VisualCpp)
  }
  components {
    main(NativeExecutableSpec)
  }
}

```

Executing `$ ./gradlew.bat :tasks` will cause the following exception:

```
> Exception thrown while executing model rule: NativeComponentModelPlugin.Rules#createBinaries(TargetedNativeComponentInterval, PlatformResolvers, BuildTypeContainer, FlavorContainer, ServiceRegistry) > named(executable, org.gradle.nativeplatform.internal.configure.NativeBinaryRules)
    > There is a problem with model rule NativeBinaryRules#assignTools(NativeBinarySpec, NativeToolChainRegistryInternal, File).
        > Type-only model reference of type java.io.File (parameter 3) is ambiguous as multiple model elements are available for this type:
            - buildDir (created by: Project.<init>.buildDir())
            - reportsDir (created by: Rules#reportsDir(File))

```

The gradle version we are using is 2.14.1 on a Windows operating system. They may be other rules coded like this one which would require grepping the codebase in order to find them and apply a fix.

[1] [https://github.com/gradle/gradle/blob/master/subprojects/platform-native/src/main/java/org/gradle/nativeplatform/internal/configure/NativeBinaryRules.java#L32](https://github.com/gradle/gradle/blob/master/subprojects/platform-native/src/main/java/org/gradle/nativeplatform/internal/configure/NativeBinaryRules.java#L32)

---

<div class="post-metadata">

**Author:** ![CedricChampeau](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/cedricchampeau/32/7541_2.png) [@CedricChampeau](https://discuss.gradle.org/u/CedricChampeau)\
**Post date:** [August 17, 2016, 7:37am UTC](https://discuss.gradle.org/t/missing-path-builddir-in-nativebinaryrules-assigntools-rule/18858/2 "2016-08-17T07:37:09Z")

</div>

Hi Daniel and thanks for reporting this. It definitely looks like a bug. I have created [https://issues.gradle.org/browse/GRADLE-3523](https://issues.gradle.org/browse/GRADLE-3523) to track this. Maybe you would be interested in contributing a fix?

---

<div class="post-metadata">

**Author:** ![eskatos](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/eskatos/32/5401_2.png) [@eskatos](https://discuss.gradle.org/u/eskatos)\
**Post date:** [August 17, 2016, 8:44am UTC](https://discuss.gradle.org/t/missing-path-builddir-in-nativebinaryrules-assigntools-rule/18858/3 "2016-08-17T08:44:19Z")

</div>

I went ahead and [fixed](https://github.com/gradle/gradle/commit/a057758cf07911a2f792e929456b4bd9da037704) the issue.  
It will be part of 3.1.

---

<div class="post-metadata">

**Author:** ![Daniel\_L](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/daniel_l/32/6420_2.png) [@Daniel\_L](https://discuss.gradle.org/u/Daniel_L)\
**Post date:** [August 21, 2016, 3:10pm UTC](https://discuss.gradle.org/t/missing-path-builddir-in-nativebinaryrules-assigntools-rule/18858/4 "2016-08-21T15:10:33Z")

</div>

I confirmed, it is fixed. Thanks a lot!
