How to upgrade a single package? - ocaml

I did opam update and then opam upgrade, and now OPAM wants to upgrade 10 packages to more recent versions.
However, for fear of breaking something inadvertently, I'd like to upgrade a single package, without touching the others. This package has no dependencies and it seems that none of the other packages depends on it.
However, doing opam upgrade <package> results in the same thing as opam upgrade, that is, OPAM wants to upgrade all 10 packages, not just the one I want.
I even tried opam install <package>.<new version>, but it also wants to upgrade everything at once.
Is there a way to upgrade just this single package, without touching the rest? In theory nothing should break, but in practice it often happens...

I found out that doing
opam reinstall <package>.<new version>
allows me to obtain what I want, that is, install only package <package> and its dependencies, without upgrading unrelated packages.
OPAM emits a warning ([WARNING] <package>.<new version> is not installed.), but it proposes me to install it anyway.
Afterwards, despite some warnings about the destination directory not being empty (due to the already installed previous version), OPAM was able to install only the desired package, without upgrading everything.
Notice that the same thing happens if I try to install a new package: because my previous opam update added several packages to the update list, trying to install anything via opam install will trigger the "update everything" algorithm, while opam reinstall won't.
I don't know if this is undesired behavior, but if so, I hope that it will remain available in future OPAM versions, or that there will be a way to ignore unrelated upgrades.
Edit: as indicated in this OPAM Github issue, using --criteria=paranoid or --criteria=-changed,-notuptodate can also help with not modifying anything else.

Related

Using the most recent version of zarith with opam

