guild icon
Toit
#vscode setup?
Thread channel in help
davidg238
davidg238 10/16/2022 02:26 AM
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:
{ "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:
{ "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
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
(edited)
floitsch
floitsch 10/16/2022 09:18 AM
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.
davidg238
davidg238 10/16/2022 04:52 PM
thx, fixed
smolesen
smolesen 10/30/2022 07:54 PM
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 '<sdk>/encoding/protobuf.toit' and '<sdk>/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
floitsch
floitsch 10/30/2022 07:55 PM
Which protobuf generator did you use?
floitsch
floitsch 10/30/2022 07:57 PM
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
Protobuf library and tools for Toit. Contribute to toitware/toit-protobuf development by creating an account on GitHub.
floitsch
floitsch 10/30/2022 07:58 PM
Fyi: there is still one outstanding PR to fix some issues with core types.
smolesen
smolesen 10/30/2022 08:01 PM
Yeah the one I'm using is probably from around feburary... will try with the new one
floitsch
floitsch 10/30/2022 08:02 PM
That one was for the v1.

How did you find it? Is there some documentation we need to update?
smolesen
smolesen 10/30/2022 08:10 PM
Don't remember, it was in feb I used it last time, think it was this URL
https://github.com/toitware/protoc-gen-toit
Protocol compiler plugin to generate Toit code. Contribute to toitware/protoc-gen-toit development by creating an account on GitHub.
floitsch
floitsch 10/30/2022 08:11 PM
Ok. Thanks.
I will update the readme there.
smolesen
smolesen 10/30/2022 08:13 PM
How can I see if protoc is actually using the latest ext.. seems to get the same result with the version you send(edited)
floitsch
floitsch 10/30/2022 08:14 PM
In theory the imports should have changed to import protobuf
floitsch
floitsch 10/30/2022 08:14 PM
Without the encoding.
smolesen
smolesen 10/30/2022 08:14 PM
Where is the extension put, maybe I need to change my path
floitsch
floitsch 10/30/2022 08:15 PM
You need to install the package with jag pkg install protobuf
floitsch
floitsch 10/30/2022 08:16 PM
This is assuming you are using Jaguar
smolesen
smolesen 10/30/2022 08:16 PM
Yes, I am now
floitsch
floitsch 10/30/2022 08:16 PM
Ok.
floitsch
floitsch 10/30/2022 08:16 PM
So after installing the package your need to generate the toit files.
floitsch
floitsch 10/30/2022 08:17 PM
They should now work in your application.
floitsch
floitsch 10/30/2022 08:18 PM
If you are still see errors let me know. It might be the outstanding PR.
smolesen
smolesen 10/30/2022 08:26 PM
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
floitsch
floitsch 10/30/2022 08:27 PM
The package now comes with its own protogen executable.
floitsch
floitsch 10/30/2022 08:28 PM
Protobuf library and tools for Toit. Contribute to toitware/toit-protobuf development by creating an account on GitHub.
floitsch
floitsch 10/30/2022 08:28 PM
So you need to switch to that one
smolesen
smolesen 10/30/2022 08:30 PM
Aha ok, so I need to use the protoc-gen-toit.exe instead
floitsch
floitsch 10/30/2022 08:30 PM
The protogen tool should still be able to find it.
floitsch
floitsch 10/30/2022 08:31 PM
If not there is probably a way to tell it where to look for it. Let me have a look.
floitsch
floitsch 10/30/2022 08:31 PM
Protobuf library and tools for Toit. Contribute to toitware/toit-protobuf development by creating an account on GitHub.
floitsch
floitsch 10/30/2022 08:32 PM
If protogen only finds the old version, try this syntax
smolesen
smolesen 10/30/2022 08:42 PM
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
floitsch
floitsch 10/30/2022 08:43 PM
Can you try to remove it?
floitsch
floitsch 10/30/2022 08:43 PM
And then try go install github.com/toitware/toit-protobuf/tool@latest again?
floitsch
floitsch 10/30/2022 08:44 PM
I hope that works. Not 100% sure if it's that easy. Not too familiar with Go's package manager
smolesen
smolesen 10/30/2022 08:45 PM
don't get a new version....let me try to see if it has put it a different place(edited)
floitsch
floitsch 10/30/2022 08:46 PM
Did you get another executable? Or did it have the old executable somewhere in the cache?
floitsch
floitsch 10/30/2022 08:46 PM
Or just nothing?
floitsch
floitsch 10/30/2022 09:02 PM
I just googled a bit.
You should be able to delete the old Go executable the following way: https://stackoverflow.com/a/13792319
I ran go get package to download a package before learning that I needed to set my GOPATH otherwise that package sullies my root Go install (I would much prefer to keep my Go install clean and sepa...
floitsch
floitsch 10/30/2022 09:02 PM
That said: this is super old question/response. Will continue looking a bit, if there is a better way now.
smolesen
smolesen 10/30/2022 10:27 PM
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
floitsch
floitsch 10/30/2022 10:28 PM
ohh. Good to know. Thanks!
floitsch
floitsch 10/30/2022 10:28 PM
I will see if it's possible to give it a different name during install.
floitsch
floitsch 10/30/2022 10:29 PM
Just "tool" in the bin folder would be a bit confusing.
smolesen
smolesen 10/30/2022 10:29 PM
Yeah, think it got the correct name when I installed it in feb, so something must have changed....
floitsch
floitsch 10/30/2022 10:30 PM
I moved the tool into a different repository.
floitsch
floitsch 10/30/2022 10:30 PM
Maybe there is also a way to change the name inside the repository.
floitsch
floitsch 10/30/2022 10:35 PM
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.
floitsch
floitsch 10/31/2022 01:09 PM
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.
smolesen
smolesen 10/31/2022 06:31 PM
Now I got rid of most of the squiggles, but still have on:
import pubsub
but is that because 'pubsub' is not supported anymore?
floitsch
floitsch 10/31/2022 09:25 PM
Correct. Pubsub is not supported anymore. We recommend MQTT instead.
floitsch
floitsch 10/31/2022 09:26 PM
For testing and low volume I generally recommend http://io.adafruit.com(edited)
Adafruit IO is the easiest way to get your projects onto the Internet of Things!
smolesen
smolesen 11/01/2022 07:26 PM
Keep getting these errors:

<pkg:toit-protobuf>\protogen\google\protobuf\timestamp_pb.toit:4:8: error: Package for prefix 'protobuf' not found
import protobuf as _protobuf
^~

<pkg:toit-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?
floitsch
floitsch 11/01/2022 07:27 PM
I fixed this today.
floitsch
floitsch 11/01/2022 07:27 PM
You just need to do a jag pkg update
floitsch
floitsch 11/01/2022 07:27 PM
Sorry about that.
smolesen
smolesen 11/01/2022 07:27 PM
Ok, will try that, thx
smolesen
smolesen 11/01/2022 07:29 PM
Yes, that solved it :๐Ÿ‘:
๐Ÿ‘1
58 messages in total