UnsupportedFormatException in Linux Mint Build

When I run my little program in the IDE debugger, everything runs smoothly. So, I thought it was time to try building this version under Linux (Mint). Just to test it. Linux runs in a Oracle VM VirtualBox.

But the build gives me a ‘UnsupportedFormatException’ and I can’t figure out why. It occurs in the following part of code:
Var fP As New FolderItem(myAppPath + "SomeFileName.ext")
I checked multiple times but the path and file do exist. In the debugger it works without errors and as expected.

I can’t check the build under Windows (yet) as I’m still using the free version. I’m running the latest 2024r1.1 release.

Where is located the project ?
Did you have write permissions there ?

Is there’s a folder separator at the end of myAppPath ?
(I suspect this one).

The build prog is in: ‘Builds - ProgName/Linux 64 bit/ProgName’.

Yes, there is a separator at the end of the FilePath. Otherwise, it would also give an error in the IDE debugger. I use this to add the separator:

#If TargetWindows Then
  Return "\"
#ElseIf TargetMacOS Then
  Return "/"
#ElseIf TargetLinux Then
  Return "/"
#Endif

When running in the debugger, what OS is the IDE running under? Or are you running the IDE in your VM?

Yes, the debugger runs in the VM. A folder is created with a name starting with ‘Debug’. The file that is checked is not in this Debug folder however. It is in a sub folder of the Xojo-project folder.

Usually, .Child is set to access/create files inside folders. Concatenate path at file creation ?
(second best clue for the bug)

But saving in the Program folder… [yes, otherwise…]

Try to Save As Dialog (same place, then elsewhere) instead of New FolderItem.

I also tried .Child but without success:

Var fP As New FolderItem(myAppPath)
If fP.Child("SomeFileName.ext").Exists Then
'Code here.

It gives the same error.

I’m not saving a file but just checking the existence of a file.

I’ll copy the build to my laptop that has Linux installed. If that runs without issues, than the VM could be the problem.

From where in the documentation did you find this line ?

Also, what are the error # and error message ?

UnsupportedFormatException

I’m not sure what you mean with the first question? But you can find it here:
https://documentation.xojo.com/api/files/folderitem.html#folderitem-constructor1
It also gives some examples.

The error number is: 0 and the message is in the description of my question: UnsupportedFormatException

I am sorry, I do not know what I may suggest beside using GetSaveFolderItem (for example) instead of the constructor.

Thanks Emile, I’ll look into that.

Meanwhile I discovered it has to do something with the subfolder. If I put the file into the app folder, the problem disappears.

To avoid issues with the ‘slash direction’ I will also use the ‘.Child’.

I was asking which OS the IDE was running under. I was trying to be sure that you were not running the IDE and debugging under (say) macOS, and then building for Linux.

Ok, I didn’t get that… No, I don’t mix OS systems.

Although I’m posting in the ‘GettingStarted’, I am not new to programming. I’m getting started with Xojo… By far not a professional, but with 20+ years of programming in VB6.

I now changed to the following code:

Var fP As New FolderItem(myFilePathPort)
Var fF As New FolderItem
fF = fP.Child("Portable.dat")

If fF <> Nil Then
' my code

The Linux build now gives fF = ‘Nil’. While this file ‘Portable.dat’ really exists in the subfolder.

Digging a bit further makes me discover that the problem lies in the folder definition:
In the debugger, I have to use:
app.ExecutableFile.Parent.Parent.NativePath

While in the Linux build I need:
app.ExecutableFile.Parent.NativePath
(so, just 1 ‘Parent’) And it works as expected…

Ah, I think I understand now. It has to do with the creation of the ‘DebugProjectName’ folder. The project subfolders are not copied to the ‘debug’ folder. Fully understandable.

I guess that using the constant ‘DebugBuild’ is the way to circumvent this issue?

What is the value of fP.exists ?

Depends on the situation: debugger is true but the build is false. It is caused by what I describe above: ‘parent’ or ‘parent.parent’.

I consider it solved by using an if statement that uses
DebugBuild <> true then…