You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无sudo权限下Linux/Ubuntu安装opam的失败尝试与求助

无sudo权限HPC上安装opam的失败尝试与问题

我在一台无sudo权限的高性能计算集群(HPC)上工作,尝试四种方法安装opam均未成功,具体情况如下:

方法1:.deb包方式

执行以下命令:

# - opam (snap, no sudo)
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

安装后出现编译器选项缺失问题,执行opam update --all时无法更新仓库,报错信息:

$ 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

方法2:Conda方式

这是我在Docker容器中常用的方法,执行命令:

conda install -c conda-forge opam

但出现路径冲突的ClobberError,报错信息:

...

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.

...

我怀疑此操作导致方法1无法正常工作。

方法3:Git仓库编译方式

通过克隆Git仓库并配置本地路径:

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)

方法4:官方脚本方式

执行官方安装脚本:

$ 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.

由于管理员已在系统中安装opam,脚本需要sudo权限移动系统文件而失败,目前考虑请求管理员更新或卸载系统opam。


内容的提问来源于stack exchange,提问作者Charlie Parker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 02:55:45