Debian12 安装vim

文章讲述了在新安装Vim时,作者建议先更换为中国清华大学的镜像源。遇到依赖问题时,通过aptitude命令管理器解决了ncurses-base和ncurses-term的版本冲突,最终成功安装了Vim。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

新装vim,先改国内源,推荐清华,阿里的实在拉跨。

修改/etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
 
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ buster/updates main contrib non-free
 
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-updates main contrib non-free
 
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ buster-backports main contrib non-free
 

随后开始安装vim

sudo apt-get purge vim-common
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install aptitude
sudo aptitude install vim

为什么用aptitude?我在卸载vim-common,死活装不上vim,如下提示

The following packages have unmet dependencies:
 ncurses-base : Breaks: vim-common (< 2:9.0.1000-2) but 2:8.1.0875-5+deb10u5 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

可能的原因是有损坏的包,对此情况那就适合aptitude 命令了。

他会先给你一个解决方案:

The following NEW packages will be installed:
  vim vim-common{a} vim-runtime{a} xxd{a} 
0 packages upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 7,395 kB of archives. After unpacking 33.7 MB will be used.
The following packages have unmet dependencies:
 ncurses-term : Breaks: vim-common (< 2:9.0.1000-2) but 2:8.1.0875-5+deb10u5 is to be installed
 ncurses-base : Breaks: vim-common (< 2:9.0.1000-2) but 2:8.1.0875-5+deb10u5 is to be installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:                              
1)     vim [Not Installed]                                                              
2)     vim-common [Not Installed]                                                       

     Leave the following dependencies unresolved:                                       
3)     vim-runtime recommends vim | vim-gtk | vim-gtk3 | vim-athena | vim-nox | vim-tiny



Accept this solution? [Y/n/q/?]

说是保持原样,显然不是我要的,回车看下一个方案:

The following actions will resolve these dependencies:

     Downgrade the following packages:                                    
1)     ncurses-base [6.4-4 (now) -> 6.1+20181013-2+deb10u3 (oldoldstable)]
2)     ncurses-term [6.4-4 (now) -> 6.1+20181013-2+deb10u3 (oldoldstable)]



Accept this solution? [Y/n/q/?] 

似乎也不是我要的,继续回车

The following packages will be DOWNGRADED:
  ncurses-base ncurses-term 
The following NEW packages will be installed:
  vim vim-common{a} vim-runtime{a} xxd{a} 
0 packages upgraded, 4 newly installed, 2 downgraded, 0 to remove and 0 not upgraded.
Need to get 8,144 kB of archives. After unpacking 33.6 MB will be used.
Do you want to continue? [Y/n/?] Y

这个对了,选Y回车。vim安装成功。。。。。 

### 解决 Debian 12 上无法安装 Vim 的问题 #### 卸载现有版本 为了确保干净的环境,在尝试重新安装之前应先移除现有的 Vim 版本。这可以通过执行以下命令来完成: ```bash sudo apt-get remove --purge vim vim-runtime vim-common gvim ``` 此操作会彻底清除旧版本及其配置文件[^4]。 #### 更新软件包列表并升级系统 更新本地软件包索引至最新的状态,并对整个系统进行一次全面升级,以防止因依赖关系而导致的问题: ```bash sudo apt-get update && sudo apt-get upgrade -y ``` #### 使用 `aptitude` 进行安装 有时标准的 APT 工具可能会遇到冲突或其他复杂情况;此时推荐使用更高级别的包管理器 `aptitude` 来处理这些棘手的情况。首先确保已安装 `aptitude`: ```bash sudo apt-get install aptitude ``` 接着利用它来进行 Vim安装工作: ```bash sudo aptitude install vim ``` 这种方法能够更好地解析和解决潜在的依赖性问题[^3]。 #### 验证安装结果 一旦上述过程顺利完成之后,应该验证新安装Vim 是否正常运行以及其功能是否完好无损。打开终端输入 `vim --version` 查看当前使用的 Vim 版本号及相关信息即可确认安装状况良好。 #### 处理特定错误消息 (可选) 如果仍然存在某些具体类型的报错提示,则需针对该类错误采取进一步措施。例如当遇到权限不足或路径缺失等问题时,可能需要调整用户权限设置或是手动创建必要的目录结构等额外步骤[^5]。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值