Simulator can't initialize SDL2 (linux)

I'm getting the following error when attempting to run the simulator:

SDL2 could not be initalized (1).
SDL2 is required for the Playdate Simulator to run and it will now quit.

I'm running on linux and I'm pretty sure I have SDL2 installed correctly, but maybe not?
Is there more useful information, like some logs or something?
Not sure if it matters, but I'm running the simulator via the command line.

Hello,

I'm pretty new to the playdate ecosystem, so I may not be the best person to help.

I think to get started, you can start by checking that SDL2 is installed on your computer.
Which distro are you running ?

As an example, I checked that the libsdl2 is installed on my debian distribution with dpkg:

$ dpkg -l | grep sdl2
ii  libsdl2-2.0-0:amd64                   2.0.14+dfsg2-3+deb11u1           amd64        Simple DirectMedia Layer
ii  libsdl2-2.0-0:i386                    2.0.14+dfsg2-3+deb11u1           i386         Simple DirectMedia Layer

If the SDL2 library is installed on your computer, the problem might be related to the command line you use to launch the playdate simulator indeed.

By the way, have you the $PLAYDATE_SDK_PATH variable defined on your system ?

Thanks for answering. I'm running nixos and I verified that SDL2 was added to my LD_LIBRARY_PATH:

$ echo $LD_LIBRARY_PATH
/nix/store/7k6ks2xfc74x40hxm39qy9anl9kr31zx-playdate_sdk-2.0.1/lib /nix/store/x4b56w1qjlml9s2vrjrpjs5kfals8m2m-gcc-arm-embedded-11.3.rel1/lib /nix/store/4igdc32rmnijcra8y3r1h42987ghzag2-gcc-12.3.0-lib/lib /nix/store/jf8y3nz89k3hxj3r4mvlp6mccsj8hdc2-gtk+3-3.24.38/lib /nix/store/ah31a45w9n6r45idnrxg24gy0pkm5r0f-pango-1.50.14/lib /nix/store/mmzy648hv7642a75ach528a1ychjmbd4-cairo-1.16.0/lib /nix/store/13r8c07d3xhgkaqgvap0hyx2v5nq7jf2-gdk-pixbuf-2.42.10/lib /nix/store/5gs8a87g7dfy1pgylzc7bgri68fd8a66-glib-2.76.4/lib /nix/store/bc20cpwxxmjfzw7gyd86vxc97akka20q-webkitgtk-2.40.5+abi=4.0/lib /nix/store/k3w1agqdhvqpzzia68vkjwj71qdz93jw-libX11-1.8.6/lib /nix/store/ikcs0s1r0qm4rhy58qsih474q1ah6b5g-libxkbcommon-1.5.0/lib /nix/store/r2s9kgxr38ypw4yvy4h4sxfc2iv1k6ws-wayland-1.22.0/lib /nix/store/pm4gxdsl1jjn3yr063si78b6636vvda7-systemd-253.6/lib /nix/store/ys75kpw9nn0ydbxm2w7wi1gd0bl1s0cv-SDL2-2.28.1/lib /nix/store/s8xs0b4xjghnck56vzbprg5i8zssrs4c-pkg-config-wrapper-0.29.2/lib

I also ran ldd against the simulator and it looks like all the shared libraries are present, curiously SDL2 is not listed:

