michaelb / sniprun

A neovim plugin to run lines/blocs of code (independently of the rest of the file), supporting multiples languages
MIT License
1.49k stars 47 forks source link

SnipInfo Command Error and Unable to receive user input. #222

Closed rileychc closed 1 year ago

rileychc commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Open a file containing '...'
  2. Run the command '....'
  3. See error '...'

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

Additional context Add any other context about the problem here.

michaelb commented 1 year ago

Hey, please fill correctly your bug report.

SnipInfo works on my end (I would be tempted to say 'obviously'), so unless you provide me with enough info, I won't be able to fix your issue

rileychc commented 1 year ago

~/.cache/sniprun/infofile.txt, I don't have this document

rileychc commented 1 year ago

But my main problem is that I still can't pop up to receive user input, causing my cin function to be a random value.

rileychc commented 1 year ago

local lines = lines_from(sniprun_cache_dir.."/infofile.txt") This code caused me to get a nil.

michaelb commented 1 year ago

But my main problem is that I still can't pop up to receive user input, causing my cin function to be a random value.

That's a limitation of sniprun. It won't be fixed in the near future, see #146

~/.cache/sniprun/infofile.txt, I don't have this document

It's supposed to be generated, and I hardly see where it can fail. Could you copy here the content of ~/.cache/sniprun/sniprun.log after trying to run SnipInfo ?

rileychc commented 1 year ago

I can't find the sniprun folder in the .cache folder.

michaelb commented 1 year ago

I can't find the sniprun folder in the .cache folder.

Wut. Does sniprun even work ? (Run it on a very simple line such as "print(1)" in a python file)

Or do you have an $XDG_CACHE_DIR environment variable that's set to somewhere strange ?

rileychc commented 1 year ago

I didn't set this $XDG_CACHE_DIR environment variable, and my sniprun can output printf("hello world");

michaelb commented 1 year ago

okay, so this just got from strange to stranger.

I'll explain. Sniprun (the binary part) generates stuff (including the infofile.txt, the log and some files it needs to run correctly) in a directory that's supposed to be standard

use dirs::cache_dir;

fn main() {
    println!("cache dir: {:?}", cache_dir());
}

And the Lua plugin part, that doesn't have the info, looks into $XDG_CACHE_HOME (sorry for earlier, it's ...HOME, not ...DIR), or defaults to $HOME/.cache

So, my conclusion is that these two don't point to the same location. You didn't say what OS you were running on, but possibly something isn't quite XDG-compliant. If you can determine where the dirs crate I use locate the cache directory on your system, you should be able to export XDG_CACHE_HOME to the same location, and get SnipInfo working

rileychc commented 1 year ago

I'm using macOS.

rileychc commented 1 year ago

So what should I do? Specify the path XDG_CACHE_HOME in the zshrc file, or should I make other settings?

michaelb commented 1 year ago

I think you should specify the XDG_CACHE_DIR in your shell's rc configuration file, but preferably make it point to the value of the default cache directory on macos (google says it's ~/Library/Caches, and if you find a sniprun subdir there it's confirmed).

I'll fix the search path for the infofile, but the above should fix the issue in the meantime

rileychc commented 1 year ago
image

It isn't useful.

michaelb commented 1 year ago

XDG_CACHE_HOME 😉 Sorry, I also keep making the mistake

michaelb commented 1 year ago

The last release also search for the temporary SnipInfo file in ~/Library/cache now, so it should be automatically fixed