teal-language / tl

The compiler for Teal, a typed dialect of Lua
MIT License
2.03k stars 101 forks source link

Error: could not predefine module 'love-example' #660

Closed kayibea closed 1 year ago

kayibea commented 1 year ago

I have been following teal tutorial, i am trying to make my custom predefine module, so for that i took the love from the tutorial, but when running tl build or tl check main.tl i get this error

Error: could not predefine module 'love-example'

Screenshot from 2023-05-17 04-21-26

kayibea commented 1 year ago

Update: It work when using the command as super user sudo tl build looks like teal only work when installed globally

hishamhm commented 1 year ago

@gloirekiba it should work without sudo. Make sure the permissions in your files are correct and all paths are reachable.

Also, tl build is deprecated, please use https://github.com/teal-language/cyan as your build manager!

kayibea commented 1 year ago

My permissions and path are correct, and i can invoke teal from everywhere since it is in the $PATH, but vscode-teal is the only one not able to find teal, it require me to install teal globally

Screenshot from 2023-05-17 18-39-37

Screenshot from 2023-05-17 18-49-31

Thanks i did not know about cyan, i am gonna check

lenscas commented 1 year ago

My permissions and path are correct, and i can invoke teal from everywhere since it is in the $PATH, but vscode-teal is the only one not able to find teal, it require me to install teal globally

I had similar problems with Ruby's tooling some time ago, with it working flawlessly everywhere but vscode. The problem is related to how vscode spawns as it doesn't take over the environment entirely from your terminal nor runs the exact same files to setup the environment as your terminal does.

So, if I had to guess the local luarocks bin folder is set to be added to the $PATH but that the line to do that is in a file that vscode doesn't run.

hishamhm commented 1 year ago

In addition, your love-example.d.tl doesn't seem to be in a location that matches Lua/Teal module search paths. Lua does have ./?.lua by default (which Teal auto-translates to ./?.tl and ./?.d.tl for its own search when there's no separate TL_PATH env variable defined), but something weird may be going on due to vscode environment variables. You may want to try to explicitly add the folder to the search list in your tlconfig.lua using include_dir = { "/folder/where/my/files/are" }, this might do the trick.

Hope this helps. I'll close this issue since I think this is more of a local configuration issue rather than an actual bug in tl.