-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Trim LD_LIBRARY_PATH on startup #1740
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 2 commits
662a256
040eeeb
28d9872
7dc93dc
a1702b7
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 |
---|---|---|
|
@@ -31,11 +31,7 @@ try { | |
const version = pkg.version || "development" | ||
const commit = pkg.commit || "development" | ||
|
||
const main = async (cliArgs: Args): Promise<void> => { | ||
const configArgs = await readConfigFile(cliArgs.config) | ||
// This prioritizes the flags set in args over the ones in the config file. | ||
let args = Object.assign(configArgs, cliArgs) | ||
|
||
const main = async (args: Args, cliArgs: Args, configArgs: Args): Promise<void> => { | ||
if (!args.auth) { | ||
args = { | ||
...args, | ||
|
@@ -126,19 +122,40 @@ 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) + ":", "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure that
if you see any output it is still pointing at code server then it might not have taken. I think you might need to do something like AppImage where they rewrite the linker path for the binary to their library paths, that way you will not pollute downstream. I am not sure if this https://medium.com/@nehckl0/creating-relocatable-linux-executables-by-setting-rpath-with-origin-45de573a2e98 is feasible. That might be the best hope since you can put that in the installer when the location is selected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I built off this PR and can confirm there's no output for that command whereas there was before. |
||
} | ||
|
||
async function entry(): Promise<void> { | ||
const tryParse = async (): Promise<Args> => { | ||
trimLDLibraryPath() | ||
|
||
const tryParse = async (): Promise<[Args, Args, Args]> => { | ||
try { | ||
let args = parse(process.argv.slice(2)) | ||
const cliArgs = parse(process.argv.slice(2)) | ||
const configArgs = await readConfigFile(cliArgs.config) | ||
// This prioritizes the flags set in args over the ones in the config file. | ||
let args = Object.assign(configArgs, cliArgs) | ||
args = await setDefaults(args) | ||
return args | ||
return [args, cliArgs, configArgs] | ||
} catch (error) { | ||
console.error(error.message) | ||
process.exit(1) | ||
} | ||
} | ||
|
||
const args = await tryParse() | ||
const [args, cliArgs, configArgs] = await tryParse() | ||
if (args.help) { | ||
console.log("code-server", version, commit) | ||
console.log("") | ||
|
@@ -182,7 +199,7 @@ async function entry(): Promise<void> { | |
}) | ||
vscode.on("exit", (code) => process.exit(code || 0)) | ||
} else { | ||
wrap(() => main(args)) | ||
wrap(() => main(args, cliArgs, configArgs)) | ||
} | ||
} | ||
|
||
|
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.
I think we might want to check if the variable exists or something rather than use the platform because
process.platform
returns non-linux
values even ifuname
normally returnsLinux
. https://nodejs.org/api/process.html#process_process_platformThere 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.
Actually that might only be the case for Android. 🤔 The rest seem to match up in terms of
uname
vsprocess.platform
.