GithubHelp home page GithubHelp logo

Comments (16)

khanakia avatar khanakia commented on June 28, 2024 1

I have fixed the issue. Here are the steps

  1. Download the source code zip from here https://github.com/elixir-lang/elixir/releases/tag/v1.12.3
  2. Unzip the file and rename it to elixir
  3. cd elixir
  4. make clean test
  5. Edit .bashrc or .zshrc file and it should be like this
. $HOME/.asdf/asdf.sh
export PATH=$PATH:/Users/khanakia/.asdf/shims
export PATH="$PATH:/Users/khanakia/D1/elixir/bin"
  1. Make sure you do not have elixir installed using asdf
  2. Run these commands
asdf global elixir path:/Users/khanakia/D1/elixir
asdf plugin add elixir
  1. Verify the asdf plugins by running asdf current and this will output
elixir          path:/Users/khanakia/D1/elixir /Users/khanakia/.tool-versions
erlang          24.1.4          /Users/khanakia/.tool-versions
  1. Confirm elixir -v
Erlang/OTP 24 [erts-12.1.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.12.3 (compiled with Erlang/OTP 24)
  1. Now you can open the vscode with elixir-ls plugin installed and it will fetch the core function definition e.g. IO.puts("demo") I can simply click the puts and it will open the IO code file

from elixir_sense.

samaaron avatar samaaron commented on June 28, 2024 1

Hi there,

has anyone figured out how to get the language server to find sources on Windows? I see:

Elixir sources not found (checking in d:/home/runner/work/elixir/elixir

I installed Elixir using the standard installer which puts it in the program files directory (I assume with no source). I'd be happy to manually download the source and configure a pointer to it if that's a possibility.

(Note that d:/home/ is not a valid directory on my machine. I'm not sure where it's getting that path from).

(Additionally, asdf isn't available for Windows and building Elixir from source on Windows appears to be non-trivial - although I'd love to be proved wrong).

from elixir_sense.

justindotpub avatar justindotpub commented on June 28, 2024

In case it is helpful, that repo has Rexbug printing out a trace to help quickly see each function's arguments and return value.

from elixir_sense.

justindotpub avatar justindotpub commented on June 28, 2024

I see now that if I install elixir from source (e.g. with asdf install elixir ref:HEAD) the tests pass. Would it make sense to 1) call this out in the docs, and 2) consider returning something else that more clearly states why the definition wasn't found?

from elixir_sense.

msaraiva avatar msaraiva commented on June 28, 2024

@balduncle yes, we can only "find definition" or "go to definition" if Elixir was installed from source. Not sure if there's another way to do this. Maybe we could accept an option like src_path and then users could just download the source and set the option. Ideally, I think the editor could even ask the user if he wants the source to be downloaded and automatically set the option whenever the editor needs to find definitions. Since this will demand work on the editor plugins side, we would need confirmation from those projects maintainers if they are willing to do those changes.

  1. call this out in the docs

We should definitely have that explicit in the docs, however, remember that the end-user doesn't even know that he should read ElixirSense's docs when something doesn't work as expected, he just uses the editor that uses a plugin that uses ElixirSense under the hood.

  1. consider returning something else that more clearly states why the definition wasn't found?

I'm open to suggestions here ;)

from elixir_sense.

justindotpub avatar justindotpub commented on June 28, 2024

Yeah, I like the idea of having the editors download the source. It would alleviate tickets like JakeBecker/vscode-elixir-ls#123. I'm willing to try to tackle this for vscode-elixir-ls, for what it's worth.

Fair point on the docs being more valuable for end users if present in a library that calls into ElixirSense.

from elixir_sense.

khanakia avatar khanakia commented on June 28, 2024

@msaraiva any update on this?
I tried to install from source asdf install elixir ref:HEAD but Go To Definition is still not working

from elixir_sense.

lukaszsamson avatar lukaszsamson commented on June 28, 2024

@khanakia can yo debug it with?

iex(3)> Enum.module_info[:compile][:source]
'/Users/me/elixir/lib/elixir/lib/enum.ex'

