binh-vu / yapf-pycharm

Pycharm plugin for https://github.com/google/yapf
MIT License
10 stars 9 forks source link

Cannot yapf format file #2

Open nmiculinic opened 7 years ago

nmiculinic commented 7 years ago
90f8cf
java.lang.Throwable
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:132)
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:135)
    at com.intellij.idea.IdeaLogger.error(IdeaLogger.java:105)
    at ReformatCode.reformatFile(ReformatCode.java:50)
    at ReformatCode.actionPerformed(ReformatCode.java:93)
    at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:216)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:233)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.a(ActionMenuItem.java:310)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:911)
    at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:136)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:300)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem.a(ActionMenuItem.java:117)
    at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:86)
    at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:109)
    at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:118)
    at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
    at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:117)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.a(BegMenuItemUI.java:513)
    at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:45)
    at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:533)
    at java.awt.Component.processMouseEvent(Component.java:6541)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
    at java.awt.Component.processEvent(Component.java:6306)
    at java.awt.Container.processEvent(Container.java:2237)
    at java.awt.Component.dispatchEventImpl(Component.java:4897)
    at java.awt.Container.dispatchEventImpl(Container.java:2295)
    at java.awt.Component.dispatchEvent(Component.java:4719)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
    at java.awt.Container.dispatchEventImpl(Container.java:2281)
    at java.awt.Window.dispatchEventImpl(Window.java:2746)
    at java.awt.Component.dispatchEvent(Component.java:4719)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:764)
    at java.awt.EventQueue.access$500(EventQueue.java:98)
    at java.awt.EventQueue$3.run(EventQueue.java:715)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
    at java.awt.EventQueue$4.run(EventQueue.java:737)
    at java.awt.EventQueue$4.run(EventQueue.java:735)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:734)
    at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:821)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:645)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

It's my first attempt at formatting any file, and this big exception pops up

binh-vu commented 7 years ago

Hi,

This exception happens because of error when invoking the YAPF command.

You have to make sure that this command: /usr/local/bin/yapf <file path> succeeds without any error.

UPDATE: The reason that I have to fix yapf path is when Java executes a process, it uses default shell environment variables. Which mean if you install yapf to other location instead of the one defined in default $PATH variable, the plugin won't work.

There may be a way to fix it, but I haven't had enough time to do it.

jesterhazy commented 6 years ago

You could try invoking yapf as python -m yapf ..., and use whatever python is setup as the project interpreter. That way people who use conda or virtualenv could use this plugin.