$ ldd (which PlaydateSimulator)
	linux-vdso.so.1 (0x00007ffc93d68000)
	libudev.so.1 => /nix/store/pm4gxdsl1jjn3yr063si78b6636vvda7-systemd-253.6/lib/libudev.so.1 (0x00007f819cc72000)
	libgtk-3.so.0 => /nix/store/jf8y3nz89k3hxj3r4mvlp6mccsj8hdc2-gtk+3-3.24.38/lib/libgtk-3.so.0 (0x00007f819c488000)
	libgdk-3.so.0 => /nix/store/jf8y3nz89k3hxj3r4mvlp6mccsj8hdc2-gtk+3-3.24.38/lib/libgdk-3.so.0 (0x00007f819c37b000)
	libpangocairo-1.0.so.0 => /nix/store/ah31a45w9n6r45idnrxg24gy0pkm5r0f-pango-1.50.14/lib/libpangocairo-1.0.so.0 (0x00007f819c368000)
	libpango-1.0.so.0 => /nix/store/ah31a45w9n6r45idnrxg24gy0pkm5r0f-pango-1.50.14/lib/libpango-1.0.so.0 (0x00007f819c2fd000)
	libcairo.so.2 => /nix/store/mmzy648hv7642a75ach528a1ychjmbd4-cairo-1.16.0/lib/libcairo.so.2 (0x00007f819c1c1000)
	libgdk_pixbuf-2.0.so.0 => /nix/store/13r8c07d3xhgkaqgvap0hyx2v5nq7jf2-gdk-pixbuf-2.42.10/lib/libgdk_pixbuf-2.0.so.0 (0x00007f819c194000)
	libgio-2.0.so.0 => /nix/store/5gs8a87g7dfy1pgylzc7bgri68fd8a66-glib-2.76.4/lib/libgio-2.0.so.0 (0x00007f819bfa9000)
	libgobject-2.0.so.0 => /nix/store/5gs8a87g7dfy1pgylzc7bgri68fd8a66-glib-2.76.4/lib/libgobject-2.0.so.0 (0x00007f819bf46000)
	libglib-2.0.so.0 => /nix/store/5gs8a87g7dfy1pgylzc7bgri68fd8a66-glib-2.76.4/lib/libglib-2.0.so.0 (0x00007f819bdfe000)
	libwebkit2gtk-4.0.so.37 => /nix/store/bc20cpwxxmjfzw7gyd86vxc97akka20q-webkitgtk-2.40.5+abi=4.0/lib/libwebkit2gtk-4.0.so.37 (0x00007f81973fd000)
	libX11.so.6 => /nix/store/k3w1agqdhvqpzzia68vkjwj71qdz93jw-libX11-1.8.6/lib/libX11.so.6 (0x00007f81972b8000)
	libpthread.so.0 => /nix/store/ibp4camsx1mlllwzh32yyqcq2r2xsy1a-glibc-2.37-8/lib/libpthread.so.0 (0x00007f81972b3000)
	libdl.so.2 => /nix/store/ibp4camsx1mlllwzh32yyqcq2r2xsy1a-glibc-2.37-8/lib/libdl.so.2 (0x00007f81972ac000)
	libstdc++.so.6 => /nix/store/4igdc32rmnijcra8y3r1h42987ghzag2-gcc-12.3.0-lib/lib/libstdc++.so.6 (0x00007f8197084000)
	libm.so.6 => /nix/store/ibp4camsx1mlllwzh32yyqcq2r2xsy1a-glibc-2.37-8/lib/libm.so.6 (0x00007f8196fa4000)
	libgcc_s.so.1 => /nix/store/4igdc32rmnijcra8y3r1h42987ghzag2-gcc-12.3.0-lib/lib/libgcc_s.so.1 (0x00007f8196f83000)
	libc.so.6 => /nix/store/ibp4camsx1mlllwzh32yyqcq2r2xsy1a-glibc-2.37-8/lib/libc.so.6 (0x00007f8196d9d000)
	/nix/store/ibp4camsx1mlllwzh32yyqcq2r2xsy1a-glibc-2.37-8/lib/ld-linux-x86-64.so.2 => /nix/store/ibp4camsx1mlllwzh32yyqcq2r2xsy1a-glibc-2.37-8/lib64/ld-linux-x86-64.so.2 (0x00007f819e2b7000)
	libxkbcommon.so.0 => /nix/store/ikcs0s1r0qm4rhy58qsih474q1ah6b5g-libxkbcommon-1.5.0/lib/libxkbcommon.so.0 (0x00007f8196d55000)
	libwayland-cursor.so.0 => /nix/store/r2s9kgxr38ypw4yvy4h4sxfc2iv1k6ws-wayland-1.22.0/lib/libwayland-cursor.so.0 (0x00007f8196d4b000)
	libwayland-egl.so.1 => /nix/store/r2s9kgxr38ypw4yvy4h4sxfc2iv1k6ws-wayland-1.22.0/lib/libwayland-egl.so.1 (0x00007f8196d46000)
	libwayland-client.so.0 => /nix/store/r2s9kgxr38ypw4yvy4h4sxfc2iv1k6ws-wayland-1.22.0/lib/libwayland-client.so.0 (0x00007f8196d34000)
	libjavascriptcoregtk-4.0.so.18 => /nix/store/bc20cpwxxmjfzw7gyd86vxc97akka20q-webkitgtk-2.40.5+abi=4.0/lib/libjavascriptcoregtk-4.0.so.18 (0x00007f819514d000)
	libcap.so.2 => /nix/store/d729a24im9pcbz5hmdvvri4brwqby8kk-libcap-2.69-lib/lib/libcap.so.2 (0x00007f819513f000)
	libgmodule-2.0.so.0 => /nix/store/5gs8a87g7dfy1pgylzc7bgri68fd8a66-glib-2.76.4/lib/libgmodule-2.0.so.0 (0x00007f8195138000)
	libharfbuzz.so.0 => /nix/store/hysm64xr80n6ykrlqrsqwbxv12ihn715-harfbuzz-7.3.0/lib/libharfbuzz.so.0 (0x00007f819501c000)
	libpangoft2-1.0.so.0 => /nix/store/ah31a45w9n6r45idnrxg24gy0pkm5r0f-pango-1.50.14/lib/libpangoft2-1.0.so.0 (0x00007f8195001000)
	libfontconfig.so.1 => /nix/store/jlkh099qcdd2j919h2y217w3xgfss6q0-fontconfig-2.14.2-lib/lib/libfontconfig.so.1 (0x00007f8194fb4000)
	libfribidi.so.0 => /nix/store/gh1r3jfqa3d82xc5klyh4hx3p68bhwg1-fribidi-1.0.13/lib/libfribidi.so.0 (0x00007f8194f94000)
	libcairo-gobject.so.2 => /nix/store/mmzy648hv7642a75ach528a1ychjmbd4-cairo-1.16.0/lib/libcairo-gobject.so.2 (0x00007f8194f89000)
	libatk-1.0.so.0 => /nix/store/sal68rv7jr1jiicvaxgc5zsjdgz6bk2n-at-spi2-core-2.48.3/lib/libatk-1.0.so.0 (0x00007f8194f60000)
	libepoxy.so.0 => /nix/store/nyf39jfay1izmf1x2wkzmqkda5zx09ch-libepoxy-1.5.10/lib/libepoxy.so.0 (0x00007f8194e29000)
	libXi.so.6 => /nix/store/04p7x1xhrc6hiws0gwpnvhyls5dq9hsz-libXi-1.8.1/lib/libXi.so.6 (0x00007f8194e15000)
	libatk-bridge-2.0.so.0 => /nix/store/sal68rv7jr1jiicvaxgc5zsjdgz6bk2n-at-spi2-core-2.48.3/lib/libatk-bridge-2.0.so.0 (0x00007f8194dd8000)
	libtracker-sparql-3.0.so.0 => /nix/store/602yyxf6ykjpaj130xs2c34bi6mr1nwq-tracker-3.5.3/lib/libtracker-sparql-3.0.so.0 (0x00007f8194d06000)
	libXfixes.so.3 => /nix/store/qcyayd6skll6143jwsxraq1yy25jcikx-libXfixes-6.0.1/lib/libXfixes.so.3 (0x00007f8194cfe000)
	libXext.so.6 => /nix/store/hz2cw1szf2xmy8lcryz685qi50l58pz3-libXext-1.3.5/lib/libXext.so.6 (0x00007f8194ce7000)
	libXcursor.so.1 => /nix/store/jh4jv0v6pxjdh7zcrg4vqg0j1c19vwmh-libXcursor-1.2.1/lib/libXcursor.so.1 (0x00007f8194cda000)
	libXdamage.so.1 => /nix/store/yyar0v0qlwbnlvjhh1vssp5bnf649nhm-libXdamage-1.1.6/lib/libXdamage.so.1 (0x00007f8194cd5000)
	libXcomposite.so.1 => /nix/store/zi9rg9a4vjqky3gia3ck9421bs88cf6z-libXcomposite-0.4.6/lib/libXcomposite.so.1 (0x00007f8194cce000)
	libXrandr.so.2 => /nix/store/y9amcxznwjajhp8m01qdq9bd8vq6i76v-libXrandr-1.5.3/lib/libXrandr.so.2 (0x00007f8194cc1000)
	libXinerama.so.1 => /nix/store/caz1n4jn97ygm9ja6ymbmmg55vmx1nvc-libXinerama-1.1.5/lib/libXinerama.so.1 (0x00007f8194cbc000)
	libthai.so.0 => /nix/store/pbgggi1xlblgwhdshqawqklj7wiknycs-libthai-0.1.29/lib/libthai.so.0 (0x00007f8194cb0000)
	libpixman-1.so.0 => /nix/store/qqg0k2xkdh6ygzc08zgc0izl4hn4mrnw-pixman-0.42.2/lib/libpixman-1.so.0 (0x00007f8194c03000)
	libfreetype.so.6 => /nix/store/mrb32818q23q7b8pjvnq1fdrwdmmbkfy-freetype-2.13.1/lib/libfreetype.so.6 (0x00007f8194b36000)
	libEGL.so.1 => /nix/store/i1wjf5x2jdzbyxyqrywgbzbdcsvaljv2-libglvnd-1.6.0/lib/libEGL.so.1 (0x00007f8194b20000)
	libpng16.so.16 => /nix/store/mppz0yhlnna153fmw03hd4r364mq07z6-libpng-apng-1.6.39/lib/libpng16.so.16 (0x00007f8194ae7000)
	libxcb-shm.so.0 => /nix/store/g93jp1k5j47zxqjnd1h0a8aixhiczz28-libxcb-1.15/lib/libxcb-shm.so.0 (0x00007f8194ae0000)
	libxcb.so.1 => /nix/store/g93jp1k5j47zxqjnd1h0a8aixhiczz28-libxcb-1.15/lib/libxcb.so.1 (0x00007f8194ab5000)
	libxcb-render.so.0 => /nix/store/g93jp1k5j47zxqjnd1h0a8aixhiczz28-libxcb-1.15/lib/libxcb-render.so.0 (0x00007f8194aa6000)
	libXrender.so.1 => /nix/store/2yn2dy4c7a2rsjrc5s7anllwi7c29760-libXrender-0.9.11/lib/libXrender.so.1 (0x00007f8194a99000)
	libz.so.1 => /nix/store/p9a2nhhpa2dwyw1sy5gr4482ddqmwpkx-zlib-1.2.13/lib/libz.so.1 (0x00007f8194a7b000)
	libGL.so.1 => /nix/store/i1wjf5x2jdzbyxyqrywgbzbdcsvaljv2-libglvnd-1.6.0/lib/libGL.so.1 (0x00007f81949eb000)
	librt.so.1 => /nix/store/ibp4camsx1mlllwzh32yyqcq2r2xsy1a-glibc-2.37-8/lib/librt.so.1 (0x00007f81949e6000)
	libjpeg.so.62 => /nix/store/apxprd9vm5zsr6aw5ljwcj3w4cb6cidf-libjpeg-turbo-2.1.5.1/lib/libjpeg.so.62 (0x00007f8194937000)
	libmount.so.1 => /nix/store/8ax7zm438ch0zz2awcwmkpw72jg39vkz-util-linux-minimal-2.39-lib/lib/libmount.so.1 (0x00007f81948c7000)
	libselinux.so.1 => /nix/store/b4rjpcf3gkdh0mlx9kclrrbw37yxsdb2-libselinux-3.3/lib/libselinux.so.1 (0x00007f8194898000)
	libffi.so.8 => /nix/store/bg6dzgvw2wpg61v8a7f0x6fkm31k26hh-libffi-3.4.4/lib/libffi.so.8 (0x00007f819488b000)
	libpcre2-8.so.0 => /nix/store/gpba0g6gpc7sfpsj11nzjwwgllx4k61y-pcre2-10.42/lib/libpcre2-8.so.0 (0x00007f81947f0000)
	libwpe-1.0.so.1 => /nix/store/5xn8469953c92mrxz5wgiq6a1wmvbqqs-libwpe-1.14.1/lib/libwpe-1.0.so.1 (0x00007f81947e0000)
	libWPEBackend-fdo-1.0.so.1 => /nix/store/arsf12z27c6cr9509vr8mzlprhilfhkq-wpebackend-fdo-1.14.2/lib/libWPEBackend-fdo-1.0.so.1 (0x00007f81947c8000)
	libatomic.so.1 => /nix/store/4igdc32rmnijcra8y3r1h42987ghzag2-gcc-12.3.0-lib/lib/libatomic.so.1 (0x00007f81947bd000)
	libicudata.so.73 => /nix/store/pj2bms0x9k0yh547f4isfirpvr46di2i-icu4c-73.2/lib/libicudata.so.73 (0x00007f819292d000)
	libicui18n.so.73 => /nix/store/pj2bms0x9k0yh547f4isfirpvr46di2i-icu4c-73.2/lib/libicui18n.so.73 (0x00007f81925e5000)
	libsystemd.so.0 => /nix/store/pm4gxdsl1jjn3yr063si78b6636vvda7-systemd-253.6/lib/libsystemd.so.0 (0x00007f81924ef000)
	libicuuc.so.73 => /nix/store/pj2bms0x9k0yh547f4isfirpvr46di2i-icu4c-73.2/lib/libicuuc.so.73 (0x00007f81922e5000)
	libxml2.so.2 => /nix/store/s9fs1xciw3m79d9qhg0zdglb4qji5i8l-libxml2-2.11.4/lib/libxml2.so.2 (0x00007f8192184000)
	libsqlite3.so.0 => /nix/store/d6h42ly2lqrai8xnyw1apx0rnknfmlfc-sqlite-3.42.0/lib/libsqlite3.so.0 (0x00007f819202e000)
	libxslt.so.1 => /nix/store/w9n8hqqizl9yqw4xz3p79mnhqr9lr4zw-libxslt-1.1.38/lib/libxslt.so.1 (0x00007f8191ff0000)
	liblcms2.so.2 => /nix/store/rdql5bqnk8f49a78q104kqbi632nk63m-lcms2-2.15/lib/liblcms2.so.2 (0x00007f8191f8b000)
	libwoff2dec.so.1.0.2 => /nix/store/pl644as20zn6xfs2hvp1s23khz9gixzd-woff2-1.0.2-lib/lib/libwoff2dec.so.1.0.2 (0x00007f8191f7e000)
	libharfbuzz-icu.so.0 => /nix/store/p2z8v1w6ygj18hzl9bzy3zc3l43mx0ay-harfbuzz-icu-7.3.0/lib/libharfbuzz-icu.so.0 (0x00007f8191f79000)
	libgcrypt.so.20 => /nix/store/nglndag1zm1af90s6ab172zpa44bd24i-libgcrypt-1.10.2/lib/libgcrypt.so.20 (0x00007f8191e30000)
	libgpg-error.so.0 => /nix/store/vcchv1mm397wi4cx2g1dk0793d7a77pn-libgpg-error-1.47/lib/libgpg-error.so.0 (0x00007f8191e08000)
	libgstallocators-1.0.so.0 => /nix/store/178ch08i8f8lxmhda48la0jkmcbc5wac-gst-plugins-base-1.22.5/lib/libgstallocators-1.0.so.0 (0x00007f8191e01000)
	libgstapp-1.0.so.0 => /nix/store/178ch08i8f8lxmhda48la0jkmcbc5wac-gst-plugins-base-1.22.5/lib/libgstapp-1.0.so.0 (0x00007f8191deb000)
	libgstbase-1.0.so.0 => /nix/store/z2vla5nspbzw1zzx6kxlsraf3pf8bjb4-gstreamer-1.22.5/lib/libgstbase-1.0.so.0 (0x00007f8191d66000)
	libgstreamer-1.0.so.0 => /nix/store/z2vla5nspbzw1zzx6kxlsraf3pf8bjb4-gstreamer-1.22.5/lib/libgstreamer-1.0.so.0 (0x00007f8191c0e000)
	libgstpbutils-1.0.so.0 => /nix/store/178ch08i8f8lxmhda48la0jkmcbc5wac-gst-plugins-base-1.22.5/lib/libgstpbutils-1.0.so.0 (0x00007f8191bcb000)
	libgstaudio-1.0.so.0 => /nix/store/178ch08i8f8lxmhda48la0jkmcbc5wac-gst-plugins-base-1.22.5/lib/libgstaudio-1.0.so.0 (0x00007f8191b49000)
	libgsttranscoder-1.0.so.0 => /nix/store/fm3k1a2yy8wqhnmgrg3sp9svwkgvim0v-gst-plugins-bad-1.22.5/lib/libgsttranscoder-1.0.so.0 (0x00007f8191b3b000)
	libgsttag-1.0.so.0 => /nix/store/178ch08i8f8lxmhda48la0jkmcbc5wac-gst-plugins-base-1.22.5/lib/libgsttag-1.0.so.0 (0x00007f8191afa000)
	libgstvideo-1.0.so.0 => /nix/store/178ch08i8f8lxmhda48la0jkmcbc5wac-gst-plugins-base-1.22.5/lib/libgstvideo-1.0.so.0 (0x00007f8191a25000)
	libgstgl-1.0.so.0 => /nix/store/178ch08i8f8lxmhda48la0jkmcbc5wac-gst-plugins-base-1.22.5/lib/libgstgl-1.0.so.0 (0x00007f81919a7000)
	libgstfft-1.0.so.0 => /nix/store/178ch08i8f8lxmhda48la0jkmcbc5wac-gst-plugins-base-1.22.5/lib/libgstfft-1.0.so.0 (0x00007f819199a000)
	libopenjp2.so.7 => /nix/store/8smljjdxxr75x1b1i8cwpj4iv5y2m02j-openjpeg-2.5.0/lib/libopenjp2.so.7 (0x00007f819192f000)
	libwebpdemux.so.2 => /nix/store/2llpd6d32a39rvcp47sdl09mk34hi023-libwebp-1.3.1/lib/libwebpdemux.so.2 (0x00007f8191929000)
	libwebp.so.7 => /nix/store/2llpd6d32a39rvcp47sdl09mk34hi023-libwebp-1.3.1/lib/libwebp.so.7 (0x00007f81918b8000)
	libavif.so.15 => /nix/store/5p392k2p26h4xx2jk5kbndpdl3ayb900-libavif-0.11.1/lib/libavif.so.15 (0x00007f819188f000)
	libsoup-2.4.so.1 => /nix/store/mn71gwm89xyi3gwanxjxi4lki1mmvsxq-libsoup-2.74.3/lib/libsoup-2.4.so.1 (0x00007f81917ee000)
	libenchant-2.so.2 => /nix/store/bz5n4nqlxj1x7a0gy5krv5k7wapy5d0f-enchant-2.5.0/lib/libenchant-2.so.2 (0x00007f81917e2000)
	libsecret-1.so.0 => /nix/store/vkrgdbaycvm8yz6b9amnd2h54y3mc975-libsecret-0.20.5/lib/libsecret-1.so.0 (0x00007f8191784000)
	libtasn1.so.6 => /nix/store/i5lc7q6snsg1cbs4fqhn3kna2wvsp16q-libtasn1-4.19.0/lib/libtasn1.so.6 (0x00007f819176d000)
	libXt.so.6 => /nix/store/h2m54r0p95a1hwsdyxilkc2pr95gbh37-libXt-1.3.0/lib/libXt.so.6 (0x00007f8191701000)
	libwayland-server.so.0 => /nix/store/r2s9kgxr38ypw4yvy4h4sxfc2iv1k6ws-wayland-1.22.0/lib/libwayland-server.so.0 (0x00007f81916eb000)
	libmanette-0.2.so.0 => /nix/store/7hwr00rmaifs7i7ikwaa20ci5kvg8wmd-libmanette-0.2.6/lib/libmanette-0.2.so.0 (0x00007f81916bc000)
	libseccomp.so.2 => /nix/store/8rp7ainagwj9ak6bx0mabmxb84jw95if-libseccomp-2.5.4-lib/lib/libseccomp.so.2 (0x00007f819169c000)
	libgbm.so.1 => /nix/store/afajk9q9cvsxcgw22vl9vh53h3bdgcpl-mesa-23.1.4/lib/libgbm.so.1 (0x00007f8191689000)
	libdrm.so.2 => /nix/store/qx2y7chays0azsb9zfk2qx7z3hjzmvhl-libdrm-2.4.115/lib/libdrm.so.2 (0x00007f8191672000)
	libgraphite2.so.3 => /nix/store/bfcqi86wv3yyjfy4a48k2aqifvjnxd0d-graphite2-1.3.14/lib/libgraphite2.so.3 (0x00007f8191649000)
	libbz2.so.1 => /nix/store/nqr0hwhybhx7jz6lz1xhazl4d9fvf03c-bzip2-1.0.8/lib/libbz2.so.1 (0x00007f8191634000)
	libbrotlidec.so.1 => /nix/store/4ddvwxgddvx7dyrnggyhhvrpch5sv21i-brotli-1.0.9-lib/lib/libbrotlidec.so.1 (0x00007f8191626000)
	libexpat.so.1 => /nix/store/cnlf5ww1hgqhynq1g2f73k4ahbdpav7v-expat-2.5.0/lib/libexpat.so.1 (0x00007f81915fb000)
	libatspi.so.0 => /nix/store/sal68rv7jr1jiicvaxgc5zsjdgz6bk2n-at-spi2-core-2.48.3/lib/libatspi.so.0 (0x00007f81915c0000)
	libdbus-1.so.3 => /nix/store/0dsl1d89lq5ljq4xz49c06m2h8qaa53q-dbus-1.14.8-lib/lib/libdbus-1.so.3 (0x00007f8191567000)
	libjson-glib-1.0.so.0 => /nix/store/1i0qhvbx0b265liafhnzi57ylfs47nwq-json-glib-1.6.6/lib/libjson-glib-1.0.so.0 (0x00007f819153c000)
	libdatrie.so.1 => /nix/store/zks0a3xxb27nmg56paqhxk6k4mk2g5cw-libdatrie-2019-12-20-lib/lib/libdatrie.so.1 (0x00007f8191532000)
	libGLdispatch.so.0 => /nix/store/i1wjf5x2jdzbyxyqrywgbzbdcsvaljv2-libglvnd-1.6.0/lib/libGLdispatch.so.0 (0x00007f8191479000)
	libXau.so.6 => /nix/store/1ik2g8bqxij22khrswbwcadqgk5qb28w-libXau-1.0.11/lib/libXau.so.6 (0x00007f8191472000)
	libXdmcp.so.6 => /nix/store/3hsiak72xfg3x643644xmg3riid0ldlp-libXdmcp-1.1.4/lib/libXdmcp.so.6 (0x00007f819146a000)
	libGLX.so.0 => /nix/store/i1wjf5x2jdzbyxyqrywgbzbdcsvaljv2-libglvnd-1.6.0/lib/libGLX.so.0 (0x00007f8191436000)
	libblkid.so.1 => /nix/store/8ax7zm438ch0zz2awcwmkpw72jg39vkz-util-linux-minimal-2.39-lib/lib/libblkid.so.1 (0x00007f81913d9000)
	libpcre.so.1 => /nix/store/cxrk14zkaypp0qi307wryg9ljs62byxv-pcre-8.45/lib/libpcre.so.1 (0x00007f819135d000)
	liblzma.so.5 => /nix/store/zrhgwwrdipfmjy3kawr0sf93y2f0x0qs-xz-5.4.3/lib/liblzma.so.5 (0x00007f819132e000)
	libzstd.so.1 => /nix/store/zh6n4c7kslf32jmliipyw4i44sk9bjfj-zstd-1.5.5/lib/libzstd.so.1 (0x00007f8191262000)
	liblz4.so.1 => /nix/store/1wa96smh0m8qfc9az79j6yavc9m4vzh4-lz4-1.9.4/lib/liblz4.so.1 (0x00007f8191229000)
	libwoff2common.so.1.0.2 => /nix/store/pl644as20zn6xfs2hvp1s23khz9gixzd-woff2-1.0.2-lib/lib/libwoff2common.so.1.0.2 (0x00007f8191222000)
	libunwind.so.8 => /nix/store/g7rl6c7hll9sfiqa7yxv5bcr266myd5y-libunwind-1.6.2/lib/libunwind.so.8 (0x00007f8191208000)
	libdw.so.1 => /nix/store/f9m7grqaf40hh3gzb49wqg36n803vwpm-elfutils-0.189/lib/libdw.so.1 (0x00007f8191169000)
	liborc-0.4.so.0 => /nix/store/q535smq1s1yyal0kqjjn5h7rr9wvmg3v-orc-0.4.34/lib/liborc-0.4.so.0 (0x00007f81910cc000)
	libX11-xcb.so.1 => /nix/store/k3w1agqdhvqpzzia68vkjwj71qdz93jw-libX11-1.8.6/lib/libX11-xcb.so.1 (0x00007f81910c7000)
	libsharpyuv.so.0 => /nix/store/2llpd6d32a39rvcp47sdl09mk34hi023-libwebp-1.3.1/lib/libsharpyuv.so.0 (0x00007f81910bf000)
	libdav1d.so.6 => /nix/store/lrh2jii65c4mr8jfycidvagb6lqf6r9j-dav1d-1.2.1/lib/libdav1d.so.6 (0x00007f8190ed4000)
	libaom.so.3 => /nix/store/dqvldj2y0hdapywqxcx2bvrgib6qdy0i-libaom-3.6.1/lib/libaom.so.3 (0x00007f81906ba000)
	libvmaf.so.1 => /nix/store/d921wk4s3gw65l28nvvpvkph8z9v644g-libvmaf-2.3.1/lib/libvmaf.so.1 (0x00007f81905b2000)
	libjxl.so.0.8 => /nix/store/idw3j80n56xgz0bs05s035p518lj8gic-libjxl-0.8.2/lib/libjxl.so.0.8 (0x00007f8190115000)
	libyuv.so => /nix/store/km1llv7dgkrpbinmg07d4xjwjd50s1g0-libyuv-1787/lib/libyuv.so (0x00007f8190029000)
	libpsl.so.5 => /nix/store/pa809548ncw3s823fnw7cc153xdmsaib-libpsl-0.21.2/lib/libpsl.so.5 (0x00007f8190013000)
	libaspell.so.15 => /nix/store/aaqh1zrycwamv5sxpprc0rk4aj7l5yld-aspell-0.60.8/lib/libaspell.so.15 (0x00007f818ff61000)
	libSM.so.6 => /nix/store/06m9q4d7vsgvkv56lqsgnfnxcmmpjgj5-libSM-1.2.4/lib/libSM.so.6 (0x00007f818ff56000)
	libICE.so.6 => /nix/store/p1v83q4cg4dz9l407x9nlnhkgz2apms6-libICE-1.1.1/lib/libICE.so.6 (0x00007f818ff37000)
	libevdev.so.2 => /nix/store/sn002z8k7vqpm4p7w8jk64ql3imwyqj8-libevdev-1.13.1/lib/libevdev.so.2 (0x00007f818ff17000)
	libgudev-1.0.so.0 => /nix/store/j3sa1mlxm33dsjpp7f9wp93y5d2nlfhk-libgudev-238/lib/libgudev-1.0.so.0 (0x00007f818ff0a000)
	libxcb-randr.so.0 => /nix/store/g93jp1k5j47zxqjnd1h0a8aixhiczz28-libxcb-1.15/lib/libxcb-randr.so.0 (0x00007f818fef8000)
	libbrotlicommon.so.1 => /nix/store/4ddvwxgddvx7dyrnggyhhvrpch5sv21i-brotli-1.0.9-lib/lib/libbrotlicommon.so.1 (0x00007f818fed5000)
	libelf.so.1 => /nix/store/f9m7grqaf40hh3gzb49wqg36n803vwpm-elfutils-0.189/lib/libelf.so.1 (0x00007f818feb8000)
	libbrotlienc.so.1 => /nix/store/4ddvwxgddvx7dyrnggyhhvrpch5sv21i-brotli-1.0.9-lib/lib/libbrotlienc.so.1 (0x00007f818fe19000)
	libunistring.so.5 => /nix/store/748caky83gr4pyrhircvi4llx99ja6z9-libunistring-1.1/lib/libunistring.so.5 (0x00007f818fc61000)
	libidn2.so.0 => /nix/store/v5llm7rmipvg487yvgb15q0m2jxrihq3-libidn2-2.3.4/lib/libidn2.so.0 (0x00007f818fc30000)
	libuuid.so.1 => /nix/store/8ax7zm438ch0zz2awcwmkpw72jg39vkz-util-linux-minimal-2.39-lib/lib/libuuid.so.1 (0x00007f818fc24000)

