Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1diff --git c/scripts/launch.sh w/scripts/launch.sh 2index 21afbb1e..8bc5c382 100755 3--- c/scripts/launch.sh 4+++ w/scripts/launch.sh 5@@ -1,125 +1,4 @@ 6-#!/bin/sh 7-# Actual launcher. This does the hard work of figuring out the best way 8-# to launch the language server or the debug adapter. 9- 10-# Running this script is a one-time action per project launch, so we opt for 11-# code simplicity instead of performance. Hence some potentially redundant 12-# moves here. 13- 14- 15-did_relaunch=$1 16- 17-# Get the user's preferred shell 18-preferred_shell=$(basename "$SHELL") 19- 20-# Get current dirname 21-dirname=$(dirname "$0") 22- 23-case "${did_relaunch}" in 24- "") 25- if [ "$preferred_shell" = "bash" ]; then 26- >&2 echo "Preferred shell is bash, relaunching" 27- exec "$(which bash)" "$0" relaunch 28- elif [ "$preferred_shell" = "zsh" ]; then 29- >&2 echo "Preferred shell is zsh, relaunching" 30- exec "$(which zsh)" "$0" relaunch 31- elif [ "$preferred_shell" = "fish" ]; then 32- >&2 echo "Preferred shell is fish, launching launch.fish" 33- exec "$(which fish)" "$dirname/launch.fish" 34- else 35- >&2 echo "Preferred shell $preferred_shell is not supported, continuing in POSIX shell" 36- fi 37- ;; 38- *) 39- # We have an arg2, so we got relaunched 40- ;; 41-esac 42- 43-# First order of business, see whether we can setup asdf 44-echo "Looking for asdf install" >&2 45- 46-readlink_f () { 47- cd "$(dirname "$1")" > /dev/null || exit 1 48- filename="$(basename "$1")" 49- if [ -h "$filename" ]; then 50- readlink_f "$(readlink "$filename")" 51- else 52- echo "$(pwd -P)/$filename" 53- fi 54-} 55- 56-export_stdlib_path () { 57- which_elixir_expr=$1 58- stdlib_path=$(eval "$which_elixir_expr") 59- stdlib_real_path=$(readlink_f "$stdlib_path") 60- ELX_STDLIB_PATH=$(echo "$stdlib_real_path" | sed "s/\(.*\)\/bin\/elixir/\1/") 61- export ELX_STDLIB_PATH 62-} 63- 64-# Check if we have the asdf binary for version >= 0.16.0 65-if command -v asdf >/dev/null 2>&1; then 66- asdf_version=$(asdf --version 2>/dev/null) 67- version=$(echo "$asdf_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+') 68- major=$(echo "$version" | cut -d. -f1) 69- minor=$(echo "$version" | cut -d. -f2) 70- # If the version is less than 0.16.0 (i.e. major = 0 and minor < 16), use legacy method. 71- if [ "$major" -eq 0 ] && [ "$minor" -lt 16 ]; then 72- ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"} 73- ASDF_SH="${ASDF_DIR}/asdf.sh" 74- if test -f "$ASDF_SH"; then 75- >&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing" 76- # Source the old asdf.sh script for versions <= 0.15.0 77- . "$ASDF_SH" 78- else 79- >&2 echo "Legacy asdf not found at $ASDF_SH" 80- fi 81- else 82- >&2 echo "asdf executable found at $(command -v asdf). Using ASDF_DIR=${ASDF_DIR}, ASDF_DATA_DIR=${ASDF_DATA_DIR}." 83- fi 84- export_stdlib_path "asdf which elixir" 85-else 86- # Fallback to old method for version <= 0.15.x 87- ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"} 88- ASDF_SH="${ASDF_DIR}/asdf.sh" 89- if test -f "$ASDF_SH"; then 90- >&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing" 91- # Source the old asdf.sh script for versions <= 0.15.0 92- . "$ASDF_SH" 93- export_stdlib_path "asdf which elixir" 94- else 95- >&2 echo "asdf not found" 96- >&2 echo "Looking for mise executable" 97- 98- # Look for mise executable 99- if command -v mise >/dev/null 2>&1; then 100- >&2 echo "mise executable found at $(command -v mise), activating" 101- eval "$($(command -v mise) env -s "$preferred_shell")" 102- export_stdlib_path "mise which elixir" 103- else 104- >&2 echo "mise not found" 105- >&2 echo "Looking for rtx executable" 106- 107- # Look for rtx executable 108- if command -v rtx >/dev/null 2>&1; then 109- >&2 echo "rtx executable found at $(command -v rtx), activating" 110- eval "$($(command -v rtx) env -s "$preferred_shell")" 111- export_stdlib_path "rtx which elixir" 112- else 113- >&2 echo "rtx not found" 114- >&2 echo "Looking for vfox executable" 115- 116- # Look for vfox executable 117- if command -v vfox >/dev/null 2>&1; then 118- >&2 echo "vfox executable found at $(command -v vfox), activating" 119- eval "$($(command -v vfox) activate "$preferred_shell")" 120- else 121- >&2 echo "vfox not found" 122- export_stdlib_path "which elixir" 123- fi 124- fi 125- fi 126- fi 127-fi 128+#!/usr/bin/env bash 129 130 # In case that people want to tweak the path, which Elixir to use, or 131 # whatever prior to launching the language server or the debug adapter, we 132@@ -138,29 +17,22 @@ fi 133 # script so we can correctly configure the Erlang library path to 134 # include the local .ez files, and then do what we were asked to do. 135 136-if [ -z "${ELS_INSTALL_PREFIX}" ]; then 137- SCRIPT=$(readlink_f "$0") 138- SCRIPTPATH=$(dirname "$SCRIPT") 139-else 140- SCRIPTPATH=${ELS_INSTALL_PREFIX} 141-fi 142+SCRIPT=$(readlink -f "$0") 143+SCRIPTPATH=$(dirname "$SCRIPT")/../scripts 144 145 export MIX_ENV=prod 146 # Mix.install prints to stdout and reads from stdin 147 # we need to make sure it doesn't interfere with LSP/DAP 148-echo "" | elixir "$SCRIPTPATH/quiet_install.exs" >/dev/null || exit 1 149+echo "" | @elixir@/bin/elixir "$SCRIPTPATH/quiet_install.exs" >/dev/null || exit 1 150 151 default_erl_opts="-kernel standard_io_encoding latin1 +sbwt none +sbwtdcpu none +sbwtdio none" 152 153-if [ "$preferred_shell" = "bash" ]; then 154- source "$dirname/exec.bash" 155-elif [ "$preferred_shell" = "zsh" ]; then 156- source "$dirname/exec.zsh" 157-else 158- if [ -z "$ELS_ELIXIR_OPTS" ] 159- then 160- # in posix shell does not support arrays 161- >&2 echo "ELS_ELIXIR_OPTS is not supported in current shell" 162- fi 163- exec elixir --erl "$default_erl_opts $ELS_ERL_OPTS" "$SCRIPTPATH/launch.exs" 164-fi 165+# ensure elixir stdlib can be found 166+ELX_STDLIB_PATH=${ELX_STDLIB_PATH:-@elixir@/lib/elixir} 167+export ELX_STDLIB_PATH 168+ 169+# ensure our elixir is in the path 170+PATH="@elixir@/bin:$PATH" 171+export PATH 172+ 173+source "$SCRIPTPATH/exec.bash"