elixir-lsp / vscode-elixir-ls

Elixir language support and debugger for VS Code, powered by ElixirLS.
https://marketplace.visualstudio.com/items?itemName=JakeBecker.elixir-ls
MIT License
545 stars 106 forks source link

can not find hex under debian12.5 #418

Closed ziyouchutuwenwu closed 6 months ago

ziyouchutuwenwu commented 6 months ago

i am not sure if this issue should be posted here or https://github.com/elixir-lsp/elixir-ls, here is the steps.

due to gfw, i download hex manually, then

mmc at deb-kvm in ~
$ mix archive.install ./hex-2.0.6.ez
Are you sure you want to install "./hex-2.0.6.ez"? [Yn]
* creating .mix/archives/hex-2.0.6

here is the snapshot of installed hex aaa

when i create demo project

mix new demo

open with vscode, then check the elixirls output

Running /home/mmc/.vscode/extensions/jakebecker.elixir-ls-0.21.1/elixir-ls-release/launch.sh
Preferred shell is zsh, relaunching
Looking for ASDF install
ASDF install found in /home/mmc/.asdf/asdf.sh, sourcing
Installing ElixirLS release v0.21.1
Running in /home/mmc/downloads/demo
* Getting elixir_ls (https://github.com/elixir-lsp/elixir-ls.git - v0.21.1)
==> language_server
Could not find Hex, which is needed to build dependency :stream_data
Shall I install Hex? (if running non-interactively, use "mix local.hex --force")

Elixir & Erlang versions (elixir --version):

elixir was installed by apt, not asdf

$ elixir --version
Erlang/OTP 25 [erts-13.1.5] [source] [64-bit] [smp:2:2] [ds:2:2:10] [async-threads:1] [jit:ns]

Elixir 1.14.0 (compiled with Erlang/OTP 24)

vscode version

Version: 1.89.1
Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685
Date: 2024-05-07T05:16:23.416Z
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Linux x64 6.1.0-9-amd64

VSCode ElixirLS version:

JakeBecker.elixir-ls v0.21

os version:

mmc at deb-kvm in ~/downloads
$ cat /etc/os-release 
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

mmc at deb-kvm in ~/downloads 
$ cat /etc/debian_version 
12.5

$ neofetch 
       _,met$$$$$gg.          mmc@deb-kvm 
    ,g$$$$$$$$$$$$$$$P.       ----------- 
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux 12 (bookworm) x86_64 
 ,$$P'              `$$$.     Host: KVM/QEMU (Standard PC (Q35 + ICH9, 2009) pc-q35-8 
',$$P       ,ggs.     `$$b:   Kernel: 6.1.0-9-amd64 
`d$$'     ,$P"'   .    $$$    Uptime: 14 mins 
 $$P      d$'     ,    $$P    Packages: 2092 (dpkg) 
 $$:      $$.   -    ,d$$'    Shell: zsh 5.9 
 $$;      Y$b._   _,d$P'      Resolution: 1280x800 
 Y$$.    `.`"Y$$$$P"'         DE: Xfce 4.18 
 `$$b      "-.__              WM: Xfwm4 
  `Y$$                        WM Theme: JacWin10 
   `Y$$.                      Theme: Windows10 [GTK2] 
     `$$b.                    Icons: Faenza [GTK2] 
       `Y$$b.                 Terminal: terminator 
          `"Y$b._             CPU: Intel i5-9500 (2) @ 3.000GHz 
              `"""            GPU: 00:01.0 Red Hat, Inc. Virtio 1.0 GPU 
                              Memory: 1171MiB / 1967MiB
ziyouchutuwenwu commented 6 months ago

it should be reported to https://github.com/elixir-lsp/elixir-ls

lukaszsamson commented 6 months ago

Something is wrong with your env or hex, not with elixirLS. There were similar reports already here and on elixir forums. Please use search

ziyouchutuwenwu commented 6 months ago

sorry for reopening this issue, i found need to run Code.append_path for debian, as i posted https://github.com/elixir-lsp/elixir-ls/issues/1092, i don't know how to add dir /home/mmc/.mix/archives/hex-2.0.6/hex-2.0.6/ebin/ to system beam path automaticlly.

here is my code for $HOME/.vscode/extensions/jakebecker.elixir-ls-0.21.1/elixir-ls-release/installer.exs

defp load_hex do
  if !Code.ensure_loaded?(Hex) do
    base_dir = System.user_home |> Path.join(".mix/archives")

    if base_dir |> File.exists? do
      sub_dirs = File.ls!(base_dir)
      if sub_dirs |> Enum.count() > 0 do
        hex_dirs = Enum.filter(sub_dirs, fn dir -> dir |> String.starts_with?("hex-") end)

        hex_dir = Enum.reduce(hex_dirs, fn dir, saved_dir ->
          start_pos = String.length("hex-")
          ver1 = dir |> String.slice(start_pos..-1) |> Version.parse!()
          ver2 = saved_dir |> String.slice(start_pos..-1) |> Version.parse!()

          case Version.compare(ver1, ver2) do
            :gt ->
              dir
            :lt ->
              saved_dir
            :eq ->
              [dir, saved_dir] |> Enum.random()
          end
        end)

        hex_beam_path = base_dir |> Path.join(hex_dir) |> Path.join(hex_dir) |> Path.join("ebin")
        Code.append_path(hex_beam_path)
      end
    end
  end
end

line 342

load_hex()
cond do xxx
ziyouchutuwenwu commented 6 months ago

sorry, it's due to https://github.com/elixir-lsp/elixir-ls, close it now