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

Missing X server or $DISPLAY #30

Closed
callwyat opened this issue Apr 14, 2024 · 11 comments · Fixed by #34
Closed

Missing X server or $DISPLAY #30

callwyat opened this issue Apr 14, 2024 · 11 comments · Fixed by #34
Assignees
Labels
feature-request Request for new features or functionality
Milestone

Comments

@callwyat
Copy link

When connected to a Linux machine using the "Remote - SSH", I get the following error when I try to run tests:

[210482:0413/230624.493004:ERROR:ozone_platform_x11.cc(240)] Missing X server or $DISPLAY
[210482:0413/230624.493055:ERROR:env.cc(257)] The platform failed to initialize.  Exiting.
Exit code:   1
Failed
Error: Test process exited with code 

I have seen this error before when setting up a CI pipeline for the tests on linux machines. It seams to be caused by trying to open VSCode with no GUI, but I don't know, I just add xvfb-run -a onto the front of npm run test as recommended here: https://code.visualstudio.com/api/working-with-extensions/continuous-integration#github-actions

Debugging the tests works, I'm guessing because the UI is opened on my local machine.

Thanks for this great extension!

@connor4312
Copy link
Member

Please share the pipeline file you're using. Thanks!

@connor4312 connor4312 added the info-needed Issue requires more information from poster label Apr 14, 2024
@callwyat
Copy link
Author

My apologies for missing that!

To recreate this issue:

  1. Connect to a Linux machine using the "Remote - SSH" extension. (I suspect the same error will occur if using the "Dev Containers" extension too)
  2. Open a folder that uses the "Extension Test Runner" extension
  3. Select the "Testing Tab" and click the "Run Tests" button
  4. All test will fail with a "Test process exited unexpectedly" and the "Test Results" will show the "Missing X server" error message
  5. Now click the "Debug Tests" button, and the tests should run successfully.

I am specifically trying to test out this extension: https://github.com/callwyat/mplab-extension ,but it requires MPLABX be installed in order to pass most tests.

@eliericha
Copy link
Contributor

I also have questions about this, and generally about how to provide environment variables to the test runner, in particular in remote development. I think this also relates to #17 .

AFAIU there are the following ways of passing environment variables to the extension test runner:

  1. The shell initialization script if working in remote mode.
  2. The .vscode-test.mjs file.
  3. The extension-test-runner.debugOptions setting when debugging.

For (1) the remote mode documentation explains that shell init scripts such as bash_profile can be used to provide the environment of the vscode server. However how does that work when the remote machine is Windows? Where can one provide environment variables for the vscode server?

(2) and (3) are nice, but they require hard-coding environment variables into the project workspace. Is there a way to avoid that?

The use case is that my tests require external tools to be available. Different developers might install such tools in different locations. So how can a developer set the PATH variable for example to make their tools available to the test runner without hard-coding local paths into the .vscode-test.mjs or the .vscode/settings.json file ?

@connor4312
Copy link
Member

connor4312 commented Jul 1, 2024

A few things:

All test will fail with a "Test process exited unexpectedly" and the "Test Results" will show the "Missing X server" error message

I've added a new config option extension-test-runner.wrapper that is a wrapper script the extension test run will be passed into. In your case you can set that to xvfb-run (probably in your remote settings) to fix the display issue.

So how can a developer set the PATH variable for example to make their tools available to the test runner without hard-coding local paths into the .vscode-test.mjs or the .vscode/settings.json file ?

You can do anything you want in your vscode-test.mjs script, a common thing might be using dotenv to load environment variables from a gitignored .env config file in the repo.

connor4312 added a commit that referenced this issue Jul 1, 2024
@connor4312 connor4312 added feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster labels Jul 1, 2024
@connor4312 connor4312 added this to the July 2024 milestone Jul 1, 2024
@eliericha
Copy link
Contributor

Thanks for the update @connor4312 . The wrapper option is indeed useful, however I see that it's defined as a string when in practice we may want to wrap with other arguments. For example xvfb-run fails if the display :99 is unavailable. Typically I use xvfb-run -a ... to automatically search for an available display number.

Also, how can I set up the workspace such that the wrapper would be used on Linux but not on Windows where xvfb-run doesn't exist?

And finally regarding .env, that's a great idea. In addition to loading it in .vscode-test.mjs using dotenv, can I make it affect my workspace terminals, tasks, debug configurations? I think .env is automatically picked up by Python debug launch configurations but I don't think that's picked up by other debug launch configurations or tasks or terminals.

@connor4312
Copy link
Member

The wrapper option is indeed useful, however I see that it's defined as a string when in practice we may want to wrap with other arguments

I can make it optionally an array instead

Also, how can I set up the workspace such that the wrapper would be used on Linux but not on Windows where xvfb-run doesn't exist?

You can set that in your Remote Settings in vscode, which are configurable per-remote.

In addition to loading it in .vscode-test.mjs using dotenv, can I make it affect my workspace terminals, tasks, debug configurations?

It depends on your setup. For JS debugging, envFile is an option you can use in your launch.json. For tasks you would want to set up your shell to read it since tasks are run in a terminal. direnv is useful here. Or you can just read it programmatically.

@callwyat
Copy link
Author

callwyat commented Jul 4, 2024

I’m I setting this up wrong? I pulled main, launched the extension and found the new “wrapper” setting, updated it with ‘xvfb-run’ in the remote settings and ran the tests, and xvfb-run didn’t show up in the output?

@connor4312
Copy link
Member

Note that you need to install the extension in your remote, not just locally.

I'll probably do an official release tomorrow.

@callwyat
Copy link
Author

callwyat commented Jul 5, 2024

Note that I cloned this repo in the remote and launched it in the remote. I forgot to mention that in my earlier post.

@eliericha
Copy link
Contributor

Thanks for the suggestions @connor4312 . I'll give everything a try once the release is out.

@callwyat
Copy link
Author

callwyat commented Jul 6, 2024

I tried it out today, and it worked!! Thank you 🙏

@connor4312 connor4312 self-assigned this Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants