Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode mainbeanfile: no effect #43

Open
Dr-Nuke opened this issue Apr 3, 2020 · 10 comments
Open

VSCode mainbeanfile: no effect #43

Dr-Nuke opened this issue Apr 3, 2020 · 10 comments

Comments

@Dr-Nuke
Copy link

Dr-Nuke commented Apr 3, 2020

I'd love to use the autocomplete feature based on my full ledger, but i can't get it working. Any suggestions?

[SOLVED: see solution at the bottom of this opening post]

System: WSL Ubuntu 18.04 & VSCode, beancount extension

steps to reproduce:

  1. in terminal, cd to main bean folder
  2. enter "code ."
  3. in the vscode window, look for the setting "beancount.mainBeanFile" and override default to "~/pathToLedgerFolder/LedgerFiles/main.bean" Question: should this be in user or workspace preferences? I put it in both to be sure.
  4. make file child.bean and add the line "include child.bean" to main.bean. save main.bean.
  5. open child.bean, enter the following incomplete transaction and observe no autocomplete suggestions:
    image

intended behavior:
show suggestions from main.bean and all included files (image from within main.bean:
image

I also made the settings.json with

{
    "beancount.mainBeanFile": "~/pathToLedger/LedgerFolder/Ledgerfiles/main.bean"
}

according to the scheme below. I wonder how it relates to the user/workspace settings of vscode

BeanFolder
├── ledgerFiles
│ ├── .vscode
│ │ └── settings.json
│ └── main.bean

SOLUTION

The cause of the problem was

  1. me specifying an absolute path of the main.bean file where a relative path is required.
  2. me using "~/" instead of "home/" for specifying the python path.

so i could fix the problem by changing

{
    "beancount.mainBeanFile": "~/pathToLedger/BeanFolder/Ledgerfiles/main.bean",
    "beancount.python3Path": "~/path/miniconda3/envs/Bean/bin/python3"
}

to

{
    "beancount.mainBeanFile": "main.bean",
    "beancount.python3Path": "home/path/miniconda3/envs/Bean/bin/python3"
}

just to be clear, these lines need to be

BeanFolder
├── ledgerFiles
│   ├── .vscode
│   │   └── settings.json  <- in this file
│   └── main.bean

you can find the correct relative path by right clicking the main.bean in the explorer pane:
image

the correct python path you can find by entering which python3 and copy-pasting the answer

[edit]
with these 2 paths in my Workspace Setting I managed to activate auto completion without the restriction of having the main bean folder as vscode working space folder.

@Lencerf
Copy link
Owner

Lencerf commented Apr 3, 2020

Have installed Python3 and beancount, and set beancount.python3Path to the correct path?

@Dr-Nuke
Copy link
Author

Dr-Nuke commented Apr 3, 2020

yes:

{
    "beancount.mainBeanFile": "~/pathToLedger/BeanFolder/Ledgerfiles/main.bean",
    "beancount.python3Path": "~/path/miniconda3/envs/Bean/bin/python3"
}

BeanFolder
├── LedgerFiles
│ ├── .vscode
│ │ └── settings.json <- in this file
│ └── main.bean

@Lencerf
Copy link
Owner

Lencerf commented Apr 3, 2020

Can you please open VSCode's Output panel and switch to beancount to show me the content like this?
telegram-cloud-photo-size-5-6334729015734151592-y

@Dr-Nuke
Copy link
Author

Dr-Nuke commented Apr 3, 2020

yes. it says

try finding a valid bean file...user specified a main bean file with a relative path...
find no valid bean files.
try finding a valid bean file...user specified a main bean file with a relative path...
find no valid bean files.

so i guess the the file specification is not at the correct place or the vscode workspace folder is a wrong one. i wondered about that and how to find out.

@Lencerf
Copy link
Owner

Lencerf commented Apr 3, 2020

Can you please try opening BeanFolder as your workspace and set beancount.mainBeanFile to "main.bean" in workspace settings? If this still does not work, what is the output?

@Dr-Nuke
Copy link
Author

Dr-Nuke commented Apr 3, 2020

[wanted to edit my previous post but you commented quicker]
i found the message say "relative path", where i specified absolute paths. i changed the settings string above to only the file name (so without path) and the file seems to be recognized now. the new output is

try finding a valid bean file...user specified a main bean file with a relative path...
running ~/path/miniconda3/envs/Bean/bin/python3 /home/path/.vscode-server/extensions/lencerf.beancount-0.5.6/pythonFiles/beancheck.py,/home/path/myfiles/Beanfolder/ledgerfiles/main.bean,--payeeNarration to refresh data...
error: Error: spawn ~/path/miniconda3/envs/Bean/bin/python3 ENOENT

this error is probably related to node.js and not of beancount's concern, according to
https://stackoverflow.com/questions/27688804/how-do-i-debug-error-spawn-enoent-on-node-js
... on the verge of solveing the next error :D

@Lencerf
Copy link
Owner

Lencerf commented Apr 3, 2020

I guess the issue is ~ in beancount.python3Path. Maybe you can try a full path?

@Dr-Nuke
Copy link
Author

Dr-Nuke commented Apr 3, 2020

I guess the issue is ~ in beancount.python3Path. Maybe you can try a full path?

you nailed it. that fixed it. now the suggestions in child.bean are properly displayed. i will edid the opening post with the solution and then we can close this.

thanks a ton for your help & suggestions!

@Dr-Nuke Dr-Nuke closed this as completed Apr 3, 2020
@Dr-Nuke Dr-Nuke changed the title VSCode mainbeanfile: no effect VSCode mainbeanfile: no effect [solved] Apr 3, 2020
@Dr-Nuke
Copy link
Author

Dr-Nuke commented Feb 1, 2023

reopening this thread.
I migrated my beancount setup to a new computer, and the plugin fails again.

WSL2 Ubuntu 22.04.1 LTS

as before, settings.json and file structure is

{
    "beancount.mainBeanFile": "home/pathToLedger/BeanFolder/Ledgerfiles/main.bean",
    "beancount.python3Path": "home/pathto/miniconda3/envs/Bean/bin/python3"
}
BeanFolder
├── LedgerFiles
│ ├── .vscode
│ │ └── settings.json <- in this file
│ └── main.bean
│ └── includeFile1.bean
│ └── includeFile2.bean
│ └── includeFile3.bean
│ └── includeFile4.beann

The beancount extension ouput reads, when I select open my main.bean file:

try finding a valid bean file...user did not specify a main bean file in settings...use the bean file in current editor.
running python3 /home/path/.vscode-server/extensions/lencerf.beancount-0.9.1/pythonFiles/beancheck.py,/home/pathtoLedger/BeanFolder/LedgerFiles/main.bean,--payeeNarration to refresh data...
try finding a valid bean file...user did not specify a main bean file in settings...use the bean file in current editor.
Data refreshed.

the affected files show
image
where every transaction has the tooltip for unknown accounts:
image
the problem seems to randomly occur and disappear when i click through the importfiles

any suggestions? Is there a way to debug the extension?
Thanks!

the beancount output mentions lencerf.beancount-0.9.1, where the installed beancount from pip has version 2.3.5

@Dr-Nuke Dr-Nuke reopened this Feb 1, 2023
@Dr-Nuke Dr-Nuke changed the title VSCode mainbeanfile: no effect [solved] VSCode mainbeanfile: no effect Feb 9, 2023
@Dr-Nuke
Copy link
Author

Dr-Nuke commented Feb 9, 2023

Can you please try opening BeanFolder as your workspace

i indeed opened the main folder in a new vscode window, et voila, it works.
Any Idea how to tweak my standard workspace such that this still works?
However, this will be a temporary workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants