epicweb-dev / full-stack-foundations

Learn the foundational skills of building full stack web applications.
https://epicweb.dev/workshops/full-stack-foundations
Other
587 stars 152 forks source link

Relevant files button does not open files in vscode #8

Closed nac62116 closed 1 year ago

nac62116 commented 1 year ago

It's me again.

I tried out the workshop app and it's very cool!

But when i try to open the relevant files for the first exercise it does not open in vscode. (Btw. im on a mac

Without the .env: Relevant file opens in vim inside my zsh terminal, which is not optimal ;)

I tried adding a .env with following value (code is added as $PATH): KCDSHOP_EDITOR="/usr/local/bin/code"

Then i get an EOENT error when i click on relevant files button.

grafik

kentcdodds commented 1 year ago

Could you try KCDSHOP_EDITOR=code?

But when i try to open the relevant files for the first exercise it does not open in vscode. (Btw. im on a mac

Does it open in something else? It should open in the editor you have open.

If you run /usr/local/bin/code in the terminal (without the workshop app), does VSCode open?

nac62116 commented 1 year ago

Thanks for your quick response!

  1. When i dont specify the KCDSHOP_EDITOR variable in the .env i get following behaviour:
  1. When i type /usr/local/bin/code into my terminal it does not start VSCode, so i tried KCDSHOP_EDITOR=code in the .env as you suggested.

Maybe i just move arround the files via VSCode search bar inside the playground, as you mentioned in your video. What would you suggest?

kentcdodds commented 1 year ago

Hi @nac62116,

I'm sorry you're having trouble with this! I'm not certain what could be causing your issues.

When i type /usr/local/bin/code

This tells me that your vscode command is either not located there or that's not available in your PATH which would be the reason that's not working for you. Try running which code and that should reveal the real path which you can use in the .env.

As a last resort, here's the part of the code where we guess your editor: https://github.com/epicweb-dev/kcdshop/blob/a8e0dbeebdb19cf609f539f4cb692225a3dde25b/packages/workshop-app/app/utils/launch-editor.server.ts#L203

Maybe you could find that file in node_modules and add some console logs to figure out why it's finding the wrong editor for you?

nac62116 commented 1 year ago

Hi @kentcdodds

Thanks for your support. I ran the which command and had to edit the output a bit to get it working.

Now it works and looks as follows:

KCDSHOP_EDITOR='open -n -b "com.microsoft.VSCode" --args $*"'

kentcdodds commented 1 year ago

I'm glad you worked it out! See you tomorrow :)