I am working on a HPC that I don't have sudo privileges. I tried 3 ways to install opam but they didn't work
Option 1 the .deb approach
I did:
# - 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
#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
tr ':' '\n' <<< "$PATH"
opam --version
but it leads to missing compiler options and it also doesn't allow me to update opam with opam update --all
. Error msg when I try to update:
$ opam update --all
<><> Updating package repositories ><><><><><><><><><><><><><><><><><><><><><><>
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
Option 2 using conda
Usually this is the way I've done it in my docker containers (due to someone else's suggestions):
conda install -c conda-forge opam
but it leads to the following error:
...
ClobberError: The package 'conda-forge/noarch::pip-22.3.1-pyhd8ed1ab_0' cannot be installed due to a
path collision for 'lib/python3.9/site-packages/pip/_vendor/requests/__pycache__/packages.cpython-39.pyc'.
This path already exists in the target prefix, and it won't be removed
by an uninstall action in this transaction. The path is one that conda
doesn't recognize. It may have been created by another package manager.
...
I also wonder if the fact that I did this error is the reason option 1 is not working see error of option 1.
Option 3 using the usual hack: download git repo then install binaries to a location you specify
mkdir ~/.opam
cd ~/.opam
git clone https://github.com/rbenv/opam.git .
export PATH="$HOME/.opam/bin:$PATH"
echo 'export PATH="$HOME/.opam/bin:$PATH"' >> ~/.bashrc
eval $(opam env)
opam update --all
opam init --disable-sandboxing
eval $(opam env)
Option 4, following the install instructions from opam
I realize there is a 4th option that I will try again right now and report. I assume it didn't work or I'd be using it (though no user interaction would be nice):
$ bash -c "sh <(curl -fsSL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)"
## Downloading opam 2.1.3 for linux on x86_64...
## Downloaded.
## Where should it be installed ? [/usr/bin] ~/.local/
## '~/.local/' resolves to '/dfs/scratch0/brando9/.local/', do you confirm [Y/n] Y
Write access to /usr/bin required, using 'sudo'.
Command: mv /usr/bin/opam /usr/bin/opam.1.2.2
[sudo] password for brando9:
Sorry, user brando9 is not allowed to execute '/bin/mv /usr/bin/opam /usr/bin/opam.1.2.2' as root on hyperturing2.stanford.edu.
I tried the above but now that the administrators installed opam it doesn't let me. Hopefully I do have permissions to update opam etc...or I might have to ask them to uninstall it or at least update it.