docker-phoenix icon indicating copy to clipboard operation
docker-phoenix copied to clipboard

how to get :observer.start() to work within a container?

Open homanchou opened this issue 2 years ago • 3 comments

Just wondering if you were able to get observer to run from within vscode devcontainer?

homanchou avatar Apr 15 '22 01:04 homanchou

Hi @homanchou,

can you please give more details on how you are attempting to run and access observer.start()? Thanks!

nicbet avatar Apr 16 '22 05:04 nicbet

I open up my project, usually by typing code . at the windows subsystem for linux shell. vscode then detects the .devcontainer folder and asks me if I want to re-open vscode to develop in the container, I say yes. From the terminal tab inside vscode, I then open up my phoenix server using iex -S mix phx.server, then I'm at the iex prompt. From here, in non-dockerized projects, I am able to type :observer.start() and somehow a new window would pop-up that contains the process info and all that jazz. But with this current devcontainer setup I see this:

`:observer.start

(Erlang:648): Gtk-WARNING **: 17:42:32.687: gtk_disable_setlocale() must be called before gtk_init() 17:42:32: Error: Unable to initialize GTK+, is DISPLAY set properly? [error] WX ERROR: Could not load library: :load Library load-call unsuccessful (1). {:error, {{:error, {:load, 'Library load-call unsuccessful (1).'}}, [ {:wxe_server, :start, 1, [file: 'wxe_server.erl', line: 65]}, {:wx, :new, 1, [file: 'wx.erl', line: 115]}, {:observer_wx, :init, 1, [file: 'observer_wx.erl', line: 108]}, {:wx_object, :init_it, 6, [file: 'wx_object.erl', line: 404]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 226]} ]}} iex(9)>`

homanchou avatar Apr 16 '22 17:04 homanchou

Yes, X11 and GTK+ display output are not available in the container. You could modify the vscode container and add an X11 server, as well as a VNC server and connect to that - for example see https://elixirforum.com/t/cant-user-observer-start-inside-container/15179

nicbet avatar Apr 16 '22 20:04 nicbet