Installed gnatformat via alire on Windows and it does... nothing

This is more of a Windows question, I think.

I installed gnatformat using alire on Windows. I was surprised when it didn’t do anything for me in vscode. I tried running it from the command line, and it still does nothign for me. gnatformat.exe --version and gnatformat.exe --verbose likewise do nothing.

I am not ordinarily a Windows user, but I know enough to set the path :white_check_mark: and check the properties (it’s an application). I’m not getting any errors; I’m getting nothing at all.

Anyone know what I’ve done wrong? gnatformat version installed is 25.0.0 as I recall (no longer at that computer but 25 is definitely correct)

:double_exclamation_mark: I remembered only afterwards: if it matters, this machine is running Windows 10, not Windows 11. I’m not sure I can upgrade it to 11.

Neither a windows nor a vscode user but have you checked that the Path variable inside vscode is correct?

I had such a problem where in cmd a command was found but vscode wasn’t using the same Path variable. I had to set it manually.

Edit: iirc alire has a command to open your editor from the shell (e.g. vscode). The correct path variable should be loaded using this method.

No, but I imagine that if it’s doing nothing from the command line, then it won’t do anything from within vscode, either. In the past I used gnatformat from the command line when the Ada language server would break down.

Yep, that was one of the first things I tried. I also tried from an msys2 terminal, just in case.

Update based on some further investigation.

  1. re-installing using --force didn’t help
  2. when I run it from Windows explorer, it complains that it can’t find libconv-2.dll or libgmp-10.dll.
  • I found those and put them in the path, then tried running again. Now it sits quietly a little longer, then fails silently. So at the very least, it looks as if something went wrong in installation / building.
  1. When I run it from msys, it fails with a segmentation fault. That might be normal; I’ve built on msys in the past, but I’m not confident in my understanding of it.

I think I’ll escalate this to a ticket on alire.

When I first started playing with Ada I had this exact problem with gnatpp built from alire. I randomly got it to work after rebuilding it a bunch of times trying different toolchains and flags, but it wasn’t clear to me what I had done differently. I asked in the alire gitter but didn’t find a solution to my problem. Now I just use the formatter bundled with als.

One thing I didn’t know at the time is that the gcc-ada package that msys distributes has debug information stripped which makes Ada exceptions unable to be caught in gdb. Debugging problems like this is impractical if you’ve configured alire to use msys gnat as a toolchain.

Make sure ldd can resolve all of your dependencies and that they point to the paths you expect. DLL mismatches can cause segfaults.

TBF, all these extra tools should really come with the gnat toolchain which is installed by alire.

1 Like

Ok, so there’s a couple things to remember about environments on windows, but they’re really simple; there’s a ‘default’ environment that processes get run in, but programs are really using scoping and can have their own environment (in properties, I think it’s an environment tab).

But wait, BEFORE you do anything there pop into a commandline console (Win-key + R, “cmd.exe”) –

  1. First, display the path and give it a once-over (DO NOT EDIT/ALTER YET);
  2. Next, from this console, navigate to the executable’s location, make a note of it;
  3. Now, as a sanity-check, invoke the executable with a suitable test;
  4. Then navigate to the code’s location;
  5. Directly invoke (explicit path) the executable specifying your source (it should work);
  6. NOW add the location to your path, using the environment of this console;
  7. Test the executable, letting the path-search take care of finding it;
  8. LASTLY, add the location to either the environment variables in the properties-tab, or else the system environment as needs dictate.

One thing to be aware of, is that not all programs are “happy” with long-form path names, particularly those with spaces in them. (Those developed in/on Unix- or Linux-heavy locations seem particularly susceptible to this.) In order to remedy this, consider using short-form names (eg C:\Progra~1\Stufffo~1\Projects\whatever\), and/or SUBST (where you can give a location a drive-letter).

I get the libgmp-10.dll was not found popup and the libiconv-2.dll was not found popup. The popups do not always appear in the same order.

ldd is definitely not finding libiconv-2.dll nor libgmp-10.dll. The only place they appear is in the git folder, but as i wrote above, copying them into a (Windows) path doesn’t make anything happen when i run them from windows, which is how i thought the program was supposed to be run. (Trying msys was just an attempt.)

For what it’s worth, some certificate issues occurred because this machine is behind a proxy. I managed to make it build anyway, and I can’t imagine that would be a problem for the executable, but I don’t actually know.

Try dir libgmp*.dll /b /s, add that to your path and try again.
(Remember to strip off the file-name.)

It is libiconv (GNU codepages conversion stuff).

If a DLL is missing the program does not start at all.

In order to check dependencies use depends.exe. Drop the application into it and you will see what is missing down to individual entry points.

If you have MSYS2 then the location is C:\msys64\mingw64\bin which should be in the PATH then. Note that differently to Linux PATH delimiter is semicolon. Under MSYS you can install them using pacman.

P.S. Does Alire support binary distributions? Because in that case individual libraries must be independent crates, like packages are in Linux. E.g. mingw-w64-libiconv under MSYS. libiconv RPM under Fedora etc. You cannot expect these physically included into the gnatformat crate.

1 Like

I’ll look at @OneWingedShark’s and @dmitry-kazakov’s suggestions tomorrow when I’m back at work. For the time being, I wanted to report another observation I just made.

On my personal Linux laptop, I run VSCode (as with the Windows laptop at work) and it is set up to use the Ada & Spark plugin fromAdaCore, which it hapily does, which is itself setup with gnatformat, which it happily uses, or seems to.

Curiously, though, I don’t find gnatformat on my system. For example, none of these is a binary:

