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

Too much quotation in generated configurations in .env.public #116

Closed
cmungall opened this issue Jun 19, 2024 · 12 comments · Fixed by #123
Closed

Too much quotation in generated configurations in .env.public #116

cmungall opened this issue Jun 19, 2024 · 12 comments · Fixed by #123
Assignees

Comments

@cmungall
Copy link
Member

LINKML_SCHEMA_NAME="{{cookiecutter.__project_slug}}"
LINKML_SCHEMA_AUTHOR="{{cookiecutter.__author}}"
LINKML_SCHEMA_DESCRIPTION="{{cookiecutter.project_description}}"
LINKML_SCHEMA_SOURCE_PATH="{{cookiecutter.__source_path}}"
LINKML_SCHEMA_GOOGLE_SHEET_ID="{{cookiecutter.google_sheet_id}}"
LINKML_SCHEMA_GOOGLE_SHEET_TABS="{{cookiecutter.google_sheet_tabs}}"

The quotes don't function like normal quotes, they end up in the string

@sbliven
Copy link

sbliven commented Jun 20, 2024

I ran into this too. Makefiles expect variables not to be quoted. The default .env.public results in errors like

bash: -c: line 1: unexpected EOF while looking for matching `"'
make: *** [compile-sheets] Error 2

@noelmcloughlin
Copy link
Contributor

I will have a look at this.

@amc-corey-cox
Copy link
Contributor

Here is my full error message:

Writing lock file

Installing the current project: sepio_linkml (0.0.0.post2.dev0+842b967)
mkdir -p src/"sepio_linkml"/datamodel
poetry run sheets2linkml --gsheet-id "19Rp5DLFS3a1Yvvw84mPupgEkCMFRKax4LXCcwX84Vbg" "release_subset_v1" > "src/sepio_linkml/schema//release_subset_v1.yaml.tmp && mv "src/sepio_linkml/schema//release_subset_v1.yaml.tmp "src/sepio_linkml/schema//release_subset_v1.yaml
bash: -c: line 1: unexpected EOF while looking for matching `"'
make: *** [Makefile:116: compile-sheets] Error 2

@amc-corey-cox
Copy link
Contributor

amc-corey-cox commented Aug 29, 2024

This looks like the quotes are somehow being dropped on the ends of variables when we run sheets2linkml. I got this when I ran make setup. I'll dig in to the .env file and see whether I can fix something there.

@amc-corey-cox
Copy link
Contributor

amc-corey-cox commented Aug 29, 2024

This is the offending line in the Makefile:

$(RUN) sheets2linkml --gsheet-id $(SHEET_ID) $(SHEET_TABS) > $(SHEET_MODULE_PATH).tmp && mv $(SHEET_MODULE_PATH).tmp $(SHEET_MODULE_PATH)

I don't know why it is eating the " at the end of these variables from the variables defined at the top of the Makefile but it appears to be when we append text to the variable, so the statements $(SHEET_MODULE_PATH).tmp and $(SHEET_MODULE_PATH).tmp don't have closing ". Also, $(SHEET_MODULE_PATH) which is defined in the header as $(SOURCE_SCHEMA_DIR)/$(SHEET_MODULE).yaml has the same problem with missing the closing ".

As expected, since we have three opening " without closing " bash exits with an error stating there is a missing ", if it were an even number the line would execute but probably make a mess.

@amc-corey-cox
Copy link
Contributor

amc-corey-cox commented Aug 29, 2024

Removing quotes from the variable definition for LINKML_SCHEMA_SOURCE_PATH in env.public solves the issue and allows make setup to run the line without issues related to ".

And here is a bit of a trace from that line to how it causes the issue in the Makefile:

SOURCE_SCHEMA_PATH = $(LINKML_SCHEMA_SOURCE_PATH)
SOURCE_SCHEMA_DIR = $(dir $(SOURCE_SCHEMA_PATH))
SHEET_MODULE_PATH = $(SOURCE_SCHEMA_DIR)/$(SHEET_MODULE).yaml

compile-sheets:
        $(RUN) sheets2linkml --gsheet-id $(SHEET_ID) $(SHEET_TABS) > $(SHEET_MODULE_PATH).tmp && mv $(SHEET_MODULE_PATH).tmp $(SHEET_MODULE_PATH)

I'm not very familiar with Makefile so I'm not sure how to solve this in the current infrastructure but I'd be happy to help.

@noelmcloughlin
Copy link
Contributor

Thanks for feedback - unfortunately I am intermittent contributor (and my work laptop cannot access public GitHub, so I need to grab my neglected personal laptop). This issue was first raised in #106 so needs solution.

Would you be wiling to raise a PR to remove all quotes from .env.public file? @amc-corey-cox

This is acceptable regression as that file is my idea and needs incremental fixing.
I raised wider discussion here: https://github.com/orgs/linkml/discussions/2296

@amc-corey-cox
Copy link
Contributor

@noelmcloughlin Sure, I'm happy to help out on this. I'll try just implementing your suggestion and see what we break.

@sbliven
Copy link

sbliven commented Sep 4, 2024

Makefile quoting is a mess. I think the normal suggestion is to not use quotes if there aren't any spaces in the variable (definitely true for the google vars, and likely true for the path)

@amc-corey-cox
Copy link
Contributor

amc-corey-cox commented Sep 9, 2024

Looking a little deeper at this, this is actually a make file, not an environment file or a Bash script file. I think we should be more clear in how we define this.

At minimum, I will include a statement in the file that this is a make-file. I would prefer to change the name from .env.public to .vars.public.mk but I'm concerned this might cause unnecessary breakage for users using cruft to update their cookie-cutters.

For now, I'll remove the excess quotation and make a notation within the file that states it is a make-file not an env file or a bash script (it kinda looks like it could be either).

Please share your thoughts on changing the file name.

@noelmcloughlin
Copy link
Contributor

Hi !!
The file originated from me and is not community driven request - i.e. nobody requested a make file with variables.
I was testing this project with different models and encountered various problems so I raised few Issues and lot of PRs.
I focused on setting environment variables manually and/or using that file and everything eventually seemed to work.
However, issues have emerged since -- so I think I need to rethink entire solution.

Feel free to rename file - I think nobody else cares at this point - they just want bug fixed I guess so that is why I suggested removing quotes as first step.

@noelmcloughlin
Copy link
Contributor

I'm bit puzzled why I never saw errors when testing, usually I am thorough testing. Is there some extra tooling people use with makefiles? Maybe there is a linter for makefiles, I might investigate that also.

@amc-corey-cox amc-corey-cox self-assigned this Sep 10, 2024
@amc-corey-cox amc-corey-cox linked a pull request Sep 12, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

4 participants