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

Keypress interaction with vite doesn't work ("o"+"Enter" doesn't open web) #9402

Open
1 task done
shanike opened this issue Nov 7, 2024 · 4 comments
Open
1 task done
Labels
kind: bug Something isn't working

Comments

@shanike
Copy link

shanike commented Nov 7, 2024

Verify canary release

  • I verified that the issue exists in the latest Turborepo canary release.

Link to code that reproduces this issue

https://github.com/shanike/turborepo-bug-repro

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Linux

Which canary version will you have in your reproduction?

2.2.4-canary.8

Describe the Bug

Vite's dev server is interactive. It accepts commands to perform operations like open the browser ("o") and restart the server ("r").

I know Turborepo v1 passes terminal input along to a dev server that was started through turbo dev. But, in Turborepo 2.2.3 it doesn't, which results with the following case:

The part that works: The "gui" opens and runs as expected, and when pressing "Enter" on the persistent vite job, it focuses into it and allows typing.
The part afterwards which doesn't work: Pressing the letter "o" followed by an "Enter" -> nothing happens.

Expected Behavior

After pressing the letter "o" followed by an "Enter" in a vite job -> vite opens the localhost web on the correct job's port. This does not happen with v2 of turbo.

To Reproduce

  1. Install Turborepo
  2. On 1 app install vite
  3. Create a "dev" vite+turbo task
    Now,
  4. pnpm exec turbo dev on apps/apps-a
    will run vite with turbo and won't open the web when pressing o + Enter

(But
5. pnpm dev
will open the web when writing o + Enter)

Additional context

On turbo v1.13.4 with experimentalUI turned on -> it DOES work: it opens the web when "interacting" with the vite task and pressing o + Enter.

This issue re-opens issue #8952.

Addressing comment #8952 (comment):

Thank you for your answer!
Unfortunately, we still encounter this strange behavior. The answers to your questions:

  • The other commands r + Enter, u + Enter, c + Enter, q + Enter and h + Enter work correctly
  • All the commands above do work as expected in loose mode, open command works as well
  • Yes, open http://localhost:5173/ in the terminal opens the web browser
@shanike shanike added kind: bug Something isn't working needs: triage New issues get this label. Remove it after triage labels Nov 7, 2024
@chris-olszewski chris-olszewski removed the needs: triage New issues get this label. Remove it after triage label Nov 7, 2024
@chris-olszewski
Copy link
Member

Do you happen to know what open command your system is using? I believe xdg-open is the most common on Linux, but man open should show which one is getting used.

All the commands above do work as expected in loose mode, open command works as well

I think this indicates open on your system is requiring some environment variable to work correctly. Could you try adding BROWSER and BROWSER_ARGS as passThroughArgs for your dev task? If that's successful I will add them to the default pass through.

@shanike
Copy link
Author

shanike commented Nov 11, 2024

Thanks for checking it out.

Do you happen to know what open command your system is using?

Seems it's xdg-open indeed
image

Could you try adding BROWSER and BROWSER_ARGS as passThroughArgs for your dev task?

Sadly it seems to still not open the browser. (Other letters still do work, like h+enter).
image

@chris-olszewski
Copy link
Member

I'm having trouble finding any documentation about other environment variables that are needed by xdg-open to function.

Could you try env -i bash --noprofile --norc and then in the new Bash shell run open http://localhost:5173 and see if that gives us any hints to what could be happening? (env -i bash --noprofile --norc should start a bash shell with the minimal env vars required for operation and nothing more) If that succeeds would you mind providing the result of env in that Bash shell?

@ChemdaImber
Copy link

Hi, thank you for all the help!
Going through all the env variables used in xdg-open script I found out that when one of the variables DISPLAY or WAYLAND_DISPLAY is passed through, the open script works as expected.
I added this line to the dev task solve the problem:

 "passThroughEnv": ["DISPLAY", "WAYLAND_DISPLAY"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants