Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to run in an x11/WSL2 environment? #279

Closed
affans opened this issue Apr 19, 2021 · 9 comments · Fixed by #280
Closed

Possible to run in an x11/WSL2 environment? #279

affans opened this issue Apr 19, 2021 · 9 comments · Fixed by #280
Labels
electron Issues related to the underlying Electron instance question windows

Comments

@affans
Copy link

affans commented Apr 19, 2021

I have a Windows 10 machine with WSL2 running (i.e. full linux kernel). I have an X11 server running that works with other Julia packages (i.e. Plots.jl and Gnuplot.jl) where the GUI is pushed through x11. However, this dosn't work for Blink.

julia> using Blink

julia> w = Window() # Open a new window
ERROR: IOError: connect: connection refused (ECONNREFUSED)
Stacktrace:
  [1] wait_connected(x::Sockets.TCPSocket)
    @ Sockets /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Sockets/src/Sockets.jl:532
  [2] connect
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Sockets/src/Sockets.jl:567 [inlined]
  [3] connect(addr::Sockets.IPv4, port::Int64)
    @ Sockets /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Sockets/src/Sockets.jl:553
  [4] try_connect(::Sockets.IPv4, ::Vararg{Any, N} where N; interval::Float64, attempts::Int64)
    @ Blink.AtomShell ~/.julia/packages/Blink/mwJC9/src/AtomShell/process.jl:79
  [5] try_connect
    @ ~/.julia/packages/Blink/mwJC9/src/AtomShell/process.jl:77 [inlined]
  [6] init(; debug::Bool)
    @ Blink.AtomShell ~/.julia/packages/Blink/mwJC9/src/AtomShell/process.jl:93
  [7] #shell#9
    @ ~/.julia/packages/Blink/mwJC9/src/AtomShell/process.jl:149 [inlined]
  [8] shell
    @ ~/.julia/packages/Blink/mwJC9/src/AtomShell/process.jl:144 [inlined]
  [9] #Window#14
    @ ~/.julia/packages/Blink/mwJC9/src/AtomShell/window.jl:89 [inlined]
 [10] Window()
    @ Blink.AtomShell ~/.julia/packages/Blink/mwJC9/src/AtomShell/window.jl:89
 [11] top-level scope
    @ REPL[8]:1
@twavv
Copy link
Member

twavv commented Apr 19, 2021

Not sure about this. If you (or anyone) want to debug further, the ECONNREFUSED probably comes from Blink.jl trying to connect to the Electron process. Instrumenting the Blink.jl code to print out the stdout/stderr from the Elector process (or log it to a file or whataver) would probably help explain why it's failing to connect.

@pfitzseb
Copy link
Member

pfitzseb commented Apr 19, 2021

It's possible that

conn = try_connect(ip"127.0.0.1", p)

needs to connect to 0.0.0.0 or localhost directly, instead of 127.0.0.1 as per this. Can you give that a try?

@twavv
Copy link
Member

twavv commented Apr 19, 2021

@pfitzseb Seems like that article is talking about external machines accessing a port on the localhost.

I've seen an error like this before that boiled down to the Electron subprocess failing to start (thus the connection fails since Electron isn't actually listening on that port).

@affans
Copy link
Author

affans commented Apr 19, 2021

@pfitzseb I tried that but could it also be a port problem? I changed to

 println("initializaing to local host on port $p")
  #conn = try_connect(ip"127.0.0.1", p)
  conn = try_connect(ip"0.0.0.0", p)

and got output

julia> w = Window() # Open a new window
initializaing to local host on port 4193
attemping to connect
ERROR: IOError: connect: connection refused (ECONNREFUSED)

With debug information printed, I get

julia> w = Window() # Open a new window
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: x-www-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: firefox: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: iceweasel: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: seamonkey: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: mozilla: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: epiphany: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: konqueror: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: google-chrome: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'http://localhost:8080/debug?port=2024'
ERROR: failed process: Process(`xdg-open 'http://localhost:8080/debug?port=2024'`, ProcessExited(3)) [3]

