0
votes

I'm getting errors when running Elixir files inside Atom IDE when a dependency is referenced in the script.

I'm using the Atom package "Script" to run the file.

Here's the code:

# This Elixir code runs fine when using Atom package "Script"
IO.puts "hello world"

When a dependency is referenced (NimbleCSV in this case) I get the error:

IO.puts "hello world"
NimbleCSV.define(MyParser, separator: "\t", escape: "\"")

** (UndefinedFunctionError) function NimbleCSV.define/2 is undefined (module NimbleCSV is not available) NimbleCSV.define(MyParser, [separator: "\t", escape: "\""]) (stdlib) erl_eval.erl:669: :erl_eval.do_apply/6 (elixir) lib/code.ex:168: Code.eval_string/3

When running the same file in Terminal using "mix run [filename]" the file runs without errors.

How do I configure Atom so that is recognizes the Elixir dependencies?

1
Looks like it's a missing feature. That package just executes elixir -r <filename>: github.com/rgbkrk/atom-script/blob/… It should check for the existence of mix.exs in any parent folder and run mix run <filename> if it finds any.Dogbert
Any possible workarounds? Maybe a way to configure the Script package to execute mix run <filename> instead?Emily
Try applying these changes to the source of that package: gist.github.com/anonymous/a6f62f651a5215ed36f197aba8faf89e Note that this will break running Elixir scripts that are not in a mix project. An actual solution would require some more code. I'll see if I can find time to write that today.Dogbert
Thanks Dogbert. The changes worked.Emily

1 Answers

0
votes

If you are open to using a different package, take a look at build. In my opinion, it has the advantage of letting you choose a separate package as build provider. So, whenever there are several compilers to choose from, you can install a build provider (if available). As for Elixir, there actually is a build provider for mix.