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

Format command doesn't work on MacOS in v0.4.6 #63

Closed
daron81 opened this issue Feb 24, 2023 · 9 comments
Closed

Format command doesn't work on MacOS in v0.4.6 #63

daron81 opened this issue Feb 24, 2023 · 9 comments
Assignees
Labels

Comments

@daron81
Copy link

daron81 commented Feb 24, 2023

Despite the configured formatter (prettier, in this case) being in the users PATH in the ecode terminal, the format command doesn't work on MacOS (Intel, Ventura 13.0.1).

It is, however, working fine on Linux (Fedora 37).

@SpartanJ SpartanJ self-assigned this Feb 24, 2023
@SpartanJ SpartanJ added the bug Something isn't working label Feb 24, 2023
@SpartanJ
Copy link
Owner

Hi!
I'm 90% sure this is a PATH issue because I tried it and had the same problem.
Please do the following:
Open ecode as you usually open it (in my case was with Spotlight) and go to Tools -> Check Languages Health. You'll have a clear picture of the status of your tools.
But to be more precise, you can easily check the PATH environment that it's visible for ecode:
Open a new terminal and just echo $PATH, and you can also run which prettier, if nothing is found we are talking of the same issue.
But, now, just to be sure:
Open a terminal, and open ecode from the terminal (make sure that the terminal has access to prettier). To open ecode run open /Applications/ecode.app --args -ldebug (the args part is to set the logs to debug which gives you more information). Then repeat the steps from the first try. It should be there and working.
I have no idea how the PATH is set in macOS (I'm not a macOS user), I'll take a look to see if I can do something to solve it from the application.

@SpartanJ
Copy link
Owner

I'm thinking that it might be a good idea to add a configuration to allow to expand the current PATH detected by ecode. BTW this worked for me.
It's really annoying because it's not ecode's fault.

@daron81
Copy link
Author

daron81 commented Feb 24, 2023

Hi,

Thanks for the quick reply. However, we might be talking about different issues, bc prettier IS in the path in ecode's terminal, and also shows up green in the health check.

But the format doc command still does nothing on macos.

@SpartanJ
Copy link
Owner

Then, I guess prettier must be complaining about something but the formatter does not print the errors, it just won't do anything. Can you please try to run prettier from the terminal in ecode to format your file manually and see the output?
I mean:
Copy the file path (right click over the editor, "Copy File Path")
open a new terminal
run
prettier {paste your file path}

Thanks

@daron81
Copy link
Author

daron81 commented Feb 24, 2023

Just tried that, and it formats the file correctly. Meaning that the file does not have any syntax errors that would prevent prettier from working.

It is strange, since it works on my Linux machine, and the format command seems correct.

@SpartanJ
Copy link
Owner

Did you tried using the shortcut or right click -> format doc or with the command palette? I'm trying to understand what could be happening. It works perfectly fine for me, even using prettier. You could also please run the application with the -ldebug argument, try to format, and send me the logs that are located at:
~/Library/Application Support/ecode/ecode.log

Thanks

@daron81
Copy link
Author

daron81 commented Feb 24, 2023

Ok, after reading through your previous comments, it seems like you were right. I had initially moved from defining the PATH from .zprofile to .zshrc to try to get this to work. Here is what I've found so far:

  • With my path env set in .zprofile or .profile, the health check fails and ecode does not pick up the path as you mentoned
  • With my path set in .zshrc, ecode does pick up the path for its built in terminal, and the health check passes, but the formatting does not work.
  • With launching ecode from the terminal with open /Applications/ecode.app --args -ldebug, everything works as expected.

I will try that work-around you linked to earlier.

@daron81
Copy link
Author

daron81 commented Feb 24, 2023

I was able to get around this by running sudo launchctl config user path $PATH, then rebooting.

It will do for now, but I believe this takes effect for all users.

@SpartanJ
Copy link
Owner

Thanks for taking the time to investigate the issue. It's really annoying certainly, but I'm not sure how to provide a better user experience. I'm still thinking... The biggest problem for the application is that it cannot know if PATH is "wrong", maybe I could search if there's a PATH definition over the shell configuration files (zsh being the most important), but it feels a little hackish. For example, in my system configuration that wouldn't have worked. I'll investigate a little further.

@SpartanJ SpartanJ added the macOS label Feb 25, 2023
SpartanJ added a commit to SpartanJ/eepp that referenced this issue Sep 24, 2023
…ATHs to the current environment. This should improve binary finding. Solves issue SpartanJ/ecode#63.

Renamed MACOSX references to MACOS / macOS.
@SpartanJ SpartanJ closed this as completed Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants