grails-core: Grails 3.0.3: gradle run throws exception "Createprocess error=206; the filename or extension is too long"

When starting a clean grails 3.0.3 app with just a few additional dependencies, the app won’t execute.

Createprocess error=206; the filename or extension is too long

This seems to be a Windows issue as there is a maximum of 30. 000 of characters for a command (see https://support.microsoft.com/en-en/kb/830473).

So, on windows based machines you would never be able to start your app with some additional (transitive) dependencies .

I tried to solve this with a couple of gradle workarounds as mentioned here: https://discuss.gradle.org/t/filename-too-long-in-windows/9222 http://stackoverflow.com/questions/22659463/add-classpath-in-manifest-using-gradle

but they don’t solve this problem. I think grails itself is generating the classpath param (-cp)

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 32 (15 by maintainers)

Most upvoted comments

For future reference, to enable the behavior your build.gradle must have the pathingJar option set to true:

grails {
    pathingJar = true
}

Here is the fix for the issue with the assets inside the pathing jar (which will break asset reloading):

if (OperatingSystem.current().isWindows()) {
    task pathingJar(type: Jar) {
        dependsOn configurations.runtime
        appendix = 'pathing'

        doFirst {
            manifest {
                // Build the Class-Path for absolute paths based on runtime dependencies.
                attributes "Class-Path": configurations.runtime.files.collect {
                    it.toURL().toString().replaceFirst(/file:\/+/, '/')
                }.join(' ')
            }
        }

        // assetCompile will be execute for all Jar-type tasks
        // (see https://github.com/bertramdev/asset-pipeline/blob/master/asset-pipeline-gradle/src/main/groovy/asset/pipeline/gradle/AssetPipelinePlugin.groovy#L85)
        // at least exclude the assets from pathing jar
        exclude { it.file.absolutePath.contains('assetCompile') }
    }

    // This gradle task will be called by `grails run-app`.
    bootRun {
        dependsOn pathingJar
        doFirst {
            // Add the compiled app classed to the classpath of the pathing jar. Probably there is a gradle variable for them?
            classpath = files("$buildDir/classes/main", "$buildDir/resources/main", "$projectDir/gsp-classes", pathingJar.archivePath)
        }
    }

    // Do the same for like for bootRun for the run task executable by `gradle run`.
    run {
        dependsOn pathingJar
        doFirst {
            classpath = files("$buildDir/classes/main", "$buildDir/resources/main", "$projectDir/gsp-classes", pathingJar.archivePath)
        }
    }
}

The assetCompile task will be still executed but the assets not packaged into the pathing jar.

I recommend that you try long path tool, it’s really useful tool and it had worked with me.

@keltik85 That most likely means the grails gradle plugin isn’t included in your build.gradle. Create a fresh 3.1.4 application and look at the differences between the build.gradle files.