so seems like I need maybe a browser installed on my WSL2?

@pfitzseb
Copy link
Member

That shouldn't be necessary -- I suspect you only got that output because you turned debug info on ;) I'll look into getting a WSL env set up at some point...

@affans
Copy link
Author

affans commented Apr 20, 2021

It might be ... so first I did [/mnt/c/Users/affan]$ export BROWSER=/usr/local/bin/edge where edge is a symbolic link to my MS Edge browser on the Win 10 machine.

Then running

julia> w = Window() # Open a new window
true
initializaing to local host
/home/affan/.julia/dev/Blink/deps/atom/electron: error while loading shared libraries: libasound.so.2: cannot open shared object file: No such file or directory
ERROR: IOError: connect: connection refused (ECONNREFUSED)
Stacktrace:
  [1] wait_connected(x::Sockets.TCPSocket)
    @ Sockets /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Sockets/src/Sockets.jl:532
  [2] connect
    @ /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Sockets/src/Sockets.jl:567 [inlined]
  [3] connect(addr::Sockets.IPv4, port::Int64)
    @ Sockets /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/Sockets/src/Sockets.jl:553
  [4] try_connect(::Sockets.IPv4, ::Vararg{Any, N} where N; interval::Float64, attempts::Int64)
    @ Blink.AtomShell ~/.julia/dev/Blink/src/AtomShell/process.jl:80
  [5] try_connect
    @ ~/.julia/dev/Blink/src/AtomShell/process.jl:78 [inlined]
  [6] init(; debug::Bool)
    @ Blink.AtomShell ~/.julia/dev/Blink/src/AtomShell/process.jl:98
  [7] #shell#9
    @ ~/.julia/dev/Blink/src/AtomShell/process.jl:155 [inlined]
  [8] shell
    @ ~/.julia/dev/Blink/src/AtomShell/process.jl:150 [inlined]
  [9] #Window#14
    @ ~/.julia/dev/Blink/src/AtomShell/window.jl:89 [inlined]
 [10] Window()
    @ Blink.AtomShell ~/.julia/dev/Blink/src/AtomShell/window.jl:89
 [11] top-level scope
    @ REPL[3]:1

so the xdg-open errors have gone away and indeed the browser pops up and points to http://localhost:8080/debug?port=6256 (which fails because of networking stuff I am not familiar with)

@twavv
Copy link
Member

twavv commented Apr 20, 2021