on my machine the sources are in the directory that is returned (I don't use asdf, I build elixir myself)

head -n 1 /Users/me/elixir/lib/elixir/lib/enum.ex 
defprotocol Enumerable do

from elixir_sense.

khanakia avatar khanakia commented on June 28, 2024

@lukaszsamson

iex(2)> Enum.module_info[:compile][:source]
'/home/build/elixir/lib/elixir/lib/enum.ex'
iex(3)> 

The above path does not exists. But i verified this path exists /Users/khanakia/.asdf/installs/elixir/1.12.3-otp-24/lib/elixir/lib/enum.ex

My binaries are located in this folder

/Users/khanakia/.asdf/shims/iex
/Users/khanakia/.asdf/shims/elixir

How can I change the path to point the elixir to a new path?

from elixir_sense.

khanakia avatar khanakia commented on June 28, 2024

@lukaszsamson So paths are correct now after I compiled with source. This is the new path it's showing now

iex(1)> Enum.module_info[:compile][:source]
'/Users/khanakia/D1/elixir/lib/elixir/lib/enum.ex'
iex(2)> 

But Go to definition still not works as you can see in the attached screenshot
Screenshot 2021-11-07 at 2 08 09 PM

from elixir_sense.

khanakia avatar khanakia commented on June 28, 2024

@lukaszsamson Also i just reinstalled the elixir-ls vscode extension and I can see now the extension is not loaded at all and the reason extension looks for a binary under asdf path but as I compiled the binaries manually so they exist in the different path now.

As https://github.com/elixir-lsp/vscode-elixir-ls required the elixir to be installed using the asdf path.

Refer to this issue. elixir-lsp/vscode-elixir-ls#208

Show how did you make it work with the custom build then as vscode extension requires asdf LOL ?

from elixir_sense.

Sky0307 avatar Sky0307 commented on June 28, 2024

Must I install elixir via asdf to use this? Im an Intel Mac user, I installed elixir via brew. And i have the same problems that i cant use the Go to Definition function with the VS Code extension

from elixir_sense.

Sky0307 avatar Sky0307 commented on June 28, 2024

I have fixed the issue. Here are the steps

  1. Download the source code zip from here https://github.com/elixir-lang/elixir/releases/tag/v1.12.3
  2. Unzip the file and rename it to elixir
  3. cd elixir
  4. make clean test
  5. Edit .bashrc or .zshrc file and it should be like this
. $HOME/.asdf/asdf.sh
export PATH=$PATH:/Users/khanakia/.asdf/shims
export PATH="$PATH:/Users/khanakia/D1/elixir/bin"
  1. Make sure you do not have elixir installed using asdf
  2. Run these commands
asdf global elixir path:/Users/khanakia/D1/elixir
asdf plugin add elixir
  1. Verify the asdf plugins by running asdf current and this will output
elixir          path:/Users/khanakia/D1/elixir /Users/khanakia/.tool-versions
erlang          24.1.4          /Users/khanakia/.tool-versions
  1. Confirm elixir -v
Erlang/OTP 24 [erts-12.1.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.12.3 (compiled with Erlang/OTP 24)
  1. Now you can open the vscode with elixir-ls plugin installed and it will fetch the core function definition e.g. IO.puts("demo") I can simply click the puts and it will open the IO code file

i tried these steps, however im stucked at step 4, i got the following error after running the command make clean test

rm -rf ebin
rm -rf lib//ebin
rm -rf lib/elixir/src/elixir_parser.erl
rm -rf lib/
/_build/
rm -rf lib/*/tmp/
rm -rf lib/elixir/test/ebin/
rm -rf lib/mix/test/fixtures/deps_on_git_repo/
rm -rf lib/mix/test/fixtures/git_rebar/
rm -rf lib/mix/test/fixtures/git_repo/
rm -rf lib/mix/test/fixtures/git_sparse_repo/
rm -f erl_crash.dump
rm -f man/elixir.1
rm -f man/elixir.1.bak
rm -f man/iex.1
rm -f man/iex.1.bak
make: erlc: No such file or directory
make: *** [lib/elixir/src/elixir_parser.erl] Error 1

from elixir_sense.

Sky0307 avatar Sky0307 commented on June 28, 2024

Can i ask the if go to definition function will only on default function such IO.inspect etc?

Currently i can see the definition of IO.inspect, IO.puts etc.

But, I have a helper.ex file and when i import it into another file(example, users.ex), i can't see the definition of the functions that is in the helper.ex from the users.ex file, is this normal?

from elixir_sense.

khanakia avatar khanakia commented on June 28, 2024

@Sky0307 the steps i gave once you perform VS Code Go To Definition will work for everything.

Regarding helper.ex you cannot inspect because you did not compile the file using elixirc. So there are 2 ways:

  1. Compile the helper.ex file within the same directory and then you will see the VS Code Definition
  2. Use mix to create a project. That the most common approach everybody uses.

from elixir_sense.

Sky0307 avatar Sky0307 commented on June 28, 2024

@khanakia Thanks for your help! I actually created my project with mix.
Anyway, I managed to get the extension working!
Here's a few things I did, hope it will help others who facing the same issue.

I am an Intel Mac user, I installed both elixir and asdf with brew.

Then, I did the following:

  1. edit .zshrc file

. /usr/local/opt/asdf/libexec/asdf.sh
export PATH=$PATH:/Users/skylee/.asdf/shims
export PATH="$PATH:/usr/local/Cellar/elixir/1.13.1"

  1. run the command

asdf global elixir path:/usr/local/Cellar/elixir/1.13.1/
asdf plugin add elixir

  1. asdf current gives me the following output

elixir path:/usr/local/Cellar/elixir/1.13.1/ /Users/skylee/.tool-versions
erlang path:/usr/local/Cellar/erlang/24.2/ /Users/skylee/.tool-versions

On top of this, I compiled my project with elixir -S mix phx.server

from elixir_sense.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.