Arrow: [Bug] Ank error

Created on 15 Jan 2020  路  21Comments  路  Source: arrow-kt/arrow

What version are you currently using?
0.10.5-SNAPSHOT (with latest master)

The error: org.jetbrains.kotlin.idea.KotlinFileType cannot be cast to org.jetbrains.kotlin.com.intellij.openapi.fileTypes.LanguageFileType is all I get when I run ank atm. This is likely related to #1921
@i-walker @rachelcarmena

This also shows that ank could use some tests ^^
This is also kind of concerning because the build was fine, I suspect that we use an old version of ank somewhere in our build!

Most helpful comment

Adding this to the user project resolves the issue:

def kotlinVersion = "1.3.61"
def arrow_version = "0.10.5-SNAPSHOT"
dependencies {
  runtime "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:$kotlinVersion"
  compile "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion"
  implementation ("io.arrow-kt:arrow-ank:$arrow_version")
  runtime ("io.arrow-kt:arrow-ank:$arrow_version")
}

Is there a way to include those dependencies to the project in a way where the user solely needs to do this:

dependencies {
  implementation ("io.arrow-kt:arrow-ank:$arrow_version")
}

@rachelcarmena, @1Jajen1 do you have an idea, where we can start?

All 21 comments

Thanks @1Jajen1 , please, could you provide us info about how to reproduce it?

I am currently writing some docs for https://github.com/1Jajen1/kotlin-pretty and snippets like in https://github.com/1Jajen1/kotlin-pretty/blob/master/docs/contentIn/en/docs/getting-started/_index.md fail with this error. The ci has the full thing: https://github.com/1Jajen1/kotlin-pretty/runs/390885150

I can try setting up a minimal example if that doesn't help ^^

I have one minimal example here with the same error: https://github.com/Kotlin/dokka/pull/573
There is also the stacktrace.

However, I cannot find the error in Arrow Documentation (next.arrow-io.kt)...

However, I cannot find the error in Arrow Documentation (next.arrow-io.kt)...

That plus the fact that next.arrow-io.kt has no extra newlines at the beginning of each snippet has me really confused as well

We could undo the change and redo it in 2 steps:

  • First extract arrow-docs from build. Check that everything is working.
  • Then, if everything works properly, upload to 1.3.50 with the new changes.

Quick question: Are arrows docs always built against the version of ank that is in the project? If so a change to ank in a pr should be reflected in the docs build that every pr makes. So a change like simply adding some bs output to the main function of ank should in theory make it to the ci build. That would be a good way of quickly checking if arrow runs ank against the project version (on master and on prs)

Quick question: Are arrows docs always built against the version of ank that is in the project? If so a change to ank in a pr should be reflected in the docs build that every pr makes. So a change like simply adding some bs output to the main function of ank should in theory make it to the ci build. That would be a good way of quickly checking if arrow runs ank against the project version (on master and on prs)

Right, as far as I know, Arrow docs are built against the version of ank that is in the project:

modules/docs/arrow-docs/build.gradle:

...
dependencies {
    compile project(':arrow-ank')
...

Right, as far as I know, Arrow docs are built against the version of ank that is in the project:

Yep this works just fine: (added some output to the beginning). This has the changes from latest master as well.
https://github.com/arrow-kt/arrow/runs/390946788

This leaves me more confused than before though ^^

Another thing: With the changes currently in master, how would one run ank on the docs locally? Because always pushing changes so that the ci builds them is quite tedious.

Another thing: With the changes currently in master, how would one run ank on the docs locally? Because always pushing changes so that the ci builds them is quite tedious.

I updated the documentation about it: modules/docs/arrow-docs/README.md

If you want to use the Ank Gradle Plugin in your local environment, firstly, install it:

./gradlew :arrow-ank-gradle:publishToMavenLocal

and then:

buildscript {
  repositories {
    mavenLocal()
  }
  dependencies {
    classpath "io.arrow-kt:arrow-ank-gradle:<version>"
  }
}

apply plugin: 'ank-gradle-plugin'

I updated the documentation about it: modules/docs/arrow-docs/README.md

:+1: Thanks

+1 Thanks

Thanks to you, @1Jajen1 !!

@1Jajen1 , I was looking at your repository and I've seen 2 different versions:

arrow_version = "0.10.5-SNAPSHOT"
...
classpath "io.arrow-kt:arrow-ank-gradle:0.10.4"
...
implementation "io.arrow-kt:arrow-ank:$arrow_version"

@rachelcarmena There was no snapshot for the gradle plugin if I remember correctly. I am by no means good with build systems so who knows ^^

@rachelcarmena There was no snapshot for the gradle plugin if I remember correctly. I am by no means good with build systems so who knows ^^

No worries! There is snapshot version for Gradle Plugin: https://oss.jfrog.org/artifactory/oss-snapshot-local/io/arrow-kt/arrow-ank-gradle/

However, for Gradle plugins, it's necessary to add OSS repository in repositories section for buildscript. In your case:

buildscript {
    ext {
        arrow_version = "0.10.5-SNAPSHOT"
        ...
    }
    repositories {
        ...
        maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' }
    }
    dependencies {
        ...
        classpath "io.arrow-kt:arrow-ank-gradle:$arrow_version" 
    }
}
apply plugin: 'ank-gradle-plugin'

Adding this to the user project resolves the issue:

def kotlinVersion = "1.3.61"
def arrow_version = "0.10.5-SNAPSHOT"
dependencies {
  runtime "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:$kotlinVersion"
  compile "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion"
  implementation ("io.arrow-kt:arrow-ank:$arrow_version")
  runtime ("io.arrow-kt:arrow-ank:$arrow_version")
}

Is there a way to include those dependencies to the project in a way where the user solely needs to do this:

dependencies {
  implementation ("io.arrow-kt:arrow-ank:$arrow_version")
}

@rachelcarmena, @1Jajen1 do you have an idea, where we can start?

Great! I think those dependencies could be managed from Gradle Plugin.

About the added dependencies, all of them can be runtimeOnly:

dependencies {
    runtimeOnly "org.jetbrains.kotlin:kotlin-scripting-compiler-embeddable:$kotlinVersion"
    runtimeOnly "org.jetbrains.kotlin:kotlin-compiler-embeddable:$kotlinVersion"
    runtimeOnly "io.arrow-kt:arrow-ank:$arrow_version"
}

After merging #1936 and publishing artifacts, @1Jajen1, dependencies section of build.gradle file from your project could be just:

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
    implementation project(":kotlin-pretty")
    implementation project(":kotlin-pretty-ansi")
}

without arrow-ank, kotlin-scripting-compiler-embeddable and kotlin-compiler-embeddable.

Hi @1Jajen1 , my last comment can be tried because new artifacts have been published. In case everything is working, this issue could be closed :+1: Thanks!!

And it works :clap: Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Northburns picture Northburns  路  4Comments

vejeta picture vejeta  路  3Comments

JorgeCastilloPrz picture JorgeCastilloPrz  路  5Comments

raulraja picture raulraja  路  3Comments

jmfayard picture jmfayard  路  4Comments