Unable to activate package ‘company-lsp’. Required package ‘lsp-mode-3.4’ is unavailable

啓動 spacemacs 時報錯,*messages* 消息:

(Spacemacs) --> refreshing package archive: gnu... [3/3]
Contacting host: elpa.gnu.org:443
Importing package-keyring.gpg...done
Package refresh done
(Spacemacs) --> installing package: [email protected] [1/1]
(Spacemacs) Warning: Cannot install package lsp-mode.
You appear to be setting environment variables ("GOPATH" "PATH") in your .bashrc or .zshrc: those files are only read by interactive shells, so you should instead set environment variables in startup files like .profile, .bash_profile or .zshenv.  Refer to your shell’s man page for more info.  Customize ‘exec-path-from-shell-arguments’ to remove "-i" when done, or disable ‘exec-path-from-shell-check-startup-files’ to disable this message.
Unable to activate package ‘company-lsp’.
Required package ‘lsp-mode-3.4’ is unavailable
Unable to activate package ‘lsp-haskell’.
Required package ‘lsp-mode-3.0’ is unavailable
Unable to activate package ‘lsp-rust’.
Required package ‘lsp-mode-3.0’ is unavailable

我的配置 https://github.com/MaskRay/Config/blob/master/home/.emacs.d/private/%2Bmy/my-code/packages.el#L10 中指定 lsp-mode 和 lsp-ui 爲 local

% tree
.
├── my
│   ├── config.el
│   └── layers.el
├── my-code
│   ├── config.el
│   ├── funcs.el
│   ├── local
│   │   ├── lsp-mode -> ../../../../../../../Dev/Emacs/lsp-mode
│   │   └── lsp-ui -> ../../../../../../../Dev/Emacs/lsp-ui
│   └── packages.el
└── my-cquery
    ├── config.el
    ├── funcs.el
    ├── local
    │   └── cquery -> ../../../../../../../Dev/Emacs/emacs-cquery
    └── packages.el

這幾個 symlinks 都是指向本地 git repo 的,不知道爲什麼 company-lsp 報錯;lsp-rust lsp-haskell cquery 這些依賴的版本號是不是也有問題?lsp-mode 3.0 3.4 是不存在的?

(defun my-code/init-lsp-mode ()
  (use-package lsp-mode
    :config
    (add-hook 'lsp-after-open-hook 'lsp-enable-imenu)
    (add-to-list 'spacemacs-jump-handlers-d-mode 'company-dcd-goto-definition)
    (setq lsp-enable-flycheck nil) ;; disable lsp-flycheck.el in favor of lsp-ui-flycheck.el
    ;; (setq-default flycheck-disabled-checkers '(c/c++-clang)) ;; in flycheck.el
    )
)

我觉得只是声明 local 是无效的,因为真的工作的是 use-package, Spacemacs 只是对use-package 做了一层封装,你声明了 local, 但是 use-package 也不知道去哪里找 :frowning: .我觉得应该配置成这样:

(defun my-code/init-lsp-mode ()
  (use-package lsp-mode
     :load-path "../../../../../../Dev/Emacs/lsp-mode" => 可能需要改改,你这路径有点厉害
    :config
    (add-hook 'lsp-after-open-hook 'lsp-enable-imenu)
    (add-to-list 'spacemacs-jump-handlers-d-mode 'company-dcd-goto-definition)
    (setq lsp-enable-flycheck nil) ;; disable lsp-flycheck.el in favor of lsp-ui-flycheck.el
    ;; (setq-default flycheck-disabled-checkers '(c/c++-clang)) ;; in flycheck.el
    )

Disclaimer:我很久以前是Spacemacs 用户,我现在不熟悉 Spacemacs, 我只是针对 use-package 分析 :joy:

为什么以前用spacemacs,现在不用了。。

我看 scturtle 的改成 (lsp-mode :location local)https://github.com/scturtle/dotfiles/blob/master/spacemacs/.emacs.d/private/lsp-cquery/packages.el

他也沒用 load-path …

这个路径是因为我的配置在 ~/Config/home/.emacs.d symlink到 ~/.emacs.d ,再加几层 private 就需要很多 … 了

包不存在十有八九就ELPA的问题,挂个代理。国内源未必好用
lsp-mode和lsp-ui在MELPA里活得好好的
location指定local,试试把整个文件夹复制过来而不是建符号链接试试

rm -r .elpa/27.0/develop 後重啓讓 spacemacs 重裝所有包。恢復了

https://melpa.org/#/company-lsp 這裏版本指定很奇怪 lsp-mode 3.4 (其他幾個 lsp-mode 依賴用 lsp-mode 3.0

company-quickhelp 大家用嗎?

因为当初我是从Vim->Emacs 的,刚开始用Evil 不太习惯,然后就找了Spacemacs 来用,大概是16年的时候,但是后来感觉Spacemacs 虽然开箱即用,但是出了问题不知道怎么去调,就一黑盒子,只能看源码分析或者是发 issue, 所以用了一段时间之后就换回自己的配置了.

company-quickhelp 我在用,不过它不支持终端下的Emacs, 是有什么问题么?

它需要只支持图形界面的 pos tips