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

vscode, devcontainers and docker #1734

Open
rosssaunders opened this issue Jun 11, 2024 · 1 comment
Open

vscode, devcontainers and docker #1734

rosssaunders opened this issue Jun 11, 2024 · 1 comment

Comments

@rosssaunders
Copy link

rosssaunders commented Jun 11, 2024

Hi,

Does anyone have a working example of developing pgrx based extensions within a docker devcontrainer in vscode?

With the following Docker file


RUN apt-get update && \
    apt-get install -y \
    git \
    curl \
    libclang-dev \
    gcc \
    build-essential \
    libreadline-dev \
    zlib1g-dev \
    flex \
    bison \
    libxml2-dev \
    libxslt-dev \
    libssl-dev \
    libxml2-utils \
    xsltproc \
    ccache \
    pkg-config

# Create a non-root user `developer` and setup sudo
RUN useradd -m -d /home/developer -s /bin/bash developer && \
    echo 'developer ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Create /workspaces folder and give all permissions to the developer account
RUN mkdir /workspaces && chown -R developer:developer /workspaces

# Set the user to developer
USER developer
WORKDIR /home/developer

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Ensure cargo binaries are in PATH
ENV PATH=/home/developer/.cargo/bin:$PATH

# Install pgrx
RUN cargo install cargo-pgrx

and then installing the "rust-analyser" extension, it fails with the following compilation error in the output

  [shim for PG v16] /----------------------------------------

  Error: failed to make pgrx-cshim for v16

  Location:
      /home/developer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pgrx-pg-sys-0.11.4/build.rs:889:20

I must be missing something simple but cannot track down what.

Thanks in advance,

Ross

@workingjubilee
Copy link
Member

workingjubilee commented Aug 14, 2024

Sorry, I don't regularly use these tools ("these" including apt) except for r-a, so I'm guessing wildly. It looks like the makefile failed. That message is from around here:

pgrx/pgrx-pg-sys/build.rs

Lines 875 to 889 in 7dd14f2

let make = env_tracked("MAKE").unwrap_or_else(|| "make".to_string());
let rc = run_command(
Command::new(make)
.arg("clean")
.arg(&format!("libpgrx-cshim-{}.a", major_version))
.env("PG_TARGET_VERSION", format!("{}", major_version))
.env("PATH", path_env)
.env_remove("TARGET")
.env_remove("HOST")
.current_dir(shim_dst),
&format!("shim for PG v{}", major_version),
)?;
if rc.status.code().unwrap() != 0 {
return Err(eyre!("failed to make pgrx-cshim for v{}", major_version));

I would strongly recommend running cargo pgrx init and caching the result in your container's... layers or whatever.

I also recommend updating to pgrx 0.12.0-beta.5 (or whatever I've reached by the time you read this message, hopefully 0.12 proper). I've altered MANY fine-grained build details, so I can't provide further support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants