opam list -a lists all packages currently available at OPAM, but does not display the version number for packages which are not currently installed, as per the opam list --help output:
(...) the output format displays one package per line, and each line contains the name of the package, the installed version or -- if the package is not installed, (...)
How can I list all packages including their version numbers?
Use opam info <packagename>.
I guess opam list does only prints the versions of already installed packages because of the package dependencies. Listing the latest versions of packages, for example, of not-yet-installed packages is not quite useful.
A refined (and quicker) version of anol's answer is to give the whole list of packages to opam show in one pass (asking opam to output both package and version field), and to process the result with sed, as apparently show outputs each field on its own line:
opam show -f package,version $(opam list -a -s) \
| sed -e '/ *package:/N; s/ *package: \([^\n]*\)\n *version: \([^\n]*\)/\1: \2/'
This is not an ideal solution, but using camlspotter's recommandation, I manually queried each package for its version field, using the following shell loop:
for p in $(opam list -a -s); do echo "$p $(opam show -f version $p)"; done
It works, but it takes ~85 seconds to complete on my machine (querying over 1000 packages currently available).
Related
I cannot opam init:
$ opam init --verbose
[NOTE] Will configure from built-in defaults.
Checking for available remotes: rsync and local, git, mercurial.
- you won't be able to use darcs repositories unless you install the darcs command on your system.
<><> Fetching repository information ><><><><><><><><><><><><><><><><><><><><><>
[ERROR] Could not update repository "default": OpamDownload.Download_fail(_, "Curl failed: \"/usr/bin/curl --write-out %{http_code}\\\\n --retry 3 --retry-delay 2
--user-agent opam/2.0.7 -L -o /tmp/opam-1697-6d07ae/index.tar.gz.part https://opam.ocaml.org/index.tar.gz\" exited with code 28")
[ERROR] Initial download of repository failed
However, I've manually downloaded index.tar.gz. How to manually specify index.tar.gz to opam init?
System info:
$ uname -a
CYGWIN_NT-10.0-19043 xxx 3.4.5-1.x86_64 2023-01-19 19:09 UTC x86_64 Cygwin
P.S. I'm trying to build one project using OCaml, but it turned out that it is very tricky: either OCaml complains about compatibility (is not a compiled interface for this version of OCaml followed by It seems to be for an older version of OCaml; does it mean that OCaml is not backward compatible?), either opam init fails, either <whatever>.
Your error message indicates that you either have network problems or very poor connection. Also, you opam version is very old, so it might not handle bad networks very well, I would suggest your installing a newer version of opam (at least 2.1.x), or, if it is possible, switching to docker or a virtual machine.
Answering your original question: I don't think there is a way (at least officially supported to specify your own downloaded index). Also, if you have trouble with downloading the index it most likely means that you will have more trouble in the future with your network when opam will start downloading actual packages.
I've installed this compiler before in a docker container, but I don't understand why it's missing right now. Command and error:
(iit_synthesis) brando9~ $ opam switch create ocaml-variants.4.07.1+flambda_coq-serapi.8.11.0+0.11.1 ocaml-variants.4.07.1+flambda
[ERROR] No compiler matching `ocaml-variants.4.07.1+flambda' found, use `opam switch list-available' to see what is available, or use `--packages' to
select packages explicitly.
but it's not in the list:
(iit_synthesis) brando9~ $ opam switch list-available
# Listing available compilers from repositories: default
# Name # Version # Synopsis
ocaml-option-32bit 1 Set OCaml to be compiled in 32-bit mode for 64-bit Linux and OS X hosts
ocaml-option-flambda 1 Set OCaml to be compiled with flambda activated
ocaml-option-nnpchecker 1 Set OCaml to be compiled with --enable-naked-pointers-checker
ocaml-option-spacetime 1 Set OCaml to be compiled with spacetime activated
ocaml-options-vanilla 1 Ensure that OCaml is compiled with no special options enabled
Opam update fails
Output:
$ opam update --all
<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
Processing 1/1: [default: http]
Processing 1/1: [default: http]
[default] synchronised from https://opam.ocaml.org
[ERROR] Could not update repository "default": "~/anaconda/bin/patch -p1 -i /dfs/scratch0/brando9/.opam/log/patch-99014-0624b6" exited with code 2
I probably should have started with this but I installed opam with "manually" with deb because I don't have sudo. In particular I did this:
# - opam (snap, no sudo)
# ref: https://askubuntu.com/questions/339/how-can-i-install-a-package-without-root-access
apt-get download opam
#apt-get download opam_1.2.2-4_amd64
# manually checked the opam name
#ls | less
mkdir -p ~/.local
dpkg -x opam_1.2.2-4_amd64.deb ~/.local/bin
export PATH="$HOME/.local/bin:$PATH"
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc.user
source ~/.bashrc.user
tr ':' '\n' <<< "$PATH"
opam --version
before that I did try installing opam with conda (which has worked in the past) but it failed. I wonder if that screwed things up :/. Will try to reproduce to post the conda error. But I ran conda install -c conda-forge opam.
related:
How to install a specific version of ocaml compiler with opam
https://discuss.ocaml.org/t/why-doesnt-my-server-show-the-ocaml-compiler-that-i-need/10917
https://www.reddit.com/r/ocaml/comments/zed88p/how_does_one_install_a_specific_ocaml_compiler/
How does one install opam without sudo priveledges on linux/ubuntu?
The goal is to compare the list of rpms under folder /tmp/list_of_rpms to installed rpm, and if the package is installed with a lower version then print this rpm.
The approach to check if rpm is installed or not can be easily verified with
rpm -qi gssproxy-0.7.0-30.el7_9.x86_64.rpm
package gssproxy-0.7.0-30.el7_9.x86_64.rpm is not installed
but actually this rpm installed with lower version as
rpm -qa | grep gssproxy
gssproxy-0.7.0-29.el7.x86_64
Can we identify also if rpm is installed with lower version?
The approach to take the installed rpm by rpm -qa | grep gssproxy
and then comparing it to the rpm file /tmp/gssproxy-0.7.0-30.el7_9.x86_64.rpm by regex is very complicated.
There's a dedicated tool called rpmdev-vercmp for comparing RPM versions. It's in the yum-utils package. apparently in a package named rpmdevtools.
Untested, but hopefully sufficient to get you started:
for rpm in /tmp/list_of_rpms/*.rpm; do
base=${rpm#/tmp/list_of_rpms/}
pkg=${base%-*-*}
if installed=$(rpm -q "$base"); then
rpmdev-vercmp "$pkg" "$installed" >/dev/null 2>&1
case $? in 12) echo "$installed is less than $pkg";; esac
fi
done
This doesn't do anything for packages which are not installed at all; perhaps you want to add an else clause and add a notification about those, too?
Some background from https://www.golinuxhub.com/2018/06/how-to-compare-rpm-version-bash-script-python-linux-algorithm/ but the actual code in that has problems. Also, https://unix.stackexchange.com/questions/163702/bash-script-to-verify-that-an-rpm-is-at-least-at-a-given-version
I am currently having problems using TinyTeX in a conda environment with Snakemake. I have to install TinyTeX installation files using the command tinytex::install_tinytex() before running the pipeline. This installs TinyTeX outside of the created environment (which isn't that big of a problem... but not preferred either) . The main problem is that every time I execute my Snakemake pipeline it will try to reinstall this installation which I don't want. Could anyone tell me what the easiest way is for me to check whether it's installed already? Should I be using the command Rscript -e \"tinytex:::is_tinytex()\" with an if-statement? And what is the best way to write that if-statement by calling Rscript -e in Snakemake? Or should I just write a boolean text-file on first run which specifies whether TinyTeX has been installed before?
It kinda sucks that the TinyTeX conda dependency doesn't work on its own without additional installation...
Snakemake rule (ignore input/output):
rule assembly_report_rmarkdown:
input:
rules.assembly_graph2image_bandage.output,
rules.assembly_assessment_quast.output,
rules.coverage_calculator_shortreads.output,
rules.coverage_calculator_longreads.output
output:
config["outdir"] + "Hybrid_assembly_report.pdf"
conda:
"envs/r-rmarkdown.yaml"
shell:
"""
cp report/RMarkdown/Hybrid_assembly_report.Rmd {config[outdir]}Hybrid_assembly_report.Rmd
Rscript -e \"tinytex::install_tinytex()\"
Rscript -e \"rmarkdown::render('{config[outdir]}Hybrid_assembly_report.Rmd')\"
rm -f {config[outdir]}Hybrid_assembly_report.Rmd {config[outdir]}Hybrid_assembly_report.tex
"""
Conda YAML:
name: r-rmarkdown
channels:
- conda-forge
- bioconda
dependencies:
- r-base=4.0.3
- r-rmarkdown=2.5
- r-tinytex=0.27
Thanks in advance.
I think I've solved the issue. Instead of calling Rscript -e, I have put the following if-statement in the setup chunk in R Markdown (Which runs before running any other code if i'm correct). I then proceeded to uninstall TinyTeX to see whether it will install for once only which it did.
knitr::opts_chunk$set(echo = TRUE)
library(knitr)
if (!tinytex:::is_tinytex()){
tinytex::install_tinytex()
}
How can I install a specific version of ocaml compiler (and compatible packages) using opam (or another package manger)?
I took a quick look through the opam documentation, but I don't find a relevant information.
I need ocaml compiler (preferably the native code compiler) to build unison, a software for file synchronization. I need to build unison on two machines using the same version of ocaml, or otherwise unison emits an error and aborts its duty (yiiii!).
I tried building ocaml version 4.04.0 from a tar ball and then using it for building unison, but on one of the machine the build of unison failed with the error message,
make[1]: Entering directory '/home/norio/Downloads/unison/unison-2.48.4_expand/src'
ocamlc -o mkProjectInfo unix.cma str.cma mkProjectInfo.ml
File "mkProjectInfo.ml", line 1:
Error: Error while linking /home/norio/Downloads/unison/ocaml_for_unison/lib/ocaml/unix.cma(Unix):
The external function `unix_has_symlink' is not available
if [ -f `which etags` ]; then \
etags *.mli */*.mli *.ml */*.ml */*.m *.c */*.c *.txt \
; fi
make[1]: Leaving directory '/home/norio/Downloads/unison/unison-2.48.4_expand/src'
I don't want to set off for the quest of unix_has_symlink function and devote myself for the exploration of the swamp of library dependencies where many developers had fallen before the civilization came and package managers were invented.
Is there anything like,
opam install ocamlc-4.04 and opam install all-packages?
Addendum
The error message about unix_has_symlink was observed on a machine running Linux Mint 18 Cinnamon 64 bit. Is this function a part of some unix/linux library, rather than ocaml package?
To create a switch with a particular version of the compiler do
opam switch create <compiler-version>
(Note: for the old opam 1.x it was opam switch <compiler-version>)
E.g.,
opam switch create 4.07.0
Or, if you want to create a fresh new switch that uses the same compiler as some other switch, then the syntax is
opam switch create <name> <compiler-version>
E.g.,
opam switch create myproj 4.07.0
Note, that if <name> is a folder, then a local switch will be created, e.g., opam switch ./myproj 4.07.0 will create a switch directly in the myproj folder.
To start with a specific version, i.e., when you first install opam, just do
opam init --compiler=<version>
E.g.,
opam init --compiler=4.07.0
To list available versions do
opam switch
To see even more, do
opam switch list-available
To install a variant of a compiler, e.g., a compiler with flambda or spacetime, use the following general syntax,
opam switch create <switch-name> ocaml-variants.<version>+options <options>...
E.g.,
opam switch create myswitch ocaml-variants.4.13.0+options ocaml-option-flambda
use opam search ocaml-options for the full list of available options. It is possible to specify several options, e.g.,
opam switch create myswitch ocaml-variants.4.13.0+options ocaml-option-flambda ocaml-option-spacetime ocaml-option-static