vscode setup?
# help
d
I have been launching the open source Toit at the CLI on Ubuntu and wanted to try to use VSCode plugin again. When I open VSCode, with extension v1.6.5, I get the attached extension error. settings.json looks like:
Copy code
{
    "explorer.confirmDelete": false,
    "editor.tabSize": 2,
    "editor.detectIndentation": false,
    "toit.path": "/home/david/toit/build/host/sdk/bin/",
    "toitLanguageServer.command": ["/home/david/toit/build/host/sdk/bin/toit.lsp", "--toitc=/home/david/toit/build/host/sdk/bin/toit.compile"],
}
JAG is on the path, /home/david/toit/build/host/sdk/bin/ is not. AFter looking at some search results 'on spawnSync .. EACCES' , I updated the settings to:
Copy code
{
    "explorer.confirmDelete": false,
    "editor.tabSize": 2,
    "editor.detectIndentation": false,
    "toit.path": "/home/david/toit/build/host/sdk/bin/toit.run",
    "toitLanguageServer.command": [
      "/home/david/toit/build/host/sdk/bin/toit.lsp",
      "--toitc=/home/david/toit/build/host/sdk/bin/toit.compile"
    ],
    "jag.path": "/usr/local/bin/jag",
}
and got the error
Copy code
Running the toit tool at '/home/david/toit/build/host/sdk/bin/toit.run' yielded an error: Error: Command failed: /home/david/toit/build/host/sdk/bin/toit.run version -o short
Also, wasn't there a Toit logo in the Primary Sidebar ... or is the lack thereof, just a consequence of the extension configuration error? Any ideas? Thx
f
If
jag
is on your path you can remove all path entries of Toit. The extension will then just find
jag
and use its LSP server. The open source version does not have any sidebar. It does have done commands though:
jag.flash
,
jag.scan
,
jag.monitor
,
jag.monitor
, and
jag.watch
.
d
thx, fixed
s
I've created some .proto files using protogen, but when I open them in VSCode, I get squiggles for: import encoding.protobuf The error says: Failed to find import 'encoding.protobuf' CommandHandler.toit(5, 17): Missing library file. Tried '/encoding/protobuf.toit' and '/encoding/protobuf/protobuf.toit' do I need to set something up in VS code for this to work? I've set: "toit.path": "C:\Projects\toit\lib_v1.6.24", in settings.json, but it doesn't change anything
f
Which protobuf generator did you use?
The
encoding.protobuf
seems to indicate that you are using the old generator. I created a package with an updated version just last week: https://github.com/toitware/toit-protobuf
Fyi: there is still one outstanding PR to fix some issues with core types.
s
Yeah the one I'm using is probably from around feburary... will try with the new one
f
That one was for the v1. How did you find it? Is there some documentation we need to update?
s
Don't remember, it was in feb I used it last time, think it was this URL https://github.com/toitware/protoc-gen-toit
f
Ok. Thanks. I will update the readme there.
s
How can I see if protoc is actually using the latest ext.. seems to get the same result with the version you send
f
In theory the imports should have changed to
import protobuf
Without the
encoding.
s
Where is the extension put, maybe I need to change my path
f
You need to install the package with
jag pkg install protobuf
This is assuming you are using Jaguar
s
Yes, I am now
f
Ok.
So after installing the package your need to generate the toit files.
They should now work in your application.
If you are still see errors let me know. It might be the outstanding PR.
s
Not sure I'm getting this... As I unserstood it 'protogen' will look in my path to find the toit extension, so do I need to change my path to look at .packages
f
The package now comes with its own protogen executable.
So you need to switch to that one
s
Aha ok, so I need to use the protoc-gen-toit.exe instead
f
The protogen tool should still be able to find it.
If not there is probably a way to tell it where to look for it. Let me have a look.
If protogen only finds the old version, try this syntax
s
Can't seem to figure it out.... not that good at reading make files.... If I look in my go/bin dir, the protoc-gen-toit.exe still seems to be from 23-01-2022, would have expected it to get a newer version
f
Can you try to remove it?
And then try
go install github.com/toitware/toit-protobuf/tool@latest
again?
I hope that works. Not 100% sure if it's that easy. Not too familiar with Go's package manager
s
don't get a new version....let me try to see if it has put it a different place
f
Did you get another executable? Or did it have the old executable somewhere in the cache?
Or just nothing?
I just googled a bit. You should be able to delete the old Go executable the following way: https://stackoverflow.com/a/13792319
That said: this is super old question/response. Will continue looking a bit, if there is a better way now.
s
Just ran the 'go install' with verbose logging (-v -x -a) and it turns out the output is called tool.exe and not protoc-gen-toit.exe. Renamed it to protoc-gen-toit.exe and ran protoc again, and now the generated .toit files are different..... Still got at lot of squiggles... will look into that tomorrow
f
ohh. Good to know. Thanks!
I will see if it's possible to give it a different name during install.
Just "tool" in the bin folder would be a bit confusing.
s
Yeah, think it got the correct name when I installed it in feb, so something must have changed....
f
I moved the tool into a different repository.
Maybe there is also a way to change the name inside the repository.
I just created a PR that changes the module name. Hopefully that's enough. (Can't test without committing, and waiting for a review first). Thanks again for looking into this.
I just committed the fixes.
go install github.com/toitware/toit-protobuf/protoc-gen-toit@latest
should work now. Also, the core types should work correctly, now.
s
Now I got rid of most of the squiggles, but still have on: import pubsub but is that because 'pubsub' is not supported anymore?
f
Correct. Pubsub is not supported anymore. We recommend MQTT instead.
For testing and low volume I generally recommend http://io.adafruit.com
s
Keep getting these errors: \protogen\google\protobuf\timestamp_pb.toit:4:8: error: Package for prefix 'protobuf' not found import protobuf as _protobuf ^~~~~~~~ \protogen\google\protobuf\timestamp_pb.toit:8:35: error: Unresolved super class class Timestamp extends _protobuf.Message: ^~~~~~~ 'timestamp_pb.toit' seems to be located under: .packages\github.com\toitware\toit-protobuf\1.0.0\src\protogen\google\protobuf Am I missing some package?
f
I fixed this today.
You just need to do a
jag pkg update
Sorry about that.
s
Ok, will try that, thx
Yes, that solved it 👍
3 Views