Skip to content

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ jobs:
with:
name: npm-package
path: ./release-npm-package
- run: brew unlink node@12
- run: brew install node
- run: ./ci/steps/release-packages.sh
env:
# Otherwise we get rate limited when fetching the ripgrep binary.
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ release-packages/
release-gcp/
release-images/
node_modules
node-*
21 changes: 0 additions & 21 deletions ci/build/build-standalone-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ main() {
mkdir -p "$RELEASE_PATH/bin"
rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server"
rsync "$node_path" "$RELEASE_PATH/lib/node"
if [[ $OS == "linux" ]]; then
bundle_dynamic_lib libstdc++
bundle_dynamic_lib libgcc_s
elif [[ $OS == "macos" ]]; then
bundle_dynamic_lib libicui18n
bundle_dynamic_lib libicuuc
bundle_dynamic_lib libicudata
fi

ln -s "./bin/code-server" "$RELEASE_PATH/code-server"
ln -s "./lib/node" "$RELEASE_PATH/node"
Expand All @@ -33,17 +25,4 @@ main() {
yarn --production --frozen-lockfile
}

bundle_dynamic_lib() {
local lib_name="$1"
local lib_path

if [[ $OS == "linux" ]]; then
lib_path="$(ldd "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $3 }')"
elif [[ $OS == "macos" ]]; then
lib_path="$(otool -L "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $1 }')"
fi

cp "$lib_path" "$RELEASE_PATH/lib"
}

main "$@"
46 changes: 28 additions & 18 deletions ci/build/code-server.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
#!/bin/sh
set -eu

# This script is intended to be bundled into the standalone releases.
# Runs code-server with the bundled node binary.

# More complicated than readlink -f or realpath to support macOS.
# See https://github.com/cdr/code-server/issues/1537
bin_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.
pwd -P || exit 1
_realpath() {
if [ "$(uname)" = "Linux" ]; then
readlink -f "$1"
return
fi

# See https://github.com/cdr/code-server/issues/1537
if [ "$(uname)" = "Darwin" ]; then
# We read the symlink, which may be relative from $1.
script="$1"
if [ -L "$script" ]; then
while [ -L "$script" ]; do
script="$(readlink "$script")"
cd "$(dirname "$script")"
done
else
cd "$(dirname "$script")"
fi

echo "$PWD/$(basename "$script")"
return
fi

echo "Unsupported OS $(uname)" >&2
exit 1
}

BIN_DIR=$(bin_dir)
if [ "$(uname)" = "Linux" ]; then
export LD_LIBRARY_PATH="$BIN_DIR/../lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}"
elif [ "$(uname)" = "Darwin" ]; then
export DYLD_LIBRARY_PATH="$BIN_DIR/../lib${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}"
fi
exec "$BIN_DIR/../lib/node" "$BIN_DIR/.." "$@"
ROOT="$(dirname "$(dirname "$(_realpath "$0")")")"
exec "$ROOT/lib/node" "$ROOT" "$@"
2 changes: 1 addition & 1 deletion ci/container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN ARCH="$(dpkg --print-architecture)" && \
# rm -R shellcheck*

# Install Go dependencies
RUN ARCH="$(dpkg --print-architecture)" && \
RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \
curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz
ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH
ENV GO111MODULE=on
Expand Down
22 changes: 22 additions & 0 deletions ci/container/centos/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM centos:7

RUN curl -sL https://rpm.nodesource.com/setup_14.x | bash - && \
yum install -y nodejs &&
npm install -g yarn

RUN yum groupinstall -y 'Development Tools'
RUN yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel

RUN npm config set python python2

RUN yum install -y epel-release && yum install -y jq
RUN yum install -y rsync

# Copied from ../Dockerfile
# Install Go dependencies
RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \
curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz
ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH
ENV GO111MODULE=on
RUN go get mvdan.cc/sh/v3/cmd/shfmt
RUN go get github.com/goreleaser/nfpm/cmd/nfpm
5 changes: 5 additions & 0 deletions ci/steps/release-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ set -euo pipefail
main() {
cd "$(dirname "$0")/../.."

if [[ "$OSTYPE" == darwin* ]]; then
curl -L https://nodejs.org/dist/v14.4.0/node-v14.4.0-darwin-x64.tar.gz | tar -xz
PATH="$PATH:node-v14.4.0-darwin-x64/bin"
fi

# https://github.com/actions/upload-artifact/issues/38
tar -xzf release-npm-package/package.tar.gz

Expand Down
5 changes: 3 additions & 2 deletions doc/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ However, it is not entirely equivalent to Microsoft's VS Code.

While the core of VS Code is open source, the marketplace and many published Microsoft extensions are not.

Not only are they closed source, Microsoft prohibits the use of any non-Microsoft VS Code from accessing their marketplace.
Furthermore, Microsoft prohibits the use of any non-Microsoft VS Code from accessing their marketplace.

See the [TOS](https://cdn.vsassets.io/v/M146_20190123.39/_content/Microsoft-Visual-Studio-Marketplace-Terms-of-Use.pdf).

> Marketplace Offerings are intended for use only with Visual Studio Products and Services
> and you may only install and use Marketplace Offerings with Visual Studio Products and Services.

As a result, we have created our own marketplace for open source extensions.
As a result, we cannot offer any extensions on the Microsoft marketplace. Instead,
we have created our own marketplace for open source extensions.
It works by scraping GitHub for VS Code extensions and building them. It's not perfect but getting
better by the day with more and more extensions.

Expand Down
2 changes: 1 addition & 1 deletion doc/npm.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sudo apt-get install -y \

```bash
sudo yum groupinstall -y 'Development Tools'
sudo yum config-manager --set-enabled PowerTools
sudo yum config-manager --set-enabled PowerTools # unnecessary on CentOS 7
sudo yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel
npm config set python python2
```
Expand Down
19 changes: 9 additions & 10 deletions src/node/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -127,18 +123,21 @@ const main = async (cliArgs: Args): Promise<void> => {
}

async function entry(): Promise<void> {
const tryParse = async (): Promise<Args> => {
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("")
Expand Down Expand Up @@ -182,7 +181,7 @@ async function entry(): Promise<void> {
})
vscode.on("exit", (code) => process.exit(code || 0))
} else {
wrap(() => main(args))
wrap(() => main(args, cliArgs, configArgs))
}
}

Expand Down