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

Don't panic when headless #57

Open
daonb opened this issue Apr 7, 2024 · 3 comments · May be fixed by #68
Open

Don't panic when headless #57

daonb opened this issue Apr 7, 2024 · 3 comments · May be fixed by #68

Comments

@daonb
Copy link

daonb commented Apr 7, 2024

I've just added you're excellent package to my project and it works great on my arm mac.
When I try to run my docker compose based tests it fails to compile:

clipboard_linux.c:15:10: fatal error: X11/Xlib.h: No such file or directory
   15 | #include <X11/Xlib.h>
        |          ^~~~~~~~~~~~
 compilation terminated.

Makes sense - containers don't have X. I've tried disabling CGO and got in run time:

 panic: clipboard: cannot use when CGO_ENABLED=0

It's clear the package can't do anything on a system with no clipboard, but IMHO it should be able to compile and return an error on all calls, leaving it to the calling program to handle. Like in my program's, where I want to use an environment variable as the clipboard storage so I can run and validate clipboard related tests.

@changkun
Copy link
Member

changkun commented Apr 8, 2024

Reasonable. PR welcome :)

@Ikke
Copy link

Ikke commented Nov 4, 2024

You need to make sure the relevant development headers are installed, which does not require X11 to be running. How to do that depends on the specific distribution you are using.

@marevers
Copy link

Second this. I am trying to use this package in a CLI I have created, but the CLI is designed to work on multiple platforms. Some of those platforms will not be able to use this package, but the CLI should still compile/run when it's being ran there. I am planning to use the clipboard.Init() check to verify and warn the user if they are trying to use clipboard functionality when they cannot.

But for that, as OP stated, whether to terminate on such an error must be left to the application, not to the module.

@marevers marevers linked a pull request Nov 21, 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