twibiral / obsidian-execute-code

Obsidian Plugin to execute code in a note.
MIT License
1.09k stars 66 forks source link

Replaced Windows file separator with path.join in Executor.getTempFile #350

Closed nfiles closed 4 months ago

nfiles commented 4 months ago

Description:

All code snippets failed to execute on Mac with the error:

/usr/local/bin/bash: /var/folders/gy/5n_nrgl56d9f7_m2df17001w0000gr/Ttemp_1715619532117.sh: No such file or directory

Solution:

A previous commit (59414abba95ee3caf5ecedf259016c2bfdd119ee) hard-coded the Windows file separator (\) in Executor.getTempFile.

This change replaces the Windows file separator with the Node built-in path.join so the getTempFile will automatically use the correct OS file separator.

Testing:

  1. clone and make changes locally
  2. npm ci
  3. npm run build
  4. cp main.js <vaultpath>/.obsidian/plugins/execute-code/
  5. reload extension and execute snippet

Fixes twibiral/obsidian-execute-code#347


Edit: tested successfully on Windows 10 as well

nfiles commented 4 months ago

Note: this worked locally (on a 2019 Intel Mac Pro), but I haven't tested on Windows or Windows+WSL.

mmmkb1 commented 4 months ago

Currently I'm using a MacBook Air 13. I want to specifically thank you. javascript works fine but dart didn't work. So I Googled it, but it didn't solve the problem. It worked out this way. Thank you for the specific method. I hope the administrator will update you officially soon.

nfiles commented 4 months ago

I tested this on my windows 10/WSL machine and can confirm that it works for

twibiral commented 4 months ago

Thanks for the detective work! Doing the updates to 1.11.x I faced some issues with too many different merges and changes. Thank you for answering all the issues and finding the problem

twibiral commented 4 months ago

Published in release version 1.12.0