Installing OPAM reports "Solver failed"

I just did a fresh install of PureOS on a Librem 15, tried installing OPAM with sudo install opam, seemed to go fine.

Next I run opam init and tell it to, yes, modify ~/.profile and set up a hook to opam’s init script. Then it says

[ERROR] Solver failed: "/usr/bin/aspcud /tmp/opam-adam-32286/solver-in-32286-2c871f
        /tmp/opam-adam-32286/solver-out-32286-ad6566
        -count(removed),-sum(request,version-lag),-count(down),-sum(solution,version-lag),-count(changed)"
        exited with code 1 "ERROR: grounder returned with non-zero exit status"
Switch initialisation failed:

The only thing I saw relevant to this error was https://github.com/ocaml/opam/issues/3484 which seems to hinge on aspcud. I checked mine and, after trying to install it, I get the message that it’s already the newest version (1:1.9.4-2).

Apparently that’s not the newest version since there’s mention of a version 2. Not sure if I need to force that newer update or how to do so.

I suppose I should mention that I also installed OPAM on a Linux Mint machine and it went fine, so I’m assuming there’s something about PureOS which accounts for the difference.

Did you do sudo apt update before sudo apt install opam? I see version 2.0.3-1 in the PureOS.

I would at least recommend running

sudo apt update
sudo apt upgrade

Yep, already did that, so this is the behavior after running all the updates and upgrades until no more were available.

That’s quite odd. What do you see in /etc/apt/sources.list?
I just have deb https://repo.puri.sm/pureos green main

So I would think you should be able to get version 2 by updating. Only other thing I could think of would be sudo apt remove opam followed by updating and installing again

So after removing and reinstalling opam, I run opam install ocaml again and get

[ERROR] No switch is currently set. Please use 'opam switch' to set or install a switch

An interesting thing is if I run sudo apt-get update && apt-get upgrade it returns

Hit:1 https://repo.pureos.net/pureos green InRelease                                
Hit:2 https://repo.puri.sm/pureos green InRelease                                   
Reading package lists... Done
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

I ran it with sudo so I’m not sure why it would return this.

Not 100% sure, but you may need sudo apt update && sudo apt upgrade - try sudo after the & too

2 Likes