Vindaar / ggplotnim

A port of ggplot2 for Nim
https://vindaar.github.io/ggplotnim
MIT License
177 stars 15 forks source link

Running examples in VSCode under Windows #152

Closed OxeStone closed 1 year ago

OxeStone commented 1 year ago

Has anyone tried to run Vindaar's examples on the main page in VSCode? I get the error below

[Running] nim compile --verbosity:0 --hints: off --run "D:\Projects\Programming\nim\Examples\ggplot\ggplot_vega.nim" oserrors.nim(95) raiseOSError Error: unhandled exception: The system cannot find the file specified. [OSError] Error: execution of an external program failed: 'd:\Projects\Programming\nim\Examples\ggplot\ggplot_vega.exe'

When I compile from the command line, I don't get any errors. Any advice?

Vindaar commented 1 year ago

I'm not entirely sure what's going on, but I can only assume the problem is from where you compile and run the program (given the path that is visible in your snippet).

The two examples in the README assume you're in the root of the project (see the usage of the explicit "data/mpg.csv" input file path and "media/recipes/rSimpleVegaLite.html"). You will need to copy the mpg.csv file somewhere else or change the path to point to the file. Keep in mind that we currently do not resolve things like ~ in paths (well, you're on windows, but I'm mentioning it because maybe there's some kind of equivalent).

Further, the ggvega call at the moment does not create non existent directories. So if you only change the input file path, the output will likely cause issues, due to the nested media/recipes directories, which for you will likely not exist.

OxeStone commented 1 year ago

Thank you for the quick response. I am not sure what's happening either. I have all the files residing in or being created in the root folder of the project (I had edited the paths). I find it odd that the error is in 'oserrors.nim' and can't figure out what file the system cannot find.

Vindaar commented 1 year ago

The fact that you see the error from oserrors.nim just tells you that a file open call of sorts failed (which is what you will see if the readCsv call can't find the file (I should probably add a manual exception if the file doesn't exist though).

Does a regular example (one without vega-lite) work? And does a simple

import datamancer
let df = readCsv("path/to/mgp.csv")
echo df

work?

OxeStone commented 1 year ago

Exactly the same error as previously reported. The program compiles and creates the EXE file. The error is issued at runtime. I tried both from VSCode and from CLI. So, it may not be a VSCode issue after all.

Vindaar commented 1 year ago

It's expected that the program compiles fine and only throws the error at runtime, if the CSV file is not found. I think the issue is likely that you're not running the program from where you think you might, messing up the expected path to the file. Did you give the full path to the CSV file ("C:...\mgp.csv" or whatever drive it's on)?

OxeStone commented 1 year ago

No, I had not given the full path. I added the full pathname and it's working. Thank you. Just a reminder to anyone having the same issue, use either '\' or '/' in the full pathname.