Sublime Forum

Package Control on Red Hat Linux gives python unicode exception

#1

Hi,

I have installed the 64 bit version of Sublime Text 3 with the tar, since I am working on a machine running Red Hat Linux where I’m not the super user (and have no packet manager). When I try to run package control in sublime text, I get the following output in the console:

Exception in thread Thread-3:
Traceback (most recent call last):
  File "./python3.3/threading.py", line 901, in _bootstrap_inner
  File "/home/ekalras/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/automatic_upgrader.py", line 117, in run
self.upgrade_packages()
  File "/home/ekalras/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/automatic_upgrader.py", line 257, in upgrade_packages
ignore_packages=self.auto_upgrade_ignore
  File "/home/ekalras/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/package_installer.py", line 91, in make_package_list
if self.manager.is_vcs_package(package):
  File "/home/ekalras/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/package_manager.py", line 310, in is_vcs_package
return self._is_git_package(package) or self._is_hg_package(package)
  File "/home/ekalras/.config/sublime-text-3/Installed Packages/Package Control.sublime-package/package_control/package_manager.py", line 285, in _is_git_package
return os.path.exists(git_dir) and (os.path.isdir(git_dir) or os.path.isfile(git_dir))
  File "./python3.3/genericpath.py", line 18, in exists
UnicodeEncodeError: 'latin-1' codec can't encode character '\u2013' in position 52: ordinal not in range(256)

The machine I’m working on has Python 2.7.5 installed. Is this potentially an issue? Alternatively, is there a good resource available for reading up on installing packages manually in a linux environment?

/ Rasmus

0 Likes

Just can't seem to install a package
#2

Can you share the output of these commands from your shell?

ls ~/.config/sublime-text-3/{,Installed\ }Packages
locale

Also, what version/build of ST did you choose?

0 Likes

#3

This is the output from the commands:

ekalras@esekilxxen4177:~ > ls ~/.config/sublime-text-3/{,Installed\ }Packages
/home/ekalras/.config/sublime-text-3/Installed Packages:
0_package_control_loader.sublime-package  Package Control.sublime-package

/home/ekalras/.config/sublime-text-3/Packages:
Default  User

ekalras@esekilxxen4177:~ > locale
LANG=en_US
LC_CTYPE="en_US"
LC_NUMERIC="en_US"
LC_TIME=C
LC_COLLATE=C
LC_MONETARY="en_US"
LC_MESSAGES=C
LC_PAPER="en_US"
LC_NAME="en_US"
LC_ADDRESS="en_US"
LC_TELEPHONE="en_US"
LC_MEASUREMENT="en_US"
LC_IDENTIFICATION="en_US"
LC_ALL=

I’m using Sublime Text Build 3176

0 Likes

#4

So you are using a locale that is incapable of representing the filenames you are using.

From the error message:

UnicodeEncodeError: 'latin-1' codec can't encode character '\u2013' in position 52: ordinal not in range(256)

One of your folders (possibly a package folder) includes https://www.fileformat.info/info/unicode/char/2013/index.htm, which isn’t representable in ISO 8859-1 (aka latin-1), which is what is used by en_US.

Ideally modern Linux users should be running with a locale like en_US.UTF-8.

0 Likes

#5

I’ve seen this error before, and it has to do with your encoding and the fact that there is a package in package control whose name contains a non-ascii dash character. Even though the package in question doesn’t exist, Package Control uses it’s name to test for file existence, which causes encoding problems.

If you start Sublime from the terminal and temporarily swap the encoding to be utf-8, the problem will go away. A more permanent solution would require always launching Sublime with that encoding or changing the system encoding to be utf-8.

0 Likes

#6

I’m curious about that. This definitely sounds fixable on PC’s part. Would you mind creating an issue for this so it’s not forgotten?

0 Likes

#7

I exported LANG to en_US.utf8, and now it works! The package control displayed a list of available packages when running the “Install Package” command.

To reiterate for future readers, the problem was that my system was running an encoding that did not support a character in a file name that sublime text 3 was looking for. When switching to system-encoding utf-8, the character in the file name was readable by sublime text and everything worked fine thereon after.

Thank you all for the help :slight_smile:

0 Likes

#8

I’ve submitted issue #1410 to cover this, with some reproduction instructions and the name of the package that originally triggered this error.

At the time I attributed the problem to the fact that I was using a fairly old Linux installation so I just updated the system locale and left well enough alone. I believe that @kingkeith recently also encountered the same problem, although I’m not sure offhand what distro he was using (I use Slackware).

2 Likes