Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set working directory when calling pico8 -run #4

Open
merwok opened this issue Feb 18, 2022 · 5 comments
Open

Set working directory when calling pico8 -run #4

merwok opened this issue Feb 18, 2022 · 5 comments
Assignees

Comments

@merwok
Copy link

merwok commented Feb 18, 2022

Hello and thanks for this package!

My projects are in sub-sub-directories of the pico-8 carts location, or in other directories entirely.
I usually run !pico8 -run % which works as pico-8 interprets the relative path correctly (I have autochangedir note), it does not try to load the filename from its carts directory. With :Pico8Run I get loading errors.
I think the current working directory should be set for the pico-8 process, or the absolute file path should be passed.

@Bakudankun
Copy link
Owner

Thank you for your report!
I could not reproduce the problem on my Windows environment, but it seems better to pass the absolute file path.
Please update the plugin and check if your problem has been resolved.

@merwok
Copy link
Author

merwok commented Feb 19, 2022

Thanks for the quick reply!

I updated and still have a loading error with the absolute path. I will try to find more info!

@merwok
Copy link
Author

merwok commented Feb 20, 2022

I ran with strace and found that this path is tried:

openat(AT_FDCWD, "/home/user/working/dir/'/home/user/working/dir/cart.p8'", O_RDONLY) = -1 ENOENT

So pico8 is already aware of the working directory, but passing a full path leads to bad concatenation.
I am reverting the change you did to see the original issue.

@merwok
Copy link
Author

merwok commented Feb 20, 2022

The original issue was a bad path too: "/home/user'/home/user/working/dir/cart.p8'"
Feels that pico-8 wants an unexpanded, unquoted relative path!

@merwok
Copy link
Author

merwok commented Feb 20, 2022

This change works for me with the autochdir option active, but not without!

diff --git a/autoload/pico8.vim b/autoload/pico8.vim
index a4ff0ae..c869a58 100644
--- a/autoload/pico8.vim
+++ b/autoload/pico8.vim
@@ -14,7 +14,7 @@ endfunction
 
 
 function! pico8#run(mods, options) abort
-  let cmdline = '"' . pico8#get_config('pico8_path', 'pico8') . '" -run ' . expand('%:p:S')
+  let cmdline = '"' . pico8#get_config('pico8_path', 'pico8') . '" -run ' . expand('%')
   if has('win32')
     " PICO-8 on Windows does not output logs if run directly.
     let cmdline = $ComSpec . ' /C "' . cmdline . '"'
``

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants