Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

erlang_ls --version always returning 0.0.0 #1369

Open
robsonpeixoto opened this issue Aug 24, 2022 · 6 comments
Open

erlang_ls --version always returning 0.0.0 #1369

robsonpeixoto opened this issue Aug 24, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@robsonpeixoto
Copy link

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 robsonpeixoto added the bug Something isn't working label Aug 24, 2022
@robertoaloi
Copy link
Member

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
Copy link
Member

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

@robsonpeixoto
Copy link
Author

robsonpeixoto commented Aug 24, 2022

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

@big-r81
Copy link

big-r81 commented Aug 30, 2022

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

@zachlankton
Copy link
Contributor

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.

@lucavallerini
Copy link

lucavallerini commented Jan 20, 2024

@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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants