** (FunctionClauseError) no function clause matching in System.find_executable/1

defmodule PythonStream do
  def go(params) do
    python_path = elem(params, 0)

    Exile.stream!(input: python_path)
    |> IO.inspect()
  end
end

Error:

** (FunctionClauseError) no function clause matching in System.find_executable/1    
    
    The following arguments were given to System.find_executable/1:
    
        # 1
        {:input, "python3 -u lib/Python/foo.py"}
    
    Attempted function clauses (showing 1 out of 1):
    
        def find_executable(program) when is_binary(program)
    
    (elixir 1.10.3) lib/system.ex:422: System.find_executable/1
    (exile 0.1.0) lib/exile/process.ex:320: Exile.Process.normalize_cmd/1
    (exile 0.1.0) lib/exile/process.ex:383: Exile.Process.normalize_args/2
    (exile 0.1.0) lib/exile/process.ex:43: Exile.Process.start_link/2
    (exile 0.1.0) lib/exile/stream.ex:39: Exile.Stream.__build__/2
    (sandbox 0.1.0) lib/Prototyping/PythonStream.ex:8: PythonStream.go/1
    (sandbox 0.1.0) lib/Bar.ex:125: Bar.main/0
    (sandbox 0.1.0) lib/Quux.ex:367: Quux.main/0

How is this issue resolved?

The first argument to Exile.stream!/2 needs to be a list of strings, of which the head is the command to run and the tail is the arguments to pass.

At least if you are talking about https://github.com/akash-akya/exile/blob/master/lib/exile.ex

2 Likes

You’re correct, this does concern Exile.

Attempt:

defmodule PythonStream do
  @private_key Credentials.quux() #Type: string

  def go() do
    python_process_path = "python3 -u Code%20Drafts/Python/stream_prototype.py"

    Exile.stream!([python_process_path, @private_key])
    |> IO.inspect()
  end
end

Error:

PythonStream.go
** (MatchError) no match of right hand side value: {:error, "command not found: \"python3 -u Code%20Drafts/Python/stream_prototype.py""}
    (exile 0.1.0) lib/exile/stream.ex:39: Exile.Stream.__build__/2
    (sandbox 0.1.0) lib/Prototyping/PythonStream.ex:18: PythonStream.go/0

Because you want to make your command and it’s arguments a list of strings and not a single string.

The way you have it now, it searches for the binary python3 -u Code%20Drafts/Python/stream_prototype.py in your PATH.

You probably want ["python", "-u", "Code Drafts/Python/stream_prototype.py", @private_key]

1 Like

Thanks for clarifying.

defmodule PythonStream do
  def go() do
    python_process_path =
    "python3 -u Code%20Drafts/Python/hello_world.py"
    |> String.split()

    python_process_path
    |> Exile.stream!()
  end
end
#hello_world.py

while True:
    print("Hello World!")
iex(1)> PythonStream.go
%Exile.Stream{
  process: #PID<0.656.0>,
  stream_opts: %{chunk_size: 65536, exit_timeout: :infinity, input: :no_input}
}
iex(32)> 
15:46:35.409 [error] GenServer #PID<0.656.0> terminating
** (ArgumentError) argument error
    (exile 0.1.0) Exile.ProcessNif.execute(['/usr/bin/python3', '-u', 'Code%20Drafts/Python/hello_world.py'], ['HOME=/home/maxximiliann', 'WINDOWPATH=2', 'XDG_RUNTIME_DIR=/run/user/1000', 'TERM=xterm-256color', 'VTE_VERSION=6003', 'COLORTERM=truecolor', 'GJS_DEBUG_TOPICS=JS ERROR;JS LOG', 'LANG=en_US.UTF-8', 'XDG_SESSION_CLASS=user', 'DESKTOP_SESSION=ubuntu', 'XDG_CURRENT_DESKTOP=ubuntu:GNOME', 'SSH_AUTH_SOCK=/run/user/1000/keyring/ssh', 'SHLVL=1', 'LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'XMODIFIERS=@im=ibus', 'GDMSESSION=ubuntu', 'MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path', 'PATH=/home/maxximiliann/.asdf/installs/erlang/23.1/erts-11.1/bin:/home/maxximiliann/.asdf/installs/erlang/23.1/bin:/home/maxximiliann/.asdf/plugins/elixir/shims:/home/maxximiliann/.asdf/installs/elixir/1.10.3-otp-22/bin:/home/maxximiliann/.asdf/installs/elixir/1.10.3-otp-22/.mix/escripts:/home/maxximiliann/.asdf/shims:/home/maxximiliann/.asdf/bin:/home/maxximiliann/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'GJS_DEBUG_OUTPUT=stderr', 'LESSCLOSE=/usr/bin/lesspipe %s %s', 'QT_ACCESSIBILITY=1', 'IM_CONFIG_PHASE=1', 'GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/c963629c_9e90_44fe_a92e_f8be9f3dc53e', 'ROOTDIR=/home/maxximiliann/.asdf/installs/erlang/23.1', 'QT_IM_MODULE=ibus', 'GNOME_DESKTOP_SESSION_ID=this-is-deprecated', 'OLDPWD=/home/maxximiliann', 'XDG_SESSION_TYPE=x11', 'GNOME_TERMINAL_SERVICE=:1.159930', 'SHELL=/bin/bash', 'XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg', 'GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1', 'DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus', 'XDG_SESSION_DESKTOP=ubuntu', 'BINDIR=/home/maxximiliann/.asdf/installs/erlang/23.1/erts-11.1/bin', 'SESSION_MANAGER=local/Maxximiliann:@/tmp/.ICE-unix/1837,unix/Maxximiliann:/tmp/.ICE-unix/1837', 'XAUTHORITY=/run/user/1000/gdm/Xauthority', 'PWD=/home/maxximiliann/Desktop/Arbit', 'ASDF_DIR=/home/maxximiliann/.asdf', 'LESSOPEN=| /usr/bin/lesspipe %s', 'PROGNAME=erl', 'USERNAME=maxximiliann', 'MIX_HOME=/home/maxximiliann/.asdf/installs/elixir/1.10.3-otp-22/.mix', 'MANAGERPID=1580', 'XDG_MENU_PREFIX=gnome-', 'EMU=beam', 'GTK_MODULES=gail:atk-bridge', 'LOGNAME=maxximiliann', 'USER=maxximiliann', 'DISPLAY=:0', ...], [], 0)
    (exile 0.1.0) lib/exile/process.ex:113: Exile.Process.handle_continue/2
    (stdlib 3.13.2) gen_server.erl:680: :gen_server.try_dispatch/4
    (stdlib 3.13.2) gen_server.erl:431: :gen_server.loop/7
    (stdlib 3.13.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: {:continue, nil}
State: %Exile.Process{args: %{cd: [], cmd_with_args: ['/usr/bin/python3', '-u', 'Code%20Drafts/Python/hello_world.py'], env: ['HOME=/home/maxximiliann', 'WINDOWPATH=2', 'XDG_RUNTIME_DIR=/run/user/1000', 'TERM=xterm-256color', 'VTE_VERSION=6003', 'COLORTERM=truecolor', 'GJS_DEBUG_TOPICS=JS ERROR;JS LOG', 'LANG=en_US.UTF-8', 'XDG_SESSION_CLASS=user', 'DESKTOP_SESSION=ubuntu', 'XDG_CURRENT_DESKTOP=ubuntu:GNOME', 'SSH_AUTH_SOCK=/run/user/1000/keyring/ssh', 'SHLVL=1', 'LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:', 'XMODIFIERS=@im=ibus', 'GDMSESSION=ubuntu', 'MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path', 'PATH=/home/maxximiliann/.asdf/installs/erlang/23.1/erts-11.1/bin:/home/maxximiliann/.asdf/installs/erlang/23.1/bin:/home/maxximiliann/.asdf/plugins/elixir/shims:/home/maxximiliann/.asdf/installs/elixir/1.10.3-otp-22/bin:/home/maxximiliann/.asdf/installs/elixir/1.10.3-otp-22/.mix/escripts:/home/maxximiliann/.asdf/shims:/home/maxximiliann/.asdf/bin:/home/maxximiliann/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin', 'GJS_DEBUG_OUTPUT=stderr', 'LESSCLOSE=/usr/bin/lesspipe %s %s', 'QT_ACCESSIBILITY=1', 'IM_CONFIG_PHASE=1', 'GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/c963629c_9e90_44fe_a92e_f8be9f3dc53e', 'ROOTDIR=/home/maxximiliann/.asdf/installs/erlang/23.1', 'QT_IM_MODULE=ibus', 'GNOME_DESKTOP_SESSION_ID=this-is-deprecated', 'OLDPWD=/home/maxximiliann', 'XDG_SESSION_TYPE=x11', 'GNOME_TERMINAL_SERVICE=:1.159930', 'SHELL=/bin/bash', 'XDG_CONFIG_DIRS=/etc/xdg/xdg-ubuntu:/etc/xdg', 'GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1', 'DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus', 'XDG_SESSION_DESKTOP=ubuntu', 'BINDIR=/home/maxximiliann/.asdf/installs/erlang/23.1/erts-11.1/bin', 'SESSION_MANAGER=local/Maxximiliann:@/tmp/.ICE-unix/1837,unix/Maxximiliann:/tmp/.ICE-unix/1837', 'XAUTHORITY=/run/user/1000/gdm/Xauthority', 'PWD=/home/maxximiliann/Desktop/Arbit', 'ASDF_DIR=/home/maxximiliann/.asdf', 'LESSOPEN=| /usr/bin/lesspipe %s', 'PROGNAME=erl', 'USERNAME=maxximiliann', 'MIX_HOME=/home/maxximiliann/.asdf/installs/elixir/1.10.3-otp-22/.mix', 'MANAGERPID=1580', 'XDG_MENU_PREFIX=gnome-', 'EMU=beam', ...], stderr_to_console: 0}, await: %{}, context: nil, errno: nil, pending_read: %Exile.Process.Pending{bin: [], client_pid: nil, remaining: 0}, pending_write: %Exile.Process.Pending{bin: [], client_pid: nil, remaining: 0}, status: :init}
 
nil

What’s keeping the Python process from communicating with its Elixir counterpart?

This error message seems to indicate that it is.

Yeah sorry, brain fart. I only worked with exile once. :smiley:

1 Like

It’s ok, I appreciate your effort :slight_smile:

A badarg from Exile.ProcessNif.execute can happen in these circumstances:

  1. The first argument is not a list
  2. Number of arguments exceeds MAX_ARGUMENTS (In the implementation I look at, it is 50)
  3. A single argument is longer than MAX_ARGUMENT_LEN (In the implementation I look at it is 1024)
  4. The list passed at first argument is “improper”

There are other occasions as well, though my C and ERL_NIF knowledge aren’t good enough to read those.

Though I guess that the length limitation for arguments is also true for environment variables, and your LS_COLORS is huge, it has a length of 1505 characters. Try again with a cleaned :env.

PS: The library should log to stderr as far as I read the code, at least on some of the errors mentioned above…

1 Like

Thanks @nobbz and @dimitarvp for helping. It is still under development, I’m not able to find time to finish the planned pending changes :sweat_smile:

Hi @Maxximiliann I fixed this issue in the master now, can you check?

Perhaps github issues section might be better place to report/discuss issues since currently user of Exile is mostly me I think.

2 Likes

The only thing I contributed is to demonstrate yet again that I shouldn’t post when I am in bed with the phone. :003:

1 Like

:laughing:

Updated github with the latest trial results. Another issue cropped up although it may just be the result of incorrect use? Thoughts?