PLAYDATE_SDK_PATH appears to correctly be set. I am able to successfully build the examples and upload them to my playdate:

$ echo $PLAYDATE_SDK_PATH
/nix/store/7k6ks2xfc74x40hxm39qy9anl9kr31zx-playdate_sdk-2.0.1/opt/playdate-sdk

SDL2 is built into the Simulator and doesn't rely on the OS version due to various distros shipping old versions. However, you'll still need the required libraries installed that it uses. Unfortunately, the initialization error isn't particularly helpful tracking down what is missing.

Oh so it is statically linked? So you're saying I need to install the SDL's dynamically linked dependencies?

Do you happen to know what version of SDL2 is used in the simulator or is there some way the error message could be updated?

Yes, it's statically linked. We're using version SDL2 2.24.1. From what I've seen, the vast majority of distros 'just work' with it. What distro are you using? You'll need audio (pulse/pipewire/alsa), wayland or x support, I'm not sure what else it needs off the top of my head.

I have updated the error message to get the message and proper error code if it fails to initialize. If you continue to have troubles I'll see if I can get a custom build to you.

Sorry for the late response. I'm running nixos and I do have pulse audio and X installed. If possible a better error message maybe helpful. For what it is worth I have run SDL apps in the past, so it is strange the simulator isn't working for me.

