Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bsp: getMillBuildClasspath return URI string #1325

Merged
merged 5 commits into from
May 19, 2021

Conversation

camper42
Copy link
Contributor

getMillBuildClasspath is expect to return URI, otherwise IDEA bsp import will have
java.lang.IllegalArgumentException: Missing scheme error on MacOS and
Java.net.URISyntaxException: Illegal character in opaque part at index 2: ... on Windows

getMillBuildClasspath is expect to return URI, otherwise IDEA bsp import will have
`java.lang.IllegalArgumentException: Missing scheme` error on MacOS and
`Java.net.URISyntaxException: Illegal character in opaque part at index 2: ...` on Windows
@camper42
Copy link
Contributor Author

problem I mentioned at #1285 (comment)
seems caused by https://github.com/com-lihaoyi/mill/pull/1285/files#diff-a8dcb229dc6fe3ad91d4667a94174520d2d13cf522738fed08023105ac955d00R165

Path.wrapped return java.nio.file.Path and toUri is missing

@lefou @ScalaWilliam pls review

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it seems this code isn't covered by any tests, I'd like to have at least one written "It works for me" from someone who really tested this locally, for each platform.

@@ -162,7 +162,7 @@ object ModuleUtils {
val binarySource =
if (sources) all.filter(url => isPathSourceJar(url))
else all.filter(url => !isPathSourceJar(url))
binarySource.filter(path => exists(path)).map(_.wrapped.toString)
binarySource.filter(path => exists(path)).map(_.toNIO.toUri.toString)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why we don't use a better return type here. At least, we should add some Scaladoc to line 126 to make it clear, that the returned Strings are meant to be URIs.

@camper42
Copy link
Contributor Author

As it seems this code isn't covered by any tests, I'd like to have at least one written "It works for me" from someone who really tested this locally, for each platform.

will try to add an ut for at least getMillBuildClasspath first, If it seems to take a long time to do, I'm happy to write "It works for me" to get this fix merged.

@ScalaWilliam
Copy link
Contributor

My apologies, I did not get a chance to test this.

@camper42
Copy link
Contributor Author

hmmm,getMillBuildClasspath on TestEvaluator.static(TestModule).evaluator return empty list
so test always pass....

@camper42
Copy link
Contributor Author

getMillBuildClasspath on TestEvaluator.static(TestModule).evaluator return empty list

test is running on a version like 0.9.7-4-c85970-DIRTY55902d6c, which can't access before ci/publish-local.sh, so:

  • classpath in getMillBuildClasspath is empty due to Try(evaluator.rootModule.getClass.getClassLoader.asInstanceOf[SpecialClassLoader]) failed
  • millJars in getMillBuildClasspath is empty due to Resolution failed

It's impossiable to test, choose to leave a "It works for me on MacOS IDEA" comment...

@camper42
Copy link
Contributor Author

also worked for my Windows IDEA

test-windows (8, cmd /C %GITHUB_WORKSPACE%\ci\mill.bat -i -d -k "{main,scalajslib,bsp}.__.test") failure can be ignored?
nothing change about mill.scalajslib

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI failure is some flakiness in GitHub Actions, I reran the tests, which are now green.

I think the test issue(s) can be solved by propagating the freshly built jars into the test setup via forkEnv and/or forkArgs. We do this in other integration tests and it works. But I think it's too much to ask for in a bug fix PR and your "works for me" is better than what we have currently. We have lots of open building sites in our BSP story, and integration testing is a central part of it.

Your technical change looks good to me, but the Scaladoc needs to be moved before the start of the def on line 126, not inside the def. Otherwise, we're good to merge.

@fabianhjr
Copy link
Contributor

fabianhjr commented May 19, 2021

Had same issue on Linux (NixOS), ( java.lang.IllegalArgumentException: Missing scheme)

Tested this PR by:

  1. Checking out this repo
  2. Checking out 0.9.7
  3. Cherrypicking this change
  4. Retagging 0.9.7 to include this change
  5. hand modifying a local project .bsp/mill.json to point to a symbolic link to the run script (/home/fabian/.local/bin/mill-checkout -> /home/fabian/Development/Open/mill/out/dev/launcher/dest/run)
  6. Restarting IntelliJ IDEA

This did fix the error and I was able to import the project again; local retagging was to avoid attempting to fetch nonexistant versions of mill-contrib-{bloop, scoverage} (0.9.7-[n]-[local commit that isn't available elsewhere])

@camper42
Copy link
Contributor Author

@fabianhjr would you mind if I add "works for @fabianhjr on Linux(NixOS)" ?

@fabianhjr
Copy link
Contributor

Not at all, go ahead.

Many thanks for the diagnosis and fix of this issue! UwU

@lefou lefou merged commit dc1cea1 into com-lihaoyi:main May 19, 2021
@lefou
Copy link
Member

lefou commented May 19, 2021

Thanks you!

@lefou lefou added this to the after 0.9.7 milestone May 19, 2021
@camper42 camper42 deleted the fix-bsp-getMillBuildClasspath branch May 19, 2021 16:40
@sequencer
Copy link
Contributor

When can we get this patch in a new version like 0.9.8? Since 0.9.7 of mill+bsp+IDEA is totally broken since this issue.

@lefou
Copy link
Member

lefou commented May 24, 2021

You can start to use it right away. Just pick the latest snapshot-build version from https://github.com/com-lihaoyi/mill/releases (e.g. 0.9.7-13-bf96a1) and put it into .mill-version in your project top directory. See https://com-lihaoyi.github.io/mill/mill/Intro_to_Mill.html#_overriding_mill_versions

@lefou
Copy link
Member

lefou commented May 24, 2021

I'd like to get some other fixes into main branch before the next tag.

@sequencer
Copy link
Contributor

Got it! Thank you!
I'll use 0.9.7-13-bf96a1 fix this temporarily, since I'm using mill package from Arch Linux.

@sequencer
Copy link
Contributor

opps, seems that package from Arch Linux doesn't honor 0.9.7-13-bf96a1

@lefou lefou linked an issue May 25, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Illegal character in URI using BSP
5 participants