-
Notifications
You must be signed in to change notification settings - Fork 272
fix(amazonq): fix chat on old glibc platforms #5754
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.amazonq.lsp | ||
|
||
import com.intellij.execution.configurations.GeneralCommandLine | ||
import software.aws.toolkits.core.utils.getLogger | ||
import software.aws.toolkits.core.utils.info | ||
import java.nio.file.Path | ||
|
||
/** | ||
* Hacky nonsense to support old glibc platforms like AL2 | ||
* @see "https://github.com/microsoft/vscode/issues/231623" | ||
* @see "https://github.com/aws/aws-toolkit-vscode/commit/6081f890bdbb91fcd8b60c4cc0abb65b15d4a38d" | ||
*/ | ||
object NodeExePatcher { | ||
const val GLIBC_LINKER_VAR = "VSCODE_SERVER_CUSTOM_GLIBC_LINKER" | ||
const val GLIBC_PATH_VAR = "VSCODE_SERVER_CUSTOM_GLIBC_PATH" | ||
|
||
fun patch(node: Path): GeneralCommandLine { | ||
val linker = System.getenv(GLIBC_LINKER_VAR) | ||
val glibc = System.getenv(GLIBC_PATH_VAR) | ||
val nodePath = node.toAbsolutePath().toString() | ||
Check warning on line 23 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/NodeExePatcher.kt
|
||
|
||
return if (!linker.isNullOrEmpty() && !glibc.isNullOrEmpty()) { | ||
GeneralCommandLine(linker) | ||
.withParameters("--library-path", glibc, nodePath) | ||
.also { | ||
getLogger<NodeExePatcher>().info { "Using glibc patch: $it" } | ||
} | ||
Check warning on line 30 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/NodeExePatcher.kt
|
||
} else { | ||
GeneralCommandLine(nodePath) | ||
Check warning on line 32 in plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/lsp/NodeExePatcher.kt
|
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.jetbrains.services.amazonq.lsp | ||
|
||
import com.intellij.execution.configurations.GeneralCommandLine | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import software.aws.toolkits.core.rules.EnvironmentVariableHelper | ||
import kotlin.io.path.Path | ||
|
||
class NodeExePatcherTest { | ||
@get:Rule | ||
val envVarHelper = EnvironmentVariableHelper() | ||
|
||
private val pathToNode = Path("/path/to/node").toAbsolutePath().toString() | ||
|
||
@Test | ||
fun `patches if path available`() { | ||
envVarHelper[NodeExePatcher.GLIBC_LINKER_VAR] = "/opt/vsc-sysroot/lib/ld-linux-x86-64.so.2" | ||
envVarHelper[NodeExePatcher.GLIBC_PATH_VAR] = "/opt/vsc-sysroot/lib/" | ||
|
||
assertThat(NodeExePatcher.patch(Path("/path/to/node"))) | ||
.usingComparator(Comparator.comparing { it.commandLineString }) | ||
.isEqualTo(GeneralCommandLine("/opt/vsc-sysroot/lib/ld-linux-x86-64.so.2", "--library-path", "/opt/vsc-sysroot/lib/", pathToNode)) | ||
} | ||
|
||
@Test | ||
fun `noop if no patch available`() { | ||
assertThat(NodeExePatcher.patch(Path("/path/to/node"))) | ||
.usingComparator(Comparator.comparing { it.commandLineString }) | ||
.isEqualTo(GeneralCommandLine(pathToNode)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will these env vars always exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the patch is available then yes