OK, give this build a shot. It will show the error code and message coming from SDL on launch. https://f000.backblazeb2.com/file/panic-files/support/playdate-sdk/PlaydateSDK-2.0.2-158163_c8289861-Releaselinux_x86.tar.gz

I'm having this same issue. NixOS doesn't do dynamic linking in the normal way so it's not that surprising it's behaving oddly. I can probably fix the issue but I don't have access to that build and there's no follow up. I'll try to install more SDL libs in the meantime. Fwiw to other NixOS users, my playdate-sdk.nix that I'm trying to write has bits that look like this:

  # Build inputs for the simulator (excluding those from pdc)
  pdsInputs = with pkgsIntel; [
    udev
    gtk3
    pango
    cairo
    gdk-pixbuf
    glib
    webkitgtk
    xorg.libX11
    stdenv.cc.cc.lib
    libxkbcommon
    wayland
    SDL2
  ];
  stdenv.mkDerivation rec {
...
    installPhase = ''
...
      patchelf \
        --set-interpreter "${dynamicLinker}" \
        --set-rpath "${lib.makeLibraryPath pdsInputs}"\
        $root/bin/PlaydateSimulator
...
    '';
  }

patchelf should be binding SDL2, but I don't think it is. I may be using the wrong package, but if it's statically linked then perhaps it is something else?

