我通过典型的方式安装了 gradle:
sudo apt install gradle
Reading package lists... Done
Building dependency tree
Reading state information... Done
gradle is already the newest version (3.5-0ubuntu1).
0 to upgrade, 0 to newly install, 0 to remove and 8 not to upgrade.
接下来我想使用这个程序:
$ gradle
The program 'gradle' is currently not installed. You can install it by typing:
sudo apt install gradle
我尝试删除 java、清除 gradle、从任何地方删除它并重新安装。但都无济于事……最令人困惑的是,这个包几天前还正常工作,没有任何问题。
下面是一些调试:
$ which gradle
$ whereis gradle
gradle:
$ apt-cache policy gradle
gradle:
Installed: 3.5-0ubuntu1
Candidate: 3.5-0ubuntu1
Version table:
*** 3.5-0ubuntu1 500
500 http://ppa.launchpad.net/cwchien/gradle/ubuntu xenial/main amd64 Packages
500 http://ppa.launchpad.net/cwchien/gradle/ubuntu xenial/main i386 Packages
100 /var/lib/dpkg/status
2.10-1 500
500 http://archive.ubuntu.com/ubuntu xenial/universe amd64 Packages
500 http://archive.ubuntu.com/ubuntu xenial/universe i386 Packages
1.4-2ubuntu1 500
500 http://us.archive.ubuntu.com/ubuntu trusty/universe amd64 Packages
500 http://us.archive.ubuntu.com/ubuntu trusty/universe i386 Packages
如何将系统恢复到可以正确检测到该包的状态?
更新
我找到了命令:
sudo apt-get clean
现在我得到:
sudo apt install gradle
Reading package lists... Done
Building dependency tree
Reading state information... Done
gradle is already the newest version (3.5-0ubuntu1).
0 to upgrade, 0 to newly install, 0 to remove and 8 not to upgrade.
W: Target Packages (main/binary-amd64/Packages) is configured multiple times in /etc/apt/sources.list:7 and /etc/apt/sources.list.d/docker.list:1
W: Target Packages (main/binary-all/Packages) is configured multiple times in /etc/apt/sources.list:7 and /etc/apt/sources.list.d/docker.list:1
W: Target Translations (main/i18n/Translation-en_GB) is configured multiple times in /etc/apt/sources.list:7 and /etc/apt/sources.list.d/docker.list:1
W: Target Translations (main/i18n/Translation-en) is configured multiple times in /etc/apt/sources.list:7 and /etc/apt/sources.list.d/docker.list:1
W: Target Translations (main/i18n/Translation-pl) is configured multiple times in /etc/apt/sources.list:7 and /etc/apt/sources.list.d/docker.list:1
W: Target DEP-11 (main/dep11/Components-amd64.yml) is configured multiple times in /etc/apt/sources.list:7 and /etc/apt/sources.list.d/docker.list:1
W: Target DEP-11-icons (main/dep11/icons-64x64.tar) is configured multiple times in /etc/apt/sources.list:7 and /etc/apt/sources.list.d/docker.list:1
更新2
dpkg -L gradle
/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/gradle
/usr/share/doc/gradle/changelog.Debian.gz
/usr/share/doc/gradle/copyright
namei -lx /usr/bin/gradle
f: /usr/bin/gradle
Drwxr-xr-x root root /
drwxr-xr-x root root usr
drwxr-xr-x root root bin
gradle - No such file or directory
答案1
最后感谢@muru 的评论,我完成了以下步骤:
我删除了ppa:cwchien/gradle
:
sudo rm -rf /etc/apt/sources.list.d/cwchien-ubuntu-gradle-xenial.*
sudo apt-get update
我从官方 repo 安装了旧的 gradle:
sudo apt-get install gradle
然后所有依赖项都正确安装。然后我cwchien-ubuntu-gradle-xenial
再次附加并再次安装:
sudo apt-get install gradle-ppa gradle
终于在网站上https://gradle.org/install我找到了命令:
export PATH=$PATH:/opt/gradle/gradle-3.5/bin
这最终解决了我的问题,现在:
gradle -v
------------------------------------------------------------
Gradle 3.5
------------------------------------------------------------
更新
现在我安装 gradlesdkman.io通过以下命令:
安装 sdkman
curl -s "https://get.sdkman.io" | bash
安装 gradle
sdk install gradle 4.0.2