Skip to content
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

fix: Make lsp work in docker, plus some other install tweaks. #3661

Merged
merged 2 commits into from
Dec 12, 2023
Merged
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
8 changes: 4 additions & 4 deletions aztec-up/bin/.aztec-run
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ VERSION=${VERSION:-"latest"}
DOCKER_HOST_BINDS=""

# Volumes to pass to the container.
DOCKER_VOLUME="-v $HOME:/root"
DOCKER_VOLUME="-v $HOME:$HOME"

# Colors.
y="\033[33m"
Expand All @@ -35,7 +35,7 @@ fi

# Set up host.docker.internal alias on Linux, just like it is on mac.
UNAME=$(uname -s)
if [ "$UNAME" == "Linux" ]; then
if [[ -z "${SKIP_NET:-}" && "$UNAME" == "Linux" ]]; then
if docker info 2>/dev/null | grep -q rootless; then
# We're in rootless docker. Probe for the host ip and use that.
ip=$(hostname -I | head | tr -d ' ')
Expand All @@ -58,7 +58,7 @@ done
# If so, warn and exit.
for i in "${!args[@]}"; do
arg=${args[$i]}
if [[ -f "$arg" || -d "$arg" && $(realpath $arg) != ${HOME}* ]]; then
if [[ -f "$arg" || -d "$arg" ]] && [[ $(realpath $arg) != ${HOME}* ]]; then
warn "Due to how we containerize our applications, paths outside of $HOME cannot be referenced."
exit 1
fi
Expand All @@ -77,7 +77,7 @@ DOCKER_VOLUME="$DOCKER_VOLUME -v cache:/cache"
docker run \
-ti \
--rm \
--workdir "${PWD/$HOME/\/root}" \
--workdir "$PWD" \
$DOCKER_HOST_BINDS \
$DOCKER_ENV \
$DOCKER_VOLUME \
Expand Down
6 changes: 4 additions & 2 deletions aztec-up/bin/aztec-install
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function title() {
if [ "$(uname -s)" == "Darwin" ]; then
echo -e "${y}WARNING: For best performance we recommend adjusting your default docker settings:"
echo -e " - Under general, enable VirtioFS."
echo -e " - Under resources, set CPUs to ~80-100% your maximum."
echo -e " - Under resources, set CPUs to ~80% your maximum."
echo -e " - Under resources, set Memory to ~80% your maximum."
echo -e "You may receive a warning about your home directory being mounted into a container."
echo -e "This is requested so we can read and write project files, that is all."
Expand Down Expand Up @@ -100,6 +100,8 @@ function pull_container {
fi
}

export DOCKER_CLI_HINTS=false

if [ -z "${SKIP_PULL:-}" ]; then
info "Pulling aztec version $VERSION..."
pull_container aztec-sandbox
Expand Down Expand Up @@ -149,7 +151,7 @@ function update_path_env_var {
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
# Add the target directory to the user's PATH in their profile.
echo "export PATH=\$PATH:$TARGET_DIR" >> "$SHELL_PROFILE"
echo "export PATH=\"\$PATH:$TARGET_DIR\"" >> "$SHELL_PROFILE"
info "Done! Starting fresh shell..."
$SHELL
else
Expand Down
35 changes: 22 additions & 13 deletions noir/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions noir/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN ./scripts/bootstrap_native.sh

# When running the container, mount the users home directory to /root
FROM ubuntu:lunar
# Install Tini as nargo doesn't handle signals properly.
RUN apt-get update && apt-get install -y tini && rm -rf /var/lib/apt/lists/* && apt-get clean
COPY --from=0 /usr/src/noir/target/release/nargo /usr/src/noir/target/release/nargo
WORKDIR /root
ENTRYPOINT ["/usr/src/noir/target/release/nargo"]
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/src/noir/target/release/nargo"]
6 changes: 5 additions & 1 deletion noir/scripts/bootstrap_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@ else
fi

# Build native.
cargo build --features="noirc_driver/aztec" --release
if [ -n "${DEBUG:-}" ]; then
cargo build --features="noirc_driver/aztec"
else
cargo build --features="noirc_driver/aztec" --release
fi
5 changes: 3 additions & 2 deletions noir/tooling/nargo_cli/src/cli/lsp_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_lsp::{
client_monitor::ClientProcessMonitorLayer, concurrency::ConcurrencyLayer,
concurrency::ConcurrencyLayer,
panic::CatchUnwindLayer, server::LifecycleLayer, tracing::TracingLayer,
};
use clap::Args;
Expand Down Expand Up @@ -39,10 +39,11 @@ pub(crate) fn run(
.layer(LifecycleLayer::default())
.layer(CatchUnwindLayer::default())
.layer(ConcurrencyLayer::default())
.layer(ClientProcessMonitorLayer::new(client))
.service(router)
});

eprintln!("LSP starting...");

// Prefer truly asynchronous piped stdin/stdout without blocking tasks.
#[cfg(unix)]
let (stdin, stdout) = (
Expand Down