Exadra37

Exadra37

Opening the source files from iex in the editor with `open` fails to find the file

From watching this Jose video https://youtu.be/suOzNeMJXl0?t=466 at minute 7:46 I see him opening the source file for Tuple.to_list from an iex session, but if a try to the same I get an error saying the file is not available:

docker run --rm -it hexpm/elixir:1.10.1-erlang-22.3.3-debian-buster-20200224 iex                                                           130 ↵
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Interactive Elixir (1.10.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> open Tuple.to_list
Could not open: "/usr/local/lib/elixir/bin/../lib/elixir/lib/tuple.ex". File is not available.
iex(2)> 

or with the docker official image:

docker run --rm -it elixir                                                 
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Interactive Elixir (1.10.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> open Tuple.to_list
Could not open: "/usr/local/lib/elixir/bin/../lib/elixir/lib/tuple.ex". File is not available.

If check the path in iex:

docker run --rm -it hexpm/elixir:1.10.1-erlang-22.3.3-debian-buster-20200224 iex
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]

Interactive Elixir (1.10.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :code.which Tuple
'/usr/local/lib/elixir/bin/../lib/elixir/ebin/Elixir.Tuple.beam'
iex(2)> 

We get a different path and file name. Why is this happening?

If we drop to bash shell the file is indeed in same path reported by :code.which Tuple

docker run --rm -it hexpm/elixir:1.10.1-erlang-22.3.3-debian-buster-20200224 bash
root@ff317b8171cc:/# ls -al /usr/local/lib/elixir/lib/elixir/ebin/Elixir.Tuple.beam
-rw-r--r-- 1 root root 3564 Apr 27 12:14 /usr/local/lib/elixir/lib/elixir/ebin/Elixir.Tuple.beam

So for some reason the function open doesn’t work in the same way as seen in the Jose video for the Elixir core, but if I try to open a file im my project it just works. I am wondering if this is anything related to be running Elixir installed in a MAC, that may use different folder structures to install Elixir when compared with Linux?

I also have the same issue when building docker images with Erlang and Elixir directly from Github releases.

To note that I don’t have Elixir installed in my host machine, because I never install any programming language or toolling in my host. Everything I can, runs from docker containers.

So I am curious if someone with Elixir installed in the Linux host is able to run open Tuple.to_list sucessefully?

Most Liked

gshaw

gshaw

I needed to make two changes:

  1. Uninstall Erlang and Elixir from Homebrew and install using asdf
  2. Tell IEx how to use VS Code to jump to a line number:
    export ELIXIR_EDITOR="code --goto __FILE__:__LINE__"
outlog

outlog

on mac with asdf I get:

iex(2)> open String.downcase

Could not open: “/Users/myuser/.asdf/installs/elixir/1.10.3-otp-22/bin/…/lib/elixir/lib/string.ex”. Please set the ELIXIR_EDITOR or EDITOR environment variables with the command line invocation of your favorite EDITOR.

which gives us enough to find Using Elixir 1.5's open command with terminal Emacs - DockYard

so if I do export ELIXIR_EDITOR="subl" and then iex - open String.downcase works :rocket:

Exadra37

Exadra37

Nice to know that for you is only missing the editor variable, but for us the error is another… doesn’t find the file :frowning:

Something really different across setups. Would love to know what…

gshaw

gshaw

I watched the same video and have installed Elixir to my Mac using Homebrew and an’t get the open or any other command related to the source file location to work.

Would love to have this ability. It looks really useful.

% iex
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Interactive Elixir (1.10.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> open String.downcase
Could not open: "/usr/local/Cellar/elixir/1.10.2/bin/../lib/elixir/lib/string.ex". File is not available.
iex(2)> 
NobbZ

NobbZ

The sources need to exist at the location that is referred to in the debug symbols of s module.

Does brew provide those? Elixir is complaining about not beeing able to find those files.

Where Next?

Popular in Questions Top

dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
Codball
Mix format works fine if run from the cmd. I’ve followed this to facilitate the implementation into VSC which involves downloading an ext...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New

Other popular topics Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
chrismccord
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement