Building gSender

If I remember correctly someone said that maybe build directions would be added at some point. I only have have a little experience with JS but if I could build gSender it might encourage me to learn more as I’d have a use for it.

I have experience with Make, CMake, Meson, Autotools, shell scripts and probably some other build systems but I don’t even know where to begin when I look at gSender’s repository. I’m also thinking the fact that you are having trouble building it doesn’t bode well for me.

1 Like

I just have a billion problems with dependencies when I try to build. I wish there was an easier way, but for as infrequently as I’ve done it, there is always something different from the last time. My notes from the last time I successfully built gsender look like the scribblings of a madman. Despite following those scribblings, I have never been successful again.
That said, I don’t really know what I’m doing when it comes to building gSender.

This is me :crazy_face: I always wonder what people will think if they look at my notebooks when I’m gone.

That reminds me my cousin just told me he’s been using Obsidian for notes, it looks interesting to me, maybe to you too if you don’t know about it.

On building gSender the closest thing I found to build directions, looked again last night, was .github/workflows/CI.yml which I’m guessing is a Travis CI configuration file in YAML. It was late and I haven’t researched Travis CI yet, if that is indeed what it’s for. Maybe the there are other continuous integration programs out there? Travis CI is the only one I’ve heard of but I’ve never looked into it because I didn’t see a need for it in small mostly solo projects.

From that file I can see it’s build with yarn. So that’s where I’m at, need to learn a little about Travis and Yarn and maybe then I could attempt to build it.

Travis CI might help, but I’m the past I’ve just built straight from visual studio on Windows. I just clone the repo, open in VS, and used npm or yarn to build. The problem comes from all the dependencies and the respective versions. I don’t know if I’m ahead or behind and when I try to update everything I get new issues. I’ve given up. I think Travis might provide a clean machine to build from, but I’d anticipate the same issues.

1 Like

Found out it’s a GitHub Actions/Workflows file. I forked the repo and I’m going to try and modify the file to use my token and see if GitHub can do a Windows build for me. I want to read up on GitHub Workflows and Actions first. They were disabled after forking and I lied to GitHub and said I knew I what I was doing. :crazy_face: So now they’re on but I’m not sure if you even have access to the files it builds or if you need a local runner for that.

There is always too much to learn and so little time. I need some clones!

1 Like

I was reading about GitHub Actions just a few days ago. I read the “Quickstart” and realized that I didn’t have a clue what I was reading. It would not be a quck start for me.
The thing I liked about just building or running locally was that I could change the code and in less than a minute I was testing in my local instance. I didn’t have to build a windows exe to test that.
I’ll keep messing with it a bit at a time.

1 Like

Howdy. So I’ll share how I got things up and running. My main workstation is a windows box, but this approach should allow you to accomplish the same regardless of your OS.

If you are not familiar with the platform that GSender is built on, there are two things primarily that result in the application executable. 1. A React JS web application 2. An electron packaged executable that provides the wrapper for the web app as well as the system calls for things like the filesystem, serial devices, etc. There is one more thing if you consider the remote browser access, which is a Node.JS server that is serving the react app.

So, the hardest thing to deal with is the package dependencies, along with the various versions of yarn, npm, etc. that are all necessary to get to the point of even being able to build.

The solution is to use a Dockerfile to stand up a container that already has the build tools like node, npm, yarn, etc. that will work for the GSender codebase.

This thread on GitHub is where the information on Docker was: Cannot compile · Issue #557 · Sienci-Labs/gsender · GitHub

So I setup up Docker, and created a docker file. Now, the docker file spelled out in the above thread, does a very specific thing, which includes copying files from the container build onto your local filesystem. When I set things up, the files were already on my local filesystem. I’m not docker expert, but using Visual Studio code and the Dev Containers extension, I was able to create a container from the following docker file and attach to it inside of VS Code. That importantly gave me a terminal.

Dockerfile:

ARG version=v1.4.9

FROM node:18-bullseye

So that creates an image that has a specific version of Node.JS on a specific version of Debian.

Once I was attached to the container in VS Code, in the terminal I then issued commands from the Docker file shared in the GitHub thread.

  1. git clone https://github.com/Sienci-Labs/gsender.git .
    (clone the gsender repo from github to cwd)
  2. yarn prebuild-latest
    script that needs to run first
  3. yarn lint
    This just warns about the code issues but afaik it doesn’t do anything else. I ran in just in case.
  4. yarn build

Assuming you do not get an error - once yarn build finishes running you have built the react JS application and everything is ready for packaging up as an Electron app.

Now, I had some trouble at first getting the electron packaged exe to run. Keep in mind, this part of the build, I did outside of the docker container, so in other words through my local terminal in windows.

Change into directory ~/build/dist/gsender

  1. yarn install
  2. npm install electron
  3. npm install electron-packager

For my machine I was successful with Node 22.16.0

Final step: Building the executable
npx electron-packager <sourcedir> <appname> --platform=<platform> --arch=<arch>

So translated to my environment:
npx electron-packager . RiftCoderGsender --platform=win32 --arch=x64

This created the folder GsenderRiftCoder-win32-x64 which inside was the electron app including RiftCoderGsender.exe

You can find the electron-packager parameter info here: packager/usage.txt at main · electron/packager · GitHub

Edit: Just FYI, I was also able to run GSender headless in the container which allowed me to access it through a web browser. Ultimately, that wasn’t useful to me because I would have to forward a COM port to docker for it to see my arudino grbl test setup. So I worked towards getting the executable and running that as if I had it installed at my CNC.

2 Likes

@RiftCoder Thanks so much for that John!

That sounds like it should get me well on my way towards a successful build. I really appreciate it!

1 Like

Just found this, awesome! Will give it a shot. Nice to see Linux can build a windows environment.

Hopefully Sienci can start merging some PR’s.

1 Like

Made it through most of the steps, but running the app

I had this exact problem at first. Also just fyi, the process hangs so you’ll have to kill the process for any of them that you opened.

I am not 100% sure yet how I solved that. Because I tried a few things and then it just worked. I believe that error is related to a package missing, so I suspect that when I was careful to make sure I was in the path build/dist/gsender (this is the build output from yarn build.. then in my local terminal I did yarn install / npm install (I think that’s redundant?) .. it worked after doing that.

I’m doing a build right now so we’ll see if I run into the same issue again.

Thanks let me know. I will try Node 22 tonight, I think I was using 20.

I’m no stranger to compiling, and this is by far the hardest thing I’ve dealt with.

1 Like

Edit: See a few posts down on how to resolve this

If you want to play with github actions, I think it’s all about telling node not to publish the package. Don't publish by default on github builds · Issue #5463 · electron-userland/electron-builder · GitHub

I do not LOL .. I’d rather use the dev container and stay away from GitHub after cloning. It doesn’t help that I am not a react dev, or a JS dev, but I’ve built some Vue apps before and had similar nightmare experiences.

@greg5 - I figured it out. I had forgotten that I did this.. ok the error that we both got, is actually because it is missing a package @electron/remote - I do not know why this isn’t a package installed when you run yarn install in the dist/gsender directory after building, but it isn’t.

To solve this after you complete a build, prior to packaging it for electron you need to run:
npm install --save @electron/remote

I cannot edit my original post anymoer - so hopefully folks see this update. Gsender runs fine when this package is there. I also see my code change - I modified the probe settings to add my “3D Touch Probe” as a new probe type, and modified the probe widget to show the image when that probe type is selected:

2 Likes

Awesome thanks! What version of node are you running?

This was above and my post needs 20 characters.

1 Like

22.16.0 is what I am running on at the moment.

1 Like

I’m working on my Linux kernel config to support Docker. I’m going to attempt to build for Linux after. I’m running Gentoo Linux.