$ locate gnatformat
/home/cantanima/.config/alire/indexes/community/repo/index/gn/gnatformat
/home/cantanima/.config/alire/indexes/community/repo/index/gn/gnatformat/gnatformat-25.0.0.toml
/home/cantanima/.config/alire/indexes/community/repo/index/li/libgnatformat
/home/cantanima/.config/alire/indexes/community/repo/index/li/libgnatformat/libgnatformat-25.0.0.toml
/home/cantanima/.local/share/alire/builds/functional_3.0.0_49073c79/aee7f26e39bb37131bc9874503a5714f753181bb5f39c3246f015623227f6114/.gnatformat.yaml
/home/cantanima/.local/share/alire/releases/functional_3.0.0_49073c79/.gnatformat.yaml

or:

$ which gnatformat
/usr/bin/which: no gnatformat in (...snip, you don't want to see all that...)

In fact, an attempt to install gnatformat installs it happily, and when I run it from the command line, I get some output that makes sense.

So, does anyone know:

  1. Whether the language server on Linux comes with its own version of gnatformat? and
  2. If so, why it doesn’t on Windows?

A surprising number of open source projects are based in Unix/Linux; and Unix/Linux users in the programmer space… have a disdain for Windows, to the point that they disregard its conventions altogether. A cousin-condition to Python’s “It Works On My Computer!” (So there’s no problem.) style approach.

Well, you wanted Alire… Did you try the “normal” way? E.g. install MSYS2 and then mingw-w64-x86_64-ada_language_server package there? Differently to crates the package systems tend to be consistent and even, can you imagine that? run out of the box! :grinning:

I did not test it though. I format, document, write and think manually. :grinning:

@OneWingedShark

That gets me to where it runs, does nothing, then terminates silently. No popups about missing dll’s. The paths made sense; they were in my AppData\Local\alire\cache\msys64\mingw64\bin folder.

@dmitry-kazakov

The GUI seems to have hung. (Window title is now Dependency Walker (Not Responding).) I tried running it from the command line with the /c option and it terminates silently.

Oops, while I was typing this it came up. There are indeed a lot of DLL’s it cannot find, but at least some of them look like Window API’s:

…while others I’m not sure about:
image

Lots of found dll’s appear at the bottom of that list.

It looks like it, judging from the help page. (It’s listed as an option under “Catalog format specification > Release Information”.)

They seem to have been installed with alire, but not added to the path. Unfortunately, as I noted above, adding them to the path doesn’t seem to get me far.

I was not aware that there was a mingw-w64-x86_64-ada_language_server. I’ve installed it using pacman and yep, that prints out information when I run it. Now I have to see if I can get the VSCode plugin to use it. If not, then I’ll just run it from the command line.

Do you always hand optimize machine code in a hex editor, as well? :wink:

Speaking seriously: I used to format manually, not that long ago. The gnat compiler badgers one about indentation and spacing, to the point where the number of lines of style advice can make it hard to find the actual errors. I could of course turn that off, but I find the recommended style bearable, and then I discovered the Ada & Spark plugin for VSCode, which is useful for many things, among them the automatic formatting which (mostly) makes gnat happy.

Marked as solution because this does what I want.

…well, mostly. The plugin doesn’t seem to look for gnatformat on the command line, so it doesn’t format automatically, which leaves open the question as to why that’s broken. But this thread is about gnatformat: I can now run gnatformat from the command line, and that satisfies me.

Thanks to everyone!

PS Reported this as Issue 2056 for alire.

You probably did it wrong. If you edit the environment, you need to restart cmd or whatever again to make it see the change. From cmd you can also test it like

set PATH=<path>;%PATH%

In my view the crate system is one the most stupid ideas of the recent time. It leads to balkanization of the software eco-system. How would you bring together software from different crate systems? Worse, it makes Ada even more a niche language.

If AdaCore wanted to jump into the last wagon of this crazy train, they could at least make Alire running on top the corresponding packaging system. E.g. under Fedora it should be a managed RPM repository, under Windows a MSYS2 Arc repository, under Debian a DEB repository etc. Then you would never have problems of missing or outdated libraries, they would be in the dependencies.

P.S. I do not blame AdaCore. They always tried to flirt with the latest hypes. It was Ada to Java compiler before, Python, now Rust. So long they remain committed to Ada I forgive them these all deviations. However, crates are really nasty.

Thankfully, I know enough about Windows to do that correctly. I verified the path, as well. (After all, I was able to modify the path so that the gnatformat executable itself was available.)

That’s a good question. In Rust, there’s only one crate system that I know of, cargo.

However, I’ve had issues with this in Python (pip v. Conda) and/or JavaScript (node vs. whatever – and node seems to be its own particular kind of :flame:, judging not just from my own experience but from that of others).

That seems to vary by package system. I run Fedora and while it’s amazingly stable (considering what it used to be like, and that it’s supposed to be bleeding-edge) it seems to lack certain “standard” Ada / AdaCore packages. Can’t remember offhand which, though. (gnatdoc?)

I’ve seen history of Ada-to-Java and Ada-to-.Net (A# ?). I’m not sure what happened to Ada-to-.NET, or if it was even AdaCore, but the Ada-to-Java backend was just a backend for gcc, I thought, but gcc dropped support for that, right?

The order is as important. I always have problems with that because I have MSYS, GtkAda, GNAT Studio all having same DLLs of different versions.

I don’t know. My problem was that Ada run-time was not complete. That makes the whole idea pointless. Furthermore you needed to port all essential bindings like SSL, ODBC, Sockets. It simply did not worth the efforts.

1 Like

I recall someone named Martin Carisle had done the initial work on A# and if I’m not mistaken, AdaCore might have leveraged it or perhaps developed their own .NET technology. Regardless, I remember someone from AdaCore mentioned long ago that they dropped .NET because they never got enough, if any, customer interest