code_runner.nvim icon indicating copy to clipboard operation
code_runner.nvim copied to clipboard

Running code inside a folder that have spaces on its name results in "too many arguments" error (and how to fix it)

Open yosuanicolaus opened this issue 3 years ago • 2 comments

I'm using the default lazy configuration from the README

image

Problem: The RunCode/RunFile command works well, except for when we are trying to run file inside a directory that has space(s) in its name- for example: "Chapter 03 - If"/ folder.

image

If we rename the directory to not have spaces, it will work as expected

image

I suspect it has something to do with how the "$dir" in filetype from setup returns the string. I found a quick fix by wrapping the $dir with a ' ' (colon) will work as expected.

-- before
cpp = "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir/$fileNameWithoutExt",
-- after
cpp = "cd '$dir' && g++ $fileName -o $fileNameWithoutExt && '$dir/$fileNameWithoutExt'",

yosuanicolaus avatar Feb 19 '23 08:02 yosuanicolaus

use this -- after cpp = "cd '$dir' && g++ $fileName -o $fileNameWithoutExt && '$dir/$fileNameWithoutExt'",

CRAG666 avatar Feb 19 '23 23:02 CRAG666

Doesn't work if mode = "toggleterm" is set. Output becomes: "cd

Hobbyist11 avatar May 24 '23 06:05 Hobbyist11