Skip to content

Commit

Permalink
Use LnBinary instead of hardcoded /bin/ln in jvm.sh (#21488)
Browse files Browse the repository at this point in the history
Fixes #21487
  • Loading branch information
grihabor authored Oct 5, 2024
1 parent 6cca0c4 commit 727819f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/notes/2.24.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Compression of class files into a jar file is not reading or writing from the re

Fixed a coursier fetch wrapper script bug on nixos.

Fixed a jvm.sh script bug on nixos.

#### Kotlin

The kotlin linter, [ktlint](https://pinterest.github.io/ktlint/), has been updated to version 1.3.1.
Expand Down
6 changes: 4 additions & 2 deletions src/python/pants/jvm/jdk_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing import ClassVar, Iterable, Mapping

from pants.core.util_rules.environments import EnvironmentTarget
from pants.core.util_rules.system_binaries import BashBinary
from pants.core.util_rules.system_binaries import BashBinary, LnBinary
from pants.engine.fs import CreateDigest, Digest, FileContent, FileDigest, MergeDigests
from pants.engine.internals.selectors import Get
from pants.engine.process import FallibleProcessResult, Process, ProcessCacheScope
Expand Down Expand Up @@ -201,6 +201,7 @@ async def prepare_jdk_environment(
coursier: Coursier,
nailgun_: Nailgun,
bash: BashBinary,
ln: LnBinary,
request: JdkRequest,
env_target: EnvironmentTarget,
) -> JdkEnvironment:
Expand Down Expand Up @@ -276,13 +277,14 @@ def prefixed(arg: str) -> str:

# TODO: Locate `ln`.
version_comment = "\n".join(f"# {line}" for line in java_version.splitlines())
ln_path = shlex.quote(ln.path)
jdk_preparation_script = textwrap.dedent( # noqa: PNT20
f"""\
# pants javac script using Coursier {coursier_jdk_option}. `java -version`:"
{version_comment}
set -eu
/bin/ln -s "$({java_home_command})" "${{PANTS_INTERNAL_ABSOLUTE_PREFIX}}{JdkEnvironment.java_home}"
{ln_path} -s "$({java_home_command})" "${{PANTS_INTERNAL_ABSOLUTE_PREFIX}}{JdkEnvironment.java_home}"
exec "$@"
"""
)
Expand Down

0 comments on commit 727819f

Please sign in to comment.