I am using zarith for handling arbitrary sized integers.
The most recent version I could find on opam.ocaml.org was v1.9.1 (published in August 2019). On the project's github page I read Latest commit a9a309d on 23 Jan (2020).
I'd like to switch to the newer version, but how do I do that? I want to
keep opam happy, and
always use the most current version of zarith.
Please help!
Indeed, currently 1.9.1 is both the latest version of Zarith available as an opam package (https://opam.ocaml.org/packages/zarith/) and as a GitHub tag (https://github.com/ocaml/Zarith/tags).
However, given this upstream Git repository also contains an .opam specification file, you can just as well use opam to install the latest development version available in the master branch, or if need be, a precise Git commit just by relying on the so-called pinning feature of opam.
So, you can run alternatively:
opam pin add -n -y -k git zarith.dev --dev-repo
or
opam pin add -n -y -k git zarith.dev "https://github.com/ocaml/Zarith.git#master"
or
opam pin add -n -y -k git zarith.dev "https://github.com/ocaml/Zarith.git#a9a309d0596d93b6c0c902951e1cae13d661bebd"
Then:
opam install zarith
Further details on the opam-pin command
The .dev version suffix is unneeded syntactically, but is recommended actually, as the zarith.opam file does not specify any version. To be more precise:
If you have other dependencies that would complain of zarith.dev when being installed, you can replace the version suffix of dev with any compatible version string, "close" to the commit or branch you selected.
However if you omit this version, opam will typically pick the latest version string from the opam package repository (i.e., 1.9.1), which wouldn't necessarily match the code of the Git branch or commit you selected.
-n, -y, and -k are the short form of the options:
--no-action (don't install the package readily but wait the subsequent opam install command),
--yes (answer potential yes/no questions without prompting − a common opam pin question is Package foo does not exist, create as a NEW package? [Y/n] if ever you'd want to install a custom package not yet released in the opam-repository),
--kind=KIND (as there are several KINDS of pinning, the most typical being version, path, and git)
If you really need to use the unreleased, in-development version of zarith you can use the --dev-repo option of opam pin add:
opam pin add --dev-repo zarith
opam install zarith

how to uninstall opam...?

UPDATE:
I've fixed the problem, but I'm still confused.
Or, rather, there wasn't a problem...apparently the fact that the opam--version command still worked didn't prevent me from re-running all the installation commands and getting things to work again.....?
I'm really confused as to why I'm not having more problems than I am. Does the version command still work even if opam is deleted...somehow?? Do I have two distinct copies of opam on my computer, but somehow they aren't interfering? I definitely ran the installation twice....I feel like something should be going wrong.....could someone please explain what's going on?
Below is my initial question:
I've messed up some switch somewhere
(the error is
ERROR] No config file found for switch
with-coq. Switch broken?
if one of you is genius enough to fix this directly lol)
and am trying to delete everything and start over. Opam won't go away, though. I've tried
opam remove --force
as per here and
opam uninstall
as per here, both from my home directory.
I've also tried forcibly deleting the .opam directory with rm -rf.
After all this, the command opam --version command still works. How do I get the damn thing to go away?
Thank you all.
If you want to remove the opam binary, you have to uninstall it the way you installed it, either using your package manager, or, if you installed manually, run which opam and then delete the file that prints.
The opam switches in ~/.opam are data, they are separate from opam the command. This is true of all package managers and almost all programs, in general.
To remove ocaml version including all its packages, use this command ...
opam switch remove <version>

Automatically redirect PPA to new package name

I maintain the PPA for Bookworm here:
https://launchpad.net/bookworm
Recently I have changed the package name from "bookworm" to "com.github.babluboy.bookworm" based on the RDNN requirements of Elementary OS AppStore
This requires that the installation on Ubuntu is done by the command "sudo apt-get install com.github.babluboy.bookworm" instead of "sudo apt-get install bookworm".
While I have signposted this on Launchpad and the Bookworm website, there are a lots of posts and blogs on the internet from earlier asking users to use the "sudo apt-get install bookworm" command. This will install an old package (still in the PPA) which I don't update anymore.
Is there a way I can set up in Launchpad so that the older package automatically points to the new one for installation.
A hack that I can think of is to update the old package so that there is a big banner on the app providing instructions to switch to the new package. But thought of asking here if there is a more elegant way to manage package name changes in PPA
What you need is a transitional package with the old name. This will be an empty package with no actual contents, which has the new package as a dependency. When people update/install the bookworm package, it will be installed, and will pull the new package as a dependency. A future version of the new package can declare the old one as a conflict, and remove it while updating.
Debian Wiki has the information you need in much more detail. For a number of package transition scenarios, see this:
https://wiki.debian.org/PackageTransition
Case #5 : Rename is what you need from there. The exact page you want is this
https://wiki.debian.org/RenamingPackages
There are other methods explained on that page, like the 'Clean Slate Method', but the 'Transition package method' is the one which is much more cleaner, and recommended. (If you search apt for 'transitional package', you'll find a lot of them).

Opam not getting latest packages

I just installed opam using the quick install
http://opam.ocaml.org/doc/Quick_Install.html
I now have
$opam --version
1.1.0
which is current. I ran "opam update" and "opam upgrade" to get the latest packages. However, when I install packages, it is still giving me the old versions (such as core 109.42 instead of core 109.55):
$ opam search core
Available packages for 4.01.0:
async_core 109.42.00 Monadic concurrency library
What do I need to do to get opam to give me the latest libraries?
If you previously built from source, make sure you uninstall that first. For whatever reason, even though the opam version correctly reports "1.1.0", it was still using the old repo address. After you uninstall old opam entirely, then follow the installation instructions at the link above.
You will know you succeeded when you do "opam update" and prints:
default Downloading http://opam.ocamlpro.com/urls.txt
[NOTE] The repository 'default' will be *permanently* redirected to https://opam.ocaml.org (opam-version >= "1.1.0")

How do I use a virtualenv-based deployment method without upgrading to each and every upstream version?

Last Friday, I've built an RPM spec for my Django project. The RPM creates a virtualenv, downloads dependencies via pip and puts everything into the packages. Today, I've found out that BeautifulSoup 3.2 has been released. Luckily, I've had my BeautifulSoup version pinned in the requirements.txt, so I found out because of the build failing.
Now a completely different matter is: how do I do avoid upgrading stuff in the future? BeautifulSoup has deleted all previous versions from PyPI, so I can't download a version I've actually tested against. pip's download cache doesn't help here either, since pip always tries to check PyPI first.
Can you recommend something to avoid this situation?
First, this is an unusual situation. I've never seen another package remove all old releases the way BeautifulSoup does. I consider that rather user-hostile behavior, except perhaps in cases of a serious security fix.
That said, if you want a reliable build process using pip, you really need to mirror all the packages you rely on locally. It's not hard to do; you can use pip's --download option (or your existing pip cache) to get all the package tarballs, then just dump them in an indexed, web-served directory and use --find-links in your requirements file to point pip there (plus --no-index to tell it not to use PyPI).
The files in question can still be found: just provide the direct url instead of the package name:
http://www.crummy.com/software/BeautifulSoup/download/3.x/3.0.8.tar.gz
for example.