Dotneteer/kliveide

ZXBasic - Path Issue (Mac)

citizenfish opened this issue · 9 comments

I have set up the path to zxbasic (Mac OSX) and it is correct in my project settings as shown below. But if I try to compile a program I get the error message:-

Compilation failed: ENONET: no such file or directory, open '/Users/daveb/klive_test_2/code/program.zxbas.bin

It looks to me like the bin suffix is the issue as the code is in program.zxbas with no bin suffix

{
  "machineType": "sp48",
  "viewOptions": {
    "showToolbar": true,
    "showSidebar": true,
    "showFrameInfo": true,
    "showKeyboard": false,
    "showStatusbar": true,
    "keyboardHeight": 0
  },
  "debugger": {
    "breakpoints": [],
    "resolved": []
  },
  "builder": {
    "roots": [
      "/code/code.kz80.asm",
      "/code/code.zxb.asm",
      "/code/program.zxbas"
    ]
  },
  "ide": {
    "zxbasic": {
      "executablePath": "/Users/daveb/dev/zxbasic/zxbc",
      "machineCodeOrigin": 32768
    }
  },
  "machineSpecific": {
    "fastLoad": false,
    "lastTapeFile": null,
    "clockMultiplier": 1,
    "soundLevel": 0.5,
    "muted": false
  }
}

Dave, thanks for signing this issue. Unfortunately, I do not have a Mac to reproduce the problem. According to the quick code check, it seems that Klive was unable to invoke ZXBC. The missing program.zxbas.bin file is supposed to be the compilation output.

Please, try to collect some more diagnostics info with the help of this article: https://dotneteer.github.io/kliveide/documents/detecting-klive-issues

I cannot see any errors in console. Only this in logs:-

2022-02-21T20:07:44.821Z: Sending response: CompileFileResponse (5)
2022-02-21T20:15:27.382Z: Request from IDE: CompileFile
2022-02-21T20:15:27.457Z: Error while invoking ZXBC compiler: Error: ENOENT: no such file or directory, open '/Users/daveb/dev/spectrum/debug/code/program.zxbas.bin'; Error: ENOENT: no such file or directory, open '/Users/daveb/dev/spectrum/debug/code/program.zxbas.bin'
    at Object.openSync (node:original-fs:585:3)
    at readFileSync (node:original-fs:453:35)
    at ZxBasicCompiler.compileFile (/Applications/Klive.app/Contents/Resources/app.asar/main.bundle.js:24419:79)
    at async processIdeRequest (/Applications/Klive.app/Contents/Resources/app.asar/main.bundle.js:10749:33)

But it looks like a path issue on MAC OSX as the file program.zxbas.bin is not getting created.

This works from command line:-

/Users/daveb/dev/zxbasic/zxbc ./program.zxbas --output program.zxbs.bin

I could build a copy locally and insert some debug in ZxBasicCompiler.ts. Is it easy to build?

I've managed to build and run locally.

The problem is in the file ompilerBase.ts

The cwd option of the exec command is not working on MacOSX. I checked that the correct value was being set for workdir but it made no difference.

This is fixable by changing the cmd variable as follows to include the full path to the command

const cmd = `${execPath} ${cmdArgs.split("\\").join("/")}`;

Dave, I'm glad you have found the issue and fixed it! In a few hours, I'll check that the fix works on Windows too, I will release a path version soon:-)

My pleasure. I'm happy to help you with Mac builds/testing. Just ask. And thanks for a great IDE

Dave, unfortunately, your fix does not work on Windows. Nonetheless, I combined your fix for Mac and the old way that works for Windows:

const filename = path.basename(execPath);
const args = cmdArgs.split("\\").join("/")
const cmd = `${__DARWIN__ ? execPath : filename} ${args}`;

It works on Windows and hopefully on Mac, too.

Here I send you the private build (v0.12.1) with the fix above:

https://1drv.ms/u/s!AqpbKz19ddp5or1VnAp867WgyV3HBw?e=hQleZr

Please try if it still works on your Mac! Thanks in advance.

Yes that works perfectly.

Thanks, Dave! Soon I will release v0.12.1 with this patch and close this issue right after the release. Please report any other issues you find!

Fixed in release v0.12.1