Yep, looks like Electron is failing to start. You should be able to simply launch electron by running /home/affan/.julia/dev/Blink/deps/atom/electron (which should make figuring out exactly why it's failing to launch easier).

That error (libasound.so.2: cannot open shared object file: No such file or directory) implies that libasound2 is not installed. I think you can just install it with apt install libasound2 (WSL uses Debian/Ubuntu right?). There might be a few other libraries you have to install as well if they come up as issues.

@twavv twavv added windows electron Issues related to the underlying Electron instance question labels Apr 20, 2021
@affans
Copy link
Author

affans commented Apr 20, 2021

Ahh success

*[master][~/.julia/dev/Blink/deps/atom]$ ./electron
./electron: error while loading shared libraries: libasound.so.2: cannot open shared object file: No such file or directory

*[master][~/.julia/dev/Blink/deps/atom]$ sudo apt-get install libasound2
... installing ...
*[master][~/.julia/dev/Blink/deps/atom]$ ./electron

Electron 4.0.4 - Build cross platform desktop apps with JavaScript, HTML, and CSS
Usage: electron [options] [path]

and then

julia> w = Window() # Open a new window
true
initializaing to local host
connecting finished
Window(1, Electron(Process(`/home/affan/.julia/dev/Blink/deps/atom/electron --debug=9700 /home/affan/.julia/dev/Blink/src/AtomShell/main.js port 4252`, ProcessRunning), Sockets.TCPSocket(RawFD(21) active, 0 bytes waiting), Dict{String, Any}("callback" => Blink.var"#1#2"())), Page(1, WebSocket(server, CONNECTED), Dict{String, Any}("webio" => Blink.AtomShell.var"#22#23"{Blink.AtomShell.WebIOBlinkComm}(Blink.AtomShell.WebIOBlinkComm(Window(#= circular reference @-5 =#))), "callback" => Blink.var"#1#2"()), Distributed.Future(1, 1, 1, Some(true))), Task (done) @0x00007f1cc686f880)

julia> body!(w, "Hello World")
Page(1, WebSocket(server, CONNECTED), Dict{String, Any}("webio" => Blink.AtomShell.var"#22#23"{Blink.AtomShell.WebIOBlinkComm}(Blink.AtomShell.WebIOBlinkComm(Window(1, Electron(Process(`/home/affan/.julia/dev/Blink/deps/atom/electron --debug=9700 /home/affan/.julia/dev/Blink/src/AtomShell/main.js port 4252`, ProcessRunning), Sockets.TCPSocket(RawFD(21) active, 0 bytes waiting), Dict{String, Any}("callback" => Blink.var"#1#2"())), Page(#= circular reference @-5 =#), Task (done) @0x00007f1cc686f880))), "callback" => Blink.var"#1#2"()), Distributed.Future(1, 1, 1, Some(true)))

Can the issue be closed? I would say that an edit to README to try running electron directly might solve some problems.

Edit: WSL2 is a minimal vm and I have Ubuntu installed on it. I don't know why that particular library wasn't there by default.

@affans
Copy link
Author

affans commented Apr 23, 2021

@travigd @pfitzseb It seems like there is still a slight issue. Seems like there needs to be a browser installed (or atleast a BROWSER env variable set).

julia> browse(df)
true
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: x-www-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: firefox: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: iceweasel: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: seamonkey: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: mozilla: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: epiphany: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: konqueror: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: chromium-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: google-chrome: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: www-browser: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links2: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: elinks: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: links: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: lynx: not found
/usr/bin/xdg-open: 851: /usr/bin/xdg-open: w3m: not found
xdg-open: no method available for opening 'http://localhost:8080/debug?port=9715'
ERROR: failed process: Process(`xdg-open 'http://localhost:8080/debug?port=9715'`, ProcessExited(3)) [3]

Stacktrace:
  [1] pipeline_error
    @ ./process.jl:525 [inlined]
  [2] run(::Cmd; wait::Bool)
    @ Base ./process.jl:440
  [3] run
    @ ./process.jl:438 [inlined]
  [4] inspector(port::Int64)
    @ Blink.AtomShell ~/.julia/dev/Blink/src/AtomShell/process.jl:38
  [5] init(; debug::Bool)
    @ Blink.AtomShell ~/.julia/dev/Blink/src/AtomShell/process.jl:93
  [6] #shell#9
    @ ~/.julia/dev/Blink/src/AtomShell/process.jl:155 [inlined]
  [7] shell
    @ ~/.julia/dev/Blink/src/AtomShell/process.jl:150 [inlined]
  [8] #Window#14
    @ ~/.julia/dev/Blink/src/AtomShell/window.jl:89 [inlined]
  [9] Window
    @ ~/.julia/dev/Blink/src/AtomShell/window.jl:89 [inlined]
 [10] browse(df::DataFrame; kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ FloatingTableView ~/.julia/packages/FloatingTableView/foXK9/src/FloatingTableView.jl:64
 [11] browse(df::DataFrame)
    @ FloatingTableView ~/.julia/packages/FloatingTableView/foXK9/src/FloatingTableView.jl:63
 [12] top-level scope
    @ REPL[3]:1

With my case, I can do export BROWSER=/usr/local/bin/edge which is a symlink to my edge browser on the win10 machine. Then running browse(df) pops open a tab pointing to localhost:xxxx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron Issues related to the underlying Electron instance question windows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants