alefragnani / vscode-project-manager

Project Manager Extension for Visual Studio Code
GNU General Public License v3.0
1.88k stars 223 forks source link

[BUG] - baseFolders config does not work with ~ in path #663

Open nathanstone opened 1 year ago

nathanstone commented 1 year ago

Environment/version

Steps to reproduce

  1. Completely remove any baseFolders config from settings.json e.g. projectManager.any.baseFolders
  2. Re-add baseFolders config, either manually to settings.json or from Settings window, making sure to include a path with ~ e.g.
    "projectManager.any.baseFolders": [
    "~/Sites"
    ]
  3. The Any option will now be missing from the Project Manager views.
  4. The developer log gives the following error:
    workbench.desktop.main.js:89 [Extension Host] stack trace: Error: ENOENT: no such file or directory, lstat '~/Sites'
    at lstatSync (node:fs:1516:3)
    at Object.e.lstatSync (node:electron/js2c/asar_bundle:5:3752)
    at Function.handleSymlinks (/Users/nathan/.vscode/extensions/alefragnani.project-manager-12.7.0/dist/extension.js:1:113300)
    at t.CustomProjectLocator.locateProjects (/Users/nathan/.vscode/extensions/alefragnani.project-manager-12.7.0/dist/extension.js:1:87907)
    at /Users/nathan/.vscode/extensions/alefragnani.project-manager-12.7.0/dist/extension.js:1:88965
    at new Promise (<anonymous>)
    at t.CustomProjectLocator.refreshProjects (/Users/nathan/.vscode/extensions/alefragnani.project-manager-12.7.0/dist/extension.js:1:88788)
    at /Users/nathan/.vscode/extensions/alefragnani.project-manager-12.7.0/dist/extension.js:1:172821
  5. Expanding the config to the full path, will make it the Any option reappear e.g.
    "projectManager.any.baseFolders": [
    "/Users/nathan/Sites"
    ]

Continuing the conversation from issue #656

alefragnani commented 1 year ago

Hi @nathanstone ,

Thanks for the details, specially the log.

Out of curiosity, what happens if you use $home instead of the tilde symbol (~). Does it work?

Thank you

nathanstone commented 1 year ago

Assuming you mean something like this:

"projectManager.any.baseFolders": [
  "$home/Sites"
],

I get the exact same error.

alefragnani commented 1 year ago

In this case, I suppose there is some issue with Node.js on your computer. Not sure why.

For some reason, os.homedir(); seems not to be working for you. I use this as a replacement for ~ and $home while processing the paths.

alefragnani commented 1 year ago

@nathanstone ,

Are you still not able to use ~ or $home in the baseFolders settings? If not, could you try out this in Node.js REPL?

  1. Open node REPL typing node in the shell
  2. Type os.homedir()
  3. What is the output?
  4. Type os.userInfo().homedir
  5. What is the output?

The expected return in steps 3 and 5 should be /Users/nathan for you.

nathanstone commented 1 year ago

Still can't use either, only the full path works.

Running the above scripts outputs exactly as you predicted.

Tested on Node v18.12.1 & v16.19.1 on my machine.

Arnaud-IFEA commented 2 months ago

Hello, same problem here

Windows 11 WSL2/Debian

Welcome to Node.js v18.19.0.
Type ".help" for more information.
> os.homedir()
'/home/arnaud'
> os.userInfo().homedir
'/home/arnaud'
> 

but projectManager.git.baseFolders does not work with $home or ~.

fundor333 commented 1 month ago

Mac user here. projectManager.git.baseFolders does not work with $home or ~

How can I help you with it? Do you need some logs? Some love ❤️ ? Some help?