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…

Where Next?

Popular in Questions Top

greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
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
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41989 114
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
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
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
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New

We're in Beta

About us Mission Statement