AmpersandTarski / Ampersand

Build database applications faster than anyone else, and keep your data pollution free as a bonus.
http://ampersandtarski.github.io/
GNU General Public License v3.0
40 stars 8 forks source link

no such directory ./templates #1276

Open stefjoosten opened 2 years ago

stefjoosten commented 2 years ago

What happened

I tried to compile a prototype using just the Ampersand compiler

sjo00577@BA92-VYF9TXMD9G % docker run -it --platform=linux/amd64 -v "$(pwd)":/scripts ampersandtarski/ampersand:v4.6.2 check foo.adl
This script of Foo contains no type errors.
sjo00577@BA92-VYF9TXMD9G % docker run -it --platform=linux/amd64 -v "$(pwd)":/scripts ampersandtarski/ampersand:v4.6.2 proto foo.adl 
Generating frontend...
Error while reading template.
File could not be read: .proto/templates/Atomic-OBJECT.html
.proto/templates/Atomic-OBJECT.html: openFile: does not exist (No such file or directory)
ExitFailure 130
sjo00577@BA92-VYF9TXMD9G % 

What I expected

I expected this file to generate some code, because foo.adl contains no errors

Version of ampersand that was used

Ampersand-v4.6.2 [51c3de2e65c540ef026925fe8547c991765a5588:refs/tags/v4.6.2]

Perception of the problem

This might have to do something with decoupling the prototype framework with the Ampersand compiler. I can imagine that the prototype templates are no longer available when using the compiler in standalone modus. However, it would be nice that a prototype without templates was generated instead of getting an error message.

hanjoosten commented 2 years ago

Indeed, the templates have been moved to the prototype repository. This is the most logical place for them to be. When generating the prototype files, the templates must be available, for they are used to generate the correct files. These templates are part of the framework. Consequence is, that the proto command can only be run when a prototype framework is available. @Michiel-s , do you agree, or do you see other options?

hanjoosten commented 2 years ago

We might consider to modify this error message explaining that a prototype framework is missing, and maybe even supply some hints.

Michiel-s commented 2 years ago

Indeed, as @hanjoosten explained correctly templates files are decoupled. That is because they need to be always in sync with the current framework version to work.

@stefjoosten You can run the proto command with the --no-frontend command. This will skip the frontend files that need the templates, but does generate backend configuration files, like the sql queries and more.

stefjoosten commented 2 years ago

Aha, we have a workaround! Alas, the cup isn't empty yet. Here is the result of running ampersand proto with the option--no-frontend:

sjo00577@BA92-VYF9TXMD9G FuncSpec % ampersand proto --no-frontend Foo.adl
Generating backend...
.proto/generics/database.sql: openFile: does not exist (No such file or directory)
ampersand: .proto/generics/database.sql: openFile: does not exist (No such file or directory)
sjo00577@BA92-VYF9TXMD9G FuncSpec % 
stefjoosten commented 2 years ago

That sounds like plenty of ideas. I suggest that the solution consists of three things:

Agreed?