LoginSignup
0

More than 3 years have passed since last update.

WSL上でElixirを使うときにモニタリングツールが起動できなかった件

Last updated at Posted at 2019-06-28

はじめに

某会社さんでElixirを始めて触った時に、WSL上のElixirでライブラリをインストールするときにエラーが発生したのでその解決策をメモ

もう一つ、WSL上でElixirを動かすときにライブラリがインストールできなかったのでそちらもどうぞ→WSL上でElixirを使うときにライブラリがインストールできなかった件

環境

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic

問題

WSLのUbuntu環境にて、モニタリングツールを実行時にエラーが起きた

$ iex
Erlang/OTP 22 [erts-10.4.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Interactive Elixir (1.8.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :observer.start
** (UndefinedFunctionError) function :observer.start/0 is undefined (module :observer is not available)
    :observer.start()

$ sudo apt-get install -y erlang-observer実行後、もう一度試したら次のようなエラーが起きた

iex(1)> :observer.start
00:28:52: Error: Unable to initialize GTK+, is DISPLAY set properly?
                                                                    {:error,
 {{:einval, 'Could not initiate graphics'},
  [
    {: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: 107]},
    {:wx_object, :init_it, 6, [file: 'wx_object.erl', line: 372]},
    {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}
  ]}}

解決

Windows上でVcXsrv Windows X Serverをインストール
https://sourceforge.net/projects/vcxsrv/

VcXsrvを起動
https://www.atmarkit.co.jp/ait/articles/1812/06/news040.html

WSL上で以下のコマンドを実行

$ echo ‘export DISPLAY=:0.0’ >> .profile
$ source .profile

改めてiexからコマンドを実行

$ iex
Erlang/OTP 22 [erts-10.4.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]

Interactive Elixir (1.8.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :observer.start
:ok
iex(2)>

うまく起動できました

image

Macと比べると面倒ですね・・・はやくMacBookほしいです

参考サイト

https://www.walknsqualk.com/post/elixir-on-wsl/
https://www.atmarkit.co.jp/ait/articles/1812/06/news040.html
https://torisky.com/wsl%E3%81%A7%E3%82%A8%E3%83%A9%E3%83%BC%EF%BC%9Aerror-cant-open-display%E3%81%AE%E5%AF%BE%E5%87%A6/

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0