File tree Expand file tree Collapse file tree 2 files changed +27
-8
lines changed Expand file tree Collapse file tree 2 files changed +27
-8
lines changed Original file line number Diff line number Diff line change 55
66# More complicated than readlink -f or realpath to support macOS.
77# See https://github.com/cdr/code-server/issues/1537
8- bin_dir () {
8+ root_dir () {
99 # We read the symlink, which may be relative from $0.
1010 dst=" $( readlink " $0 " ) "
1111 # We cd into the $0 directory.
1212 cd " $( dirname " $0 " ) " || exit 1
13- # Now we can cd into the dst directory.
14- cd " $( dirname " $dst " ) " || exit 1
15- # Finally we use pwd -P to print the absolute path of the directory of $dst.
13+ # Now we can cd into the directory above the dst directory which is the root
14+ # of the release.
15+ cd " $( dirname " $dst " ) /.." || exit 1
16+ # Finally we use pwd -P to print the absolute path the root.
1617 pwd -P || exit 1
1718}
1819
19- BIN_DIR= $( bin_dir )
20+ ROOT= " $( root_dir ) "
2021if [ " $( uname) " = " Linux" ]; then
21- export LD_LIBRARY_PATH=" $BIN_DIR /../ lib${LD_LIBRARY_PATH+ : $LD_LIBRARY_PATH } "
22+ export LD_LIBRARY_PATH=" $ROOT / lib:$LD_LIBRARY_PATH "
2223elif [ " $( uname) " = " Darwin" ]; then
23- export DYLD_LIBRARY_PATH=" $BIN_DIR /../ lib${DYLD_LIBRARY_PATH+ : $DYLD_LIBRARY_PATH } "
24+ export DYLD_LIBRARY_PATH=" $ROOT / lib:$DYLD_LIBRARY_PATH "
2425fi
25- exec " $BIN_DIR /../ lib/node" " $BIN_DIR /.. " " $@ "
26+ exec " $ROOT / lib/node" " $ROOT " " $@ "
Original file line number Diff line number Diff line change @@ -126,7 +126,25 @@ const main = async (cliArgs: Args): Promise<void> => {
126126 }
127127}
128128
129+ function trimLDLibraryPath ( ) : void {
130+ let ldVar : string
131+ if ( process . platform === "linux" ) {
132+ ldVar = "LD_LIBRARY_PATH"
133+ } else if ( process . platform === "darwin" ) {
134+ ldVar = "DYLD_LIBRARY_PATH"
135+ } else {
136+ return
137+ }
138+
139+ // Removes the leading path added by ./ci/build/code-server.sh to use our bundled
140+ // dynamic libraries. See ci/build/build-standalone-release.sh
141+ // This is required to avoid child processes using our bundled libraries.
142+ process . env [ ldVar ] = process . env [ ldVar ] ?. replace ( path . dirname ( process . execPath ) + ":" , "" )
143+ }
144+
129145async function entry ( ) : Promise < void > {
146+ trimLDLibraryPath ( )
147+
130148 const tryParse = async ( ) : Promise < Args > => {
131149 try {
132150 let args = parse ( process . argv . slice ( 2 ) )
You can’t perform that action at this time.
0 commit comments