Skip to content

Build error occurred; commits with "" break build commands. - #269

Merged
vaxerski merged 5 commits into
hyprwm:mainfrom
Blake-sama:main
Jul 27, 2025
Merged

Build error occurred; commits with "" break build commands.#269
vaxerski merged 5 commits into
hyprwm:mainfrom
Blake-sama:main

Conversation

@Blake-sama

@Blake-sama Blake-sama commented Jul 27, 2025

Copy link
Copy Markdown
Contributor

Using these build commands found on the main page of the repo:
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build
cmake --build ./build --config Release --target hyprpaper -jnproc 2>/dev/null || getconf _NPROCESSORS_CONF

I caused this error when building:
/home/blake-sama/Developer/hyprpaper/src/main.cpp: In function ‘int main(int, char**, char**)’:
: error: unable to find string literal operator ‘operator""source’ with ‘const char [19]’, ‘long unsigned int’ arguments
/home/blake-sama/Developer/hyprpaper/src/main.cpp:6:90: note: in expansion of macro ‘GIT_COMMIT_MESSAGE’
6 | Debug::log(LOG, "Welcome to hyprpaper!\nbuilt from commit {} ({})", GIT_COMMIT_HASH, GIT_COMMIT_MESSAGE);
| ^~~~~~~~~~~~~~~~~~
make[3]: *** [CMakeFiles/hyprpaper.dir/build.make:205: CMakeFiles/hyprpaper.dir/src/main.cpp.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/Makefile2:87: CMakeFiles/hyprpaper.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:94: CMakeFiles/hyprpaper.dir/rule] Error 2
make: *** [Makefile:189: hyprpaper] Error 2

After ChatGPT'ing the error, when the build tried to compile, it detected a bad commit message. Well, that's because the most recent commit to the project was mine which had "source=" in the commit message. It failed to read the "" marks in my commit message correctly, breaking the compiler's ability to build hyprpaper.

I'm also not very great at explaining so here's ChatGPT expressing what this fix does:
"The fix I added ensures that any " characters in the commit message are escaped ("), so that when the macro is expanded into C++, it stays within the bounds of a valid string literal. This prevents the preprocessor from misinterpreting the contents of commit messages."

tl;dr I'm sorry I broke the build with a bad commit message, lesson learned . . . don't use "" marks in commits.

As for why the prior pull request failed, in typical fashion of how tf do I create a pull request, I copied a line incorrectly:
string(REPLACE """ "3 \ marks here when there should have been 5" GIT_COMMIT_MESSAGE_ESCAPED "${GIT_COMMIT_MESSAGE}")

Basically I missed two \ marks in the prior pull request, which error'd out. I have updated my fork, commit & push, ran the build commands:
[100%] Built target hyprpaper
Success!

… on the main GitHub page because my commit contained "" marks. These two adjustments to CMakeLists.txt resolve this by escaping "" marks in commit messages.
@Blake-sama

Copy link
Copy Markdown
Contributor Author

Deleted my fork locally, recloned, ran build again to confirm I'm not an idiot, it did build successfully. Very minor change, just telling it to ignore "" marks in commit messages when building, but I'm a mess with Git so apologies for the quick confusion there!

@Blake-sama

Copy link
Copy Markdown
Contributor Author

Escaped with \" | """ → " | ❌ sometimes | Works only if the message doesn’t break syntax
Escaped with \\" | """ → \" → " | ✅ always | Survives CMake → shell → compiler safely

Circling back, my original pull request . . . it did build (hence why I made a pull request) but when I tried it a second time, everything broke.
Then I added two more \ marks, and now it's building every time.

Asking ChatGPT to investigate why it worked ONCE, this is what it returned.

tl;dr I was sort've right in my original pull request, but when I built a second time the newest commit message didn't have "" marks and it broke again.

this latest pull request should mean you can build with any commit message, "" marks or not, and it should succeed.

@vaxerski vaxerski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just replace it with a space

@Blake-sama

Blake-sama commented Jul 27, 2025

Copy link
Copy Markdown
Contributor Author

Doing some testing with the code I've pushed. This is a very specific edge-case that I'm dealing with.
In short, here's what I learned:

Prior to this code, if you commit the following:
❯ git commit -m "testing again this "time" to see if it breaks/works"
The code would break, as seen by my "source=" commit.

This pull request fixes this.
However, it's not perfect.
If we PROPERLY escape the marks:

❯ git commit -m "testing again [backslash]" with [backslash]" marks"
This will break. It will fail as it doesn't recognize \ correctly.

Of course, what matters most is:
❯ git commit -m "this has always worked and still works"
Works like it should.

In short, I created a problem when I committed with "" marks in my commit message.
I am unaware if [backslash]" would have worked or broke prior to this pull request.
I can confirm if you commit a message with [backslash]" in it, it will fail, even with this pull request.

That being said, as long as we just commit with plain text, it will always build.
Side note, I'm really bothered that github hides the backslash character from these messages, it's making this hard to communicate.

@Blake-sama

Copy link
Copy Markdown
Contributor Author

tl;dr if you just change the most recent commit msg to not include quotes, the issue self-resolves without needing to adjust any code.

then you just don't accept commits that contain " marks >.>
I'll let you decide what is more appropriate for the repo.

@Blake-sama

Copy link
Copy Markdown
Contributor Author

Currently adjusting, I've changed it to just replace with a space. I'm going to run a few tests with different commit messages like I did above.

@Blake-sama

Blake-sama commented Jul 27, 2025

Copy link
Copy Markdown
Contributor Author

Accidentally pushed two additional commits, was just me adding a test.txt & then removing it. Anyway, I replaced it to be a space like you mentioned, now all three scenarios I tested:
Using a standard message; Using a quoted "message"; Using an escaped [backslash]"message[backslash]";
Successfully built.

❯ git commit -m "this has always worked and still works"
❯ git commit -m "Testing if using "quotes" will properly replace to just spaces"
❯ git commit -m "Does [backslash]" proper escaping work?"

Unlike before, all of these commit messages still allowed CMake to build, no errors occurring. My only gripe is I ended on that last commit (yes it still works!) but I should've ended on a commit that had ZERO QUOTES just to avoid complications.

tl;dr I believe replacing with a space has made it so no matter how someone commits, whether they use " or [backslash]" in their message, it should build. :) Thank you for your patience.

@vaxerski vaxerski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@vaxerski
vaxerski merged commit 86f6217 into hyprwm:main Jul 27, 2025
1 check passed
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 this pull request may close these issues.

2 participants