Had to modify

pretty substantially already to get to this point

Try this link and see what the SDL error is logged on launch: https://files.panic.com/support/playdate-sdk/PlaydateSDK-2.0.2-158163_c8289861-Releaselinux_x86.tar.gz

$ PlaydateSimulator 
SDL2 could not be initalized (-1 - dsp: No such audio device).
SDL2 is required for the Playdate Simulator to run and it will now quit.

Looks audio related, maybe because I'm using pipewire's pulseaudio layer instead of pulseaudio? I'll do some digging

edit: I can get the error message to change based on what I set SDL_AUDIODRIVER to, based off this page SDL2/FAQUsingSDL - SDL Wiki

edit 2: I can get it working without sound by running

$ SDL_AUDIODRIVER=disk PlaydateSimulator

Our SDL2 is built with both Pipewire and Pulse Audio support, so hopefully that's not it.

I did a small amount of reading on this last night. SDL attempts to open the audio libraries on launch, if it can't find them, it will fail. I assume it's looking in a 'standard' location for these libraries but perhaps NixOS puts them in a location it can't find?

This is probably the case, I'll try to get audio working today now that I've got the error message, though even more detail would help.

Other question, is there an environment variable that I can use to set the disk directory? NixOS packages are immutable and it looks like Playdate simulator is trying to write to a directory in the nix store. If not I can probably get it to work with the file picker.

What do you mean by disk directory? Are you talking about where it saves the settings? It attempts to store its settings in the users home folder, but with all things linux, that may not work in all cases. It looks at the ENV HOME value for the users home folder for the settings location.

As for the audio error message, that's all I can get from SDL2. :frowning:

I'm still working on getting everything sorted, I'm definitely past the audio issues and I'm onto filesystem / configuration stuff and I think I can get this working 100%.
The fix is to link libpulseaudio to PlaydateSimulator using patchelf, and do

      export PLAYDATE_SDK_PATH="${pkgs.playdate-sdk.outPath}"
      export SDL_AUDIODRIVER=pulseaudio

I intend to do a full write up when I get everything working, and maybe post my install script somewhere if that's within the playdate SDK license (currently it downloads the binaries automatically, but doesn't distribute the binaries directly, is that okay?)
And yes, I'm trying to fix where it saves the settings, I'm now running into

Update error: listView.lua:890: Couldn't open file at launcherprefs.tmp: Unknown error, errno=30
stack traceback:
	[C]: in field 'write'
	listView.lua:890: in method 'saveScrollPosition'
	listView.lua:791: in method 'setup'
	main.lua:70: in function <main.lua:66>
1 Like

Launcher prefs are written to the /PlaydateSDK/Disk/System/Data/ folder which needs to be in a writable location.

I should elaborate. By default, the SDK path is determined by the location of the Playdate Simulator binary at launch time and its relationship to the Disk folder in the PlaydateSDK folder. You can, as you found, select a different SDK from the file picker. That's not ideal and can lead to missing features the Simulator needs/expects if you're running a mis-matched SDK vs sim bin, but it does work.

Alright, I got it working on NixOS, and this is now mostly reproducable. It would work better if I was able to specify a separate Disk directory, but essentialy here's what needs to be done:

Inside your project directory create the following files:

# shell.nix
{ pkgs ? import <nixpkgs> { overlays = [ (import ./nix/playdate-sdk/overlay.nix) ]; } }:
  pkgs.mkShell {
    nativeBuildInputs = with pkgs.buildPackages; [ cmake playdate-sdk gcc-arm-embedded ];
    shellHook = ''
      export PLAYDATE_NIX_PATH="${pkgs.playdate-sdk.outPath}"
      export PLAYDATE_SDK_PATH="${builtins.toString ./playdate-sdk}"
      export SDL_AUDIODRIVER=pulseaudio
    '';
}
# nix/playdate-sdk/overlay.nix
let
  # this was taken from a gist which involved cross compilation. This is probably a weird thing to do.
  pkgs = import <nixpkgs> {};
in
  final: prev: rec {
    inherit pkgs;
    playdate-sdk = prev.callPackage ./playdate-sdk.nix {};
  }
