sigven / pcgr

Personal Cancer Genome Reporter (PCGR)
https://sigven.github.io/pcgr
MIT License
251 stars 47 forks source link

run PCGR as non-root user fails at quarto #246

Closed HomoPolyethylen closed 1 month ago

HomoPolyethylen commented 1 month ago

Whenever you encounter an error, please also include:

running the pcgr v2.0.1 docker container on the example vcf file T001-BRCA.grch37.vcf.gz with assembly GRCh37 fails, if the container is run as the executing user (providing -u $(id -u):$(id -g) to the docker command. If I leave out the -u option, pcgr runs through smoothly. quarto seems to need root-permissions

command

I first started the docker container in interactive mode ``` docker run -it --rm \ -v /home-link/zxmgc83/tools/pcgr/examples:/mnt/data \ -v /home-link/zxmgc83/tools/pcgr/refbundle/20240621:/mnt/refdata \ -v /home-link/zxmgc83/.vep:/mnt/vep \ -v /home-link/zxmgc83/runs/pcgr/pcgr2/results:/mnt/output \ -u $(id -u):$(id -g) # remove this line and pcgr/quarto runs through sigven/pcgr:2.0.1 ``` and then executed pcgr ``` pcgr \ --input_vcf /mnt/data/tumor_sample.BRCA.vcf.gz \ --refdata_dir /mnt/refdata \ --vep_dir /mnt/vep \ --output_dir /mnt/output \ --genome_assembly grch37 \ --sample_id pcgr-test-sample \ --assay TARGETED \ --tumor_site 8 ```

error message

``` 2024-06-30 10:51:58 - pcgr-writer - INFO - PCGR - STEP 6: Generation of output files - molecular interpretation report for precision cancer medicine 2024-06-30 10:51:59 - pcgr-report-generation - INFO - Successfully parsed YAML configuration file - reporting mode: PCGR 2024-06-30 10:51:59 - pcgr-report-generation - INFO - Loading reference datasets - genome assembly: grch37 2024-06-30 10:52:25 - pcgr-report-generation - INFO - ------ 2024-06-30 10:52:25 - pcgr-report-generation - INFO - Reading annotated molecular dataset (DNA) - somatic SNV/InDels 2024-06-30 10:52:26 - pcgr-report-generation - INFO - Assigning variants to tiers of clinical significance - somatic actionability guidelines (ACMG/AMP) 2024-06-30 10:52:26 - pcgr-report-generation - INFO - Generating data frame with hyperlinked variant/gene annotations 2024-06-30 10:52:27 - pcgr-report-generation - INFO - ------ 2024-06-30 10:52:27 - pcgr-report-generation - INFO - Generating quarto-based interactive HTML report (.html) with variant findings [0m[1m[31merror[0m: Uncaught PermissionDenied: Permission denied (os error 13): mkdir '/.cache/quarto' Deno.mkdirSync(dir, { [0m[31m ^[0m at [0m[1m[3mObject.mkdirSync[0m ([0m[36mext:deno_fs/30_fs.js[0m:[0m[33m132[0m:[0m[33m7[0m) at [0m[1m[3mensureDirSync[0m ([0m[36mfile:///opt/mambaforge/envs/pcgrr/bin/quarto.js[0m:[0m[33m9288[0m:[0m[33m14[0m) at [0m[1m[3mquartoDir[0m ([0m[36mfile:///opt/mambaforge/envs/pcgrr/bin/quarto.js[0m:[0m[33m33006[0m:[0m[33m5[0m) at [0m[1m[3mquartoCacheDir[0m ([0m[36mfile:///opt/mambaforge/envs/pcgrr/bin/quarto.js[0m:[0m[33m32998[0m:[0m[33m12[0m) at [0m[36mfile:///opt/mambaforge/envs/pcgrr/bin/quarto.js[0m:[0m[33m39501[0m:[0m[33m25[0m Error in `quarto::quarto_render()`: ✖ Error running quarto cli. ℹ Rerun with `quiet = FALSE` to see the full error message. Caused by error: ! System command 'quarto' failed Backtrace: ▆ 1. └─pcgrr::write_report_quarto_html(report = pcg_report) 2. └─quarto::quarto_render(...) 3. └─quarto:::quarto_run(args, echo = TRUE, quarto_bin = quarto_bin) 4. └─base::tryCatch(...) 5. └─base (local) tryCatchList(expr, classes, parentenv, handlers) 6. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]]) 7. └─value[[3L]](cond) 8. └─cli::cli_abort(msg, call = .call, parent = e) 9. └─rlang::abort(...) ```

Additional context

I could replicate this issue with other samples. I am not sure whether execution as non-root is intended or not and hence if this is a bug or a feature request.

running on Linux 5.14.0

I want to run pcgr on a server, where I do not have root-privileges. If I run docker without -u, the pcgr output files are written by root and I hence cannot remove them. If I run docker with -u, the user witin the container does not have the rights to create a directory in the root dir (mkdir /.cache/quarto)

pdiakumis commented 1 month ago

Hi @HomoPolyethylen, Thanks for the excellent reporting and apologies you're having a hard time getting PCGR to work as you'd like. I'll have a closer look at this Docker issue next week when I find some time - we have definitely encountered issues with quarto permissions which we have successfully overcome (so far) by exporting several required environment variables. Have you given the PCGR conda installation a try (https://sigven.github.io/pcgr/articles/installation.html#a--conda)? It might work better than Docker for your Linux setup. Cheers, Peter

sigven commented 1 month ago

Hi Niclas,

Thanks for reporting this, and sorry that it's not working at the moment in the current version. I see it as an enhancement/feature request :-) Just to follow up on Peter's remarks: in addition to the Conda installation, which we recommend, we have worked hard to support also Singularity/Apptainer in the latest version, have you tried that? We have had several requests for this, as many now tend to use this as their preferred container framework in HPC/server environments (rather than Docker, which, as you have figured out, typically runs in root mode).

best, Sigve

HomoPolyethylen commented 1 month ago

Thanks a lot for your fast responses! With your help, I could get it to run. Key was the XDG_CACHE_HOME env variable, that I did previously not find at quarto.

should anybody else encounter this issue: set the abovementioned environment variable in the docker/singularity call (both use --env) as described in the pcgr docs: singularity

--env "XDG_CACHE_HOME=/tmp/quarto_cache_home"
pdiakumis commented 1 month ago

Nice one, thanks for providing the solution - I did notice some related issues on the quarto repo messing with XDG_* env vars, good to know!