Almenon/AREPL-vscode

Arepl using code file directory when VScode uses parent directory

Closed this issue · 3 comments

Describe the bug
AREPL and VSCode don't agree on which directory to use, causing AREPL to not see files that VSCode can. A setting or option to set the working directory for AREPL could fix this problem, but I couldn't find that setting.

To Reproduce
Steps to reproduce the behavior:

  1. Make a parent folder
  2. Add a folder for your code within the parent.
  3. Add some kind of file or folder to the parent, as a sibling folder to the code folder.
    github bug
  4. Attempt to access the file in AREPL, and by running the program
  5. Error

Expected behavior
I expected either both AREPL and VSCode to read the file, or both to be unable to read the file.

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

image

Other Information (please complete the following information):

  • OS: Windows 11
  • Python Version: 3.12.6

Additional context
I understand that I could change the working directory of VSCode, but I would really prefer if I could change AREPL's working directory instead.

AREPL uses the directory that the file resides by default, unless that file is a new unsaved file, upon which it uses the workspace directory. So if you move test.txt to the code directory the it will work.

Or if you add this code at the top then your code will work:

import os
os.chdir('../')

(this will change the directory to be one directory higher)

You could also submit a PR to this repo to add a setting to customize the directory used.

The problem with all files needing to be accessed by AREPL having to be in the code directory is that it messes up with organization. For my projects, utilities that the code needs to access is in a different folder that is adjacent to the code folder, like this:
image

Your solution, while functional, still has the problem of VSCode and AREPL disagreeing with one another on which directory to use, which still causes problems
image

The only solution I have found was to change the terminal's directory to match AREPL's
image

Which works when you're doing an isolated coding session, but requires you to remember to change the code before committing it to anything, since it wouldn't work on other systems unless they also change their directory.

If there's no way to edit AREPL's directory, then I definitely do suggest adding that feature! I'm still learning how to code properly, and I've essentially been using AREPL for as long as i've been programming. I'm not sure if I'm good enough to add the feature myself and make a PR, but I do think considering adding the feature in the future might be a good idea.

Thank you for your help and your consideration