eric ide

Message1612

Author: Qb
Recipients: Qb
Date: 2022-04-25.18:27:24
Content
After upgrading from eric6 to eric7, I cannot start eric7 from its macOS app bundle /Applications/eric7.app. It stalled with a message box saying "The background client for Python3 disconnected because of an unknown reason. Should it be restarted?" caused by:

<class 'enchant.errors.Error'>: 
No tag specified and default language could not be determined.
--------------------------------------------------------------------------------
  File "/Applications/eric7/lib/python3.9/site-packages/eric7/eric7.py", line 429, in <module>
    main()
  File "/Applications/eric7/lib/python3.9/site-packages/eric7/eric7.py", line 408, in main
    mainWindow = UserInterface(app, loc, splash, pluginFile, disabledPlugins,
  File "/Applications/eric7/lib/python3.9/site-packages/eric7/UI/UserInterface.py", line 308, in __init__
    self.__createObjects()
  File "/Applications/eric7/lib/python3.9/site-packages/eric7/UI/UserInterface.py", line 973, in __createObjects
    self.__vcsStatusWidget = StatusWidget(
  File "/Applications/eric7/lib/python3.9/site-packages/eric7/VCS/StatusWidget.py", line 123, in __init__
    self.__quickCommitEdit = EricSpellCheckedTextEdit(self)
  File "/Applications/eric7/lib/python3.9/site-packages/eric7/EricWidgets/EricSpellCheckedTextEdit.py", line 654, in __init__
    SpellCheckMixin.__init__(self)
  File "/Applications/eric7/lib/python3.9/site-packages/eric7/EricWidgets/EricSpellCheckedTextEdit.py", line 52, in __init__
    spellDict = enchant.DictWithPWL(
  File "/Applications/eric7/lib/python3.9/site-packages/enchant/__init__.py", line 782, in __init__
    super().__init__(tag, broker)
  File "/Applications/eric7/lib/python3.9/site-packages/enchant/__init__.py", line 536, in __init__
    raise Error(err)

--------------------------------------------------------------------------------
Version Numbers:
  Python 3.9.12, 64-Bit
  Qt 6.3.0
  PyQt6 6.3.0
  PyQt6-Charts 6.3.0
  PyQt6-WebEngine 6.3.0
  PyQt6-QScintilla 2.13.2
  sip 6.6.1
  WebEngine 94.0.4606.126
  eric7 22.4 (rev. 429cc091bf0e)

Platform: darwin
3.9.12 (main, Mar 25 2022, 11:13:23) 
[Clang 11.0.0 (clang-1100.0.33.16)]


The default language cannot be detected since LC_* environ variables are not passed when an application is started from its app bundle (for example, double clicking on its icon). However, environment variables can be set in the plist file inside the bundle.

The following lines can be added to the file /Applications/eric7.app/Contents/Info.plist to solve the issue:


    <key>LSEnvironment</key>
    <dict>
        <key>LANG</key>
        <string>en_GB.UTF-8</string>
        <key>LC_ALL</key>
        <string>en_GB.UTF-8</string>
        <key>LC_CTYPE</key>
        <string>en_GB.UTF-8</string>
    </dict>


After running `plutil /Applications/eric7.app/Contents/Info.plist` to check that there are no errors, the Launch Service Database must be updated with the following command:

`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f /Applications/eric7.app`

After that patch, eric7 can be started from the app bundle without any inconvenience.

I have attached the modified plist file for your consideration.

Of course, this solution implies that the system language is really not available for the application (it is replaced by a default fixed language stored in the plist possibly different from user's preferred language). So it is probably not the best solution for this issue but it does its work for me.


Additionally, I have noticed that the enchant.Error exception raised when no default language can be found is not caught in EricWidgets/EricSpellCheckedTextEdit.py as (I suppose) intended. The block starting in line 58 is not executed since it catches enchant.DictNotFoundError but not enchant.Error. Hence using "English dictionary if no locale dictionary is available or the default one could not be found" or "forget about spell checking" if "still no dictionary could be found" are not really executed.


Thanks a lot. I have just tested eric7 for the first time and I very happy with it. Nice work!!
History
Date User Action Args
2022-04-25 18:27:25Qbsetrecipients: + Qb
2022-04-25 18:27:25Qbsetmessageid: <1650911245.0.0.976476360102.issue425@eric-ide.python-projects.org>
2022-04-25 18:27:24Qblinkissue425 messages
2022-04-25 18:27:24Qbcreate