erlang_ls icon indicating copy to clipboard operation
erlang_ls copied to clipboard

erlang_ls --version always returning 0.0.0

Open robsonpeixoto opened this issue 1 year ago • 6 comments

Describe the bug

❯ erlang_ls --version
Version: 0.0.0

To Reproduce

❯ erlang_ls --version
Version: 0.0.0

Expected behavior

❯ erlang_ls --version
Version: 0.41.2

Actual behavior

❯ erlang_ls --version
Version: 0.0.0

Context

  • erlang_ls version (tag/sha): 0.41.2
  • Editor used: terminal
  • LSP client used: terminal

I'm submitting a PR to use homebrew to install erlang_ls(https://github.com/Homebrew/homebrew-core/pull/108766/files) and after install I tried the --version flag to figure-out if the command was installed correctly.

robsonpeixoto avatar Aug 24 '22 05:08 robsonpeixoto

Hi @robsonpeixoto !

I cannot reproduce this, not even on a fresh clone. What OTP/rebar3 versions are you using? The code to extract the version is here:

https://github.com/erlang-ls/erlang_ls/blob/main/apps/els_lsp/src/erlang_ls.erl#L39

robertoaloi avatar Aug 24 '22 11:08 robertoaloi

Can you also describe the steps you are using to compile Erlang LS?

robertoaloi avatar Aug 24 '22 11:08 robertoaloi

This bug only happen when compiled from the tarball https://github.com/erlang-ls/erlang_ls/archive/refs/tags/0.41.2.tar.gz. From the git repository the --version works well.

❯ wget https://github.com/erlang-ls/erlang_ls/archive/refs/tags/0.41.2.tar.gz
...
2022-08-24 09:06:24 (1.45 MB/s) - ‘0.41.2.tar.gz’ saved [531934]

❯ tar xzf 0.41.2.tar.gz

❯ cd erlang_ls-0.41.2

❯ make
...
===> Building escript for els_dap...

❯ ./_build/default/bin/erlang_ls --version
Version: 0.0.0

robsonpeixoto avatar Aug 24 '22 12:08 robsonpeixoto

Hi,

i used mason within neovim to install erlang_ls and there this happens too. In a "normal" checkout of the repo this doesn't happen.

grafik

big-r81 avatar Aug 30 '22 07:08 big-r81

I believe this has something to do with running the make or make install from a directory that is not a git repo, or not a git repo with all the tags.

When I try to build using my forked repo I can reproduce the same problem with the version output:

zach@zach-VirtualBox:~/Documents$ git clone https://github.com/zach-writes-code/erlang_ls && cd erlang_ls
zach@zach-VirtualBox:~/Documents/erlang_ls$ sudo make install
Building escript...
===> Fetching erlfmt v1.1.0
...
...
...
===> Building escript for els_dap...
Installing escript...

zach@zach-VirtualBox:~/Documents/erlang_ls$ erlang_ls -v
Version: 0.0.0+build.1898.ref55a3854

zach@zach-VirtualBox:~/Documents/erlang_ls$ git tag
zach@zach-VirtualBox:~/Documents/erlang_ls$

However when I fetch the upstream repo it pulls all the tags in and builds with the correct version output:

zach@zach-VirtualBox:~/Documents/erlang_ls$ git remote add upstream https://github.com/erlang-ls/erlang_ls
zach@zach-VirtualBox:~/Documents/erlang_ls$ git fetch upstream
remote: Enumerating objects: 1261, done.
...
...
 * [new tag]         0.40.0                                               -> 0.40.0
 * [new tag]         0.41.0                                               -> 0.41.0
 * [new tag]         0.41.1                                               -> 0.41.1
 * [new tag]         0.41.2                                               -> 0.41.2
...
...
zach@zach-VirtualBox:~/Documents/erlang_ls$ sudo make install
Building escript...
===> Verifying dependencies...
...
...
===> Building escript for els_dap...
Installing escript...
zach@zach-VirtualBox:~/Documents/erlang_ls$ erlang_ls -v
Version: 0.41.2+build.1898.ref55a3854

I've poked around the code to try to understand why this is, but have not been able to pin anything down.

zachlankton avatar Aug 31 '22 17:08 zachlankton

@zachlankton You were on the right path. The version is retrieved from the git repo as set here https://github.com/erlang-ls/erlang_ls/blob/0.50.0/src/erlang_ls.app.src#L3 on the vsn prop. When compiling from a non git directory it would not work, and rebar3 warns about that:

...
===> Analyzing applications...
===> Compiling els_core
===> Compiling els_lsp
===> Compiling erlang_ls
===> Getting log of git repo failed in /home/luca/Scaricati/erlang_ls-0.50.0/apps/els_lsp. Falling back to version 0.0.0
===> Getting log of git repo failed in /home/luca/Scaricati/erlang_ls-0.50.0. Falling back to version 0.0.0
===> Building escript for els_lsp...

@robertoaloi A possible solution is to use a VERSION file on the root project and use it on the vsn prop as described here https://rebar3.org/docs/basic_usage/#adding-dependencies (to keep consistency on both erlang_ls and els_lsp apps).

lucavallerini avatar Jan 20 '24 12:01 lucavallerini