nicbet / docker-phoenix

A dockerized Phoenix development and runtime environment.
GNU General Public License v3.0
277 stars 57 forks source link

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

Closed homanchou closed 9 months ago

homanchou commented 2 years ago

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

nicbet commented 2 years ago

Hi @homanchou,

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

homanchou commented 2 years ago

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)>`

nicbet commented 2 years ago

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