Trim LD_LIBRARY_PATH on startup
This commit is contained in:
parent
9a3b9fcac2
commit
7ab47b3d83
@ -5,21 +5,22 @@
|
||||
|
||||
# More complicated than readlink -f or realpath to support macOS.
|
||||
# See https://github.com/cdr/code-server/issues/1537
|
||||
bin_dir() {
|
||||
root_dir() {
|
||||
# We read the symlink, which may be relative from $0.
|
||||
dst="$(readlink "$0")"
|
||||
# We cd into the $0 directory.
|
||||
cd "$(dirname "$0")" || exit 1
|
||||
# Now we can cd into the dst directory.
|
||||
cd "$(dirname "$dst")" || exit 1
|
||||
# Finally we use pwd -P to print the absolute path of the directory of $dst.
|
||||
# Now we can cd into the directory above the dst directory which is the root
|
||||
# of the release.
|
||||
cd "$(dirname "$dst")/.." || exit 1
|
||||
# Finally we use pwd -P to print the absolute path the root.
|
||||
pwd -P || exit 1
|
||||
}
|
||||
|
||||
BIN_DIR=$(bin_dir)
|
||||
ROOT="$(root_dir)"
|
||||
if [ "$(uname)" = "Linux" ]; then
|
||||
export LD_LIBRARY_PATH="$BIN_DIR/../lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}"
|
||||
export LD_LIBRARY_PATH="$ROOT/lib:$LD_LIBRARY_PATH"
|
||||
elif [ "$(uname)" = "Darwin" ]; then
|
||||
export DYLD_LIBRARY_PATH="$BIN_DIR/../lib${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}"
|
||||
export DYLD_LIBRARY_PATH="$ROOT/lib:$DYLD_LIBRARY_PATH"
|
||||
fi
|
||||
exec "$BIN_DIR/../lib/node" "$BIN_DIR/.." "$@"
|
||||
exec "$ROOT/lib/node" "$ROOT" "$@"
|
||||
|
@ -126,7 +126,25 @@ const main = async (cliArgs: Args): Promise<void> => {
|
||||
}
|
||||
}
|
||||
|
||||
function trimLDLibraryPath(): void {
|
||||
let ldVar: string
|
||||
if (process.platform === "linux") {
|
||||
ldVar = "LD_LIBRARY_PATH"
|
||||
} else if (process.platform === "darwin") {
|
||||
ldVar = "DYLD_LIBRARY_PATH"
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
||||
// Removes the leading path added by ./ci/build/code-server.sh to use our bundled
|
||||
// dynamic libraries. See ci/build/build-standalone-release.sh
|
||||
// This is required to avoid child processes using our bundled libraries.
|
||||
process.env[ldVar] = process.env[ldVar]?.replace(path.dirname(process.execPath) + ":", "")
|
||||
}
|
||||
|
||||
async function entry(): Promise<void> {
|
||||
trimLDLibraryPath()
|
||||
|
||||
const tryParse = async (): Promise<Args> => {
|
||||
try {
|
||||
let args = parse(process.argv.slice(2))
|
||||
|
Loading…
Reference in New Issue
Block a user