0

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.


Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
  • 1
    Generally, if you can't run sudo you can't install software at the system level. There may be an individual-user installation option; check the package's documentation. If not, talk to your sysadmin about getting the package installed; managing that is why you _have_ a sysadmin. – keshlam Dec 06 '22 at 19:55
  • `I tried the above but now that the administrators installed opam it doesn't let me` - if the server admin has installed a version, you should talk to them if it needs to be updated. Going behind their back could get you in trouble. Let them do their job and they will be happier with you. – Dave S Dec 06 '22 at 20:04
  • 1
    @DaveS Will talk to them! I wasn't going behind their back. I did my local install since they suggested it because they can't install the most recent version. Doing my best here but thanks for the advice! – Charlie Parker Dec 06 '22 at 20:50
  • @DaveS no worries! I think your comment is still valuable. Hopefully they will see your comment and avoid the hassle I'm going through. – Charlie Parker Dec 06 '22 at 21:07
  • related: https://stackoverflow.com/questions/75330486/how-does-one-use-the-official-way-to-install-opam-without-user-interaction – Charlie Parker Feb 03 '23 at 01:03

1 Answers1

0

Seems that this works:

$ 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

Will test if afterwords I can do what I truly need:

opam init --disable-sandboxing
opam update --all
eval $(opam env)
# compiler + '_' + coq_serapi + '.' + coq_serapi_pin
# ref: https://stackoverflow.com/questions/74697011/how-does-one-install-a-specific-ocaml-compiler-when-it-doesnt-appear-on-the-opa
opam switch create ocaml-variants.4.07.1+flambda_coq-serapi.8.11.0+0.11.1 ocaml-variants.4.07.1+flambda
opam switch ocaml-variants.4.07.1+flambda_coq-serapi.8.11.0+0.11.1
eval $(opam env)

opam repo add coq-released https://coq.inria.fr/opam/released
# opam pin add -y coq 8.11.0
opam repo --all-switches add --set-default coq-released https://coq.inria.fr/opam/released
opam update --all
opam pin add -y coq 8.11.0

#opam install -y --switch ocaml-variants.4.07.1+flambda_coq-serapi_coq-serapi_8.11.0+0.11.1 coq-serapi 8.11.0+0.11.1
opam install -y coq-serapi

eval $(opam env)

# - install utop
opam install utop
Charlie Parker
  • 5,884
  • 57
  • 198
  • 323