# nix/playdate-sdk/playdate-sdk.nix
{
  stdenv,
  lib,
  fetchurl,
  pkgs,
  wrapGAppsHook,
}: let

  # Build inputs for `pdc`
  pdcInputs = with pkgs; [
    stdenv.cc.cc.lib
    libpng
    zlib
  ];

  # Build inputs for the simulator (excluding those from pdc)
  pdsInputs = with pkgs; [
    udev
    gtk3
    pango
    cairo
    gdk-pixbuf
    glib
    webkitgtk
    xorg.libX11
    stdenv.cc.cc.lib
    libxkbcommon
    wayland
    libpulseaudio
    gsettings-desktop-schemas
  ];

  dynamicLinker = "${pkgs.glibc}/lib/ld-linux-x86-64.so.2";
in
  stdenv.mkDerivation rec {
    pname = "playdate-sdk";
    version = "2.0.3";

    src = fetchurl {
      url = "https://download.panic.com/playdate_sdk/Linux/PlaydateSDK-${version}.tar.gz";
      sha256 = "sha256-FNzb3OjXGZpTTuR9+ox9KZD0sKlYfoA7jg48lZeQrpE=";
    };

    buildInputs = pdcInputs;
    nativeBuildInputs = [ pkgs.makeWrapper wrapGAppsHook ];
    dontFixup = true;

    installPhase = ''
      runHook preInstall

      # Get our new root
      root=$out/opt/playdate-sdk-${version}

      # Everything else
      mkdir -p $out/opt/playdate-sdk-${version}
      cp -r ./ $out/opt/playdate-sdk-${version}
      ln -s $root $out/opt/playdate-sdk

      # Setup dependencies and interpreter
      patchelf \
        --set-interpreter "${dynamicLinker}" \
        --set-rpath "${lib.makeLibraryPath pdcInputs}" \
        $root/bin/pdc
      patchelf \
        --set-interpreter "${dynamicLinker}" \
        $root/bin/pdutil
      patchelf \
        --set-interpreter "${dynamicLinker}" \
        --set-rpath "${lib.makeLibraryPath pdsInputs}"\
        $root/bin/PlaydateSimulator

      # Binaries
      mkdir -p $out/bin

      cp $root/bin/pdc $out/bin/pdc
      cp $root/bin/pdutil $out/bin/pdutil
      makeWrapper $root/bin/PlaydateSimulator $out/bin/PlaydateSimulator \
        --suffix XDG_DATA_DIRS : ${pkgs.gsettings-desktop-schemas}/share/gsettings-schemas/${pkgs.gsettings-desktop-schemas.name}
      cp -r $root/C_API $out/C_API
      cp -r $root/CoreLibs $out/CoreLibs
      cp -r $root/Resources $out/Resources
      cp -r $root/Disk $out/Disk

      runHook postInstall
    '';
  }

Enter a nix-shell at the root of the project directory. This will download the playdate sdk and install pdc, pdutil, and PlaydateSimulator inside the shell. It may need to rebuild a bunch of libraries. At this point pdc and pdutil both work fine, and if you only need to use those you're done. However, PlaydateSimulator needs PlaydateSDK/Disk to be writable, because the nix store is unwritable this will cause a bunch of errors. You can get around this by creating a replica of the playdate sdk folder using symlinks, with a Disk folder that isn't symlinked. You can do it using this script:

#/usr/bin/env sh
# make-symlinks.sh
rm -r playdate-sdk
mkdir -p playdate-sdk

echo $PLAYDATE_NIX_PATH
echo $PLAYDATE_SDK_PATH

# Disk is the only writable part
cp -TR $PLAYDATE_NIX_PATH/Disk $PLAYDATE_SDK_PATH/Disk
chmod -R 755 $PLAYDATE_SDK_PATH/Disk
ln -s $PLAYDATE_NIX_PATH/bin $PLAYDATE_SDK_PATH/bin
ln -s $PLAYDATE_NIX_PATH/C_API $PLAYDATE_SDK_PATH/C_API
ln -s $PLAYDATE_NIX_PATH/CoreLibs $PLAYDATE_SDK_PATH/CoreLibs
ln -s $PLAYDATE_NIX_PATH/Resources $PLAYDATE_SDK_PATH/Resources

Now this part is a little janky, I couldn't figure out why PlaydateSimulator doesn't respect $PLAYDATE_SDK_PATH you need to set it to your writable playdate-sdk location using the file picker dialog inside of the simulator under File > Set SDK Path. Also because I'm using KDE Plasma and maybe don't have it all set up 100% correctly I get

(PlaydateSimulator:42776): GLib-GIO-ERROR **: 21:12:20.549: Settings schema 'org.gtk.Settings.FileChooser' is not installed

This is almost certainly fixable inside of playdate-sdk.nix or shell.nix, but I couldn't figure it out. As a workaround, the first time you launch PlaydateSimulator do it like this

steam-run PlaydateSimulator

and the file picker will work just fine. Point it at the directory with the writable Disk, in my case it's $PROJECT_ROOT/playdate-sdk. Subsequent launches of PlaydateSimulator will just work :tm:.

Obviously only use this if you agree to the Playdate SDK EULA.