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

[BUG FIX] Fix path resolution for executables #328

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rasharab
Copy link

@rasharab rasharab commented Jan 16, 2025

There’s an issue with mac silicion+intellij, whereby gradle process executor is not respecting path environment variables.

This gets around that by using a fix for the plugin whereby we attempt to resolve the path manually.

#152

https://youtrack.jetbrains.com/issue/IDEA-334183

We hit this constantly with our development team and this fix resolved it for us.

Copy link
Member

@deepy deepy left a comment

Choose a reason for hiding this comment

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

I've got a hunch of what you're trying to solve, but if you can describe the problem I can give better pointers

* @return The best matching executable path as a String.
*/
fun findBestExecutableMatch(executableName: String): String {
val pathVariable = System.getenv("PATH") ?: return executableName
Copy link
Member

Choose a reason for hiding this comment

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

iirc this won't work on windows where environment variables are case-insensitive (and default to Path)

Copy link
Author

Choose a reason for hiding this comment

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

Easy to fix, thanks.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@@ -43,8 +61,9 @@ fun computeWorkingDir(nodeProjectDir: DirectoryProperty, execConfiguration: Exec
*/
class ExecRunner {
fun execute(projectHelper: ProjectApiHelper, extension: NodeExtension, execConfiguration: ExecConfiguration): ExecResult {
val executablePath = findBestExecutableMatch(execConfiguration.executable)
Copy link
Member

Choose a reason for hiding this comment

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

From a quick glance it looks like this will break the download functionality entirely by only using already installed applications

Copy link
Author

Choose a reason for hiding this comment

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

We will address these points. Thanks.

Copy link
Author

Choose a reason for hiding this comment

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

Done with tests to validate behaviour (w/ download and without download)

@@ -181,6 +182,9 @@ open class NodeExtension(project: Project) {
*/
val resolvedPlatform = project.objects.property<Platform>()


val environment = project.objects.mapProperty<String, String>().convention(System.getenv())
Copy link
Author

@rasharab rasharab Jan 16, 2025

Choose a reason for hiding this comment

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

Primarily for test validation. Welcome other suggestions.

1. Add abiility for tests to override environment behaviour
2. Fix tests.
@rasharab
Copy link
Author

rasharab commented Jan 16, 2025

I've got a hunch of what you're trying to solve, but if you can describe the problem I can give better pointers

Updated comments. I prematurely submitted this pr, apologies.

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.

2 participants