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

TypeError: coercing to Unicode: need string or buffer, NoneType found #690

Closed
dpashkevich opened this Issue Apr 24, 2017 · 19 comments

Comments

Projects
None yet
3 participants
@dpashkevich

dpashkevich commented Apr 24, 2017

I just installed git-cola from source in Ubuntu 16.04, and I'm getting this error upon launching:

Traceback (most recent call last):

  File "/usr/share/git-cola/lib/cola/cmds.py", line 1915, in do_cmd
    return cmd.do()

  File "/usr/share/git-cola/lib/cola/cmds.py", line 1314, in do
    self.model.update_status(update_index=True)

  File "/usr/share/git-cola/lib/cola/models/main.py", line 194, in update_status
    self._update_merge_rebase_status()

  File "/usr/share/git-cola/lib/cola/models/main.py", line 246, in _update_merge_rebase_status
    self.is_merging = core.exists(self.git.git_path('MERGE_HEAD'))

  File "/usr/share/git-cola/lib/cola/core.py", line 294, in wrapped
    return decorator(fn(action(*args, **kwargs)))

  File "/usr/lib/python2.7/genericpath.py", line 26, in exists
    os.stat(path)

TypeError: coercing to Unicode: need string or buffer, NoneType found

I can't get past the error dialog, as soon as I click Close, a new one pops up.
image

@davvid

This comment has been minimized.

Show comment
Hide comment
@davvid

davvid Apr 25, 2017

Member

would you mind cloning the repo and trying the version in master? The screenshot shows v2.10.

These steps will clone git-cola into ~/src/git-cola and run it in-place:

mkdir ~/src
git clone git://github.com/git-cola/git-cola.git ~/src/git-cola
~/src/git-cola/bin/git-cola

I tried reproducing this by creating repos in non-ascii paths and couldn't reproduce it.

I also tried checking out an older version and I am unable to reproduce it there. Hmm.. can you share some details about your current directory, or how you're launching it?

What python version are you using? If you peek at the #! line in /usr/bin/git-cola it should have the python path embedded in it. Are you in a non-ascii path? We do support utf8 paths, but non-utf8 might break something.

Are you inside a directory when launching? Did you click anything, or does that error display right away? The dialog you're seeing is what you get with either the --prompt option or if cola does not find a repo in your current directory.

Let me know if there's any clues in there. I'd like to get a good long-term solve for Ubuntu 16.

Member

davvid commented Apr 25, 2017

would you mind cloning the repo and trying the version in master? The screenshot shows v2.10.

These steps will clone git-cola into ~/src/git-cola and run it in-place:

mkdir ~/src
git clone git://github.com/git-cola/git-cola.git ~/src/git-cola
~/src/git-cola/bin/git-cola

I tried reproducing this by creating repos in non-ascii paths and couldn't reproduce it.

I also tried checking out an older version and I am unable to reproduce it there. Hmm.. can you share some details about your current directory, or how you're launching it?

What python version are you using? If you peek at the #! line in /usr/bin/git-cola it should have the python path embedded in it. Are you in a non-ascii path? We do support utf8 paths, but non-utf8 might break something.

Are you inside a directory when launching? Did you click anything, or does that error display right away? The dialog you're seeing is what you get with either the --prompt option or if cola does not find a repo in your current directory.

Let me know if there's any clues in there. I'd like to get a good long-term solve for Ubuntu 16.

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 25, 2017

I just set up a brand new computer with Ubuntu 16.04 and installed git cola from the latest source linked on the website. I had an older version installed on another computer (running Ubuntu 14.04) and the problem wasn't happening. The error displays immediately upon launching the app.

I shouldn't have any non-ascii characters in my path. I tried running it from the command line with the same result:

$ pwd
/home/dmitry
dmitry@dmitry:~$ git-cola

Here's the head of git-cola executable:

$ head /usr/bin/git-cola
#!/usr/bin/python
# -*- python-mode -*-
"""git-cola: The highly caffeinated Git GUI
"""

Here's my version of python:

$ /usr/bin/python --version
Python 2.7.12

I'll try the latest version from master

dpashkevich commented Apr 25, 2017

I just set up a brand new computer with Ubuntu 16.04 and installed git cola from the latest source linked on the website. I had an older version installed on another computer (running Ubuntu 14.04) and the problem wasn't happening. The error displays immediately upon launching the app.

I shouldn't have any non-ascii characters in my path. I tried running it from the command line with the same result:

$ pwd
/home/dmitry
dmitry@dmitry:~$ git-cola

Here's the head of git-cola executable:

$ head /usr/bin/git-cola
#!/usr/bin/python
# -*- python-mode -*-
"""git-cola: The highly caffeinated Git GUI
"""

Here's my version of python:

$ /usr/bin/python --version
Python 2.7.12

I'll try the latest version from master

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 25, 2017

Here's the original contents of /usr/share/applications/git-cola.desktop:

 1 [Desktop Entry]
  2 Name=Git Cola
  3 Comment=The highly caffeinated Git GUI
  4 Comment[zh_TW]=高咖啡因含量的 Git 圖形介面
  5 TryExec=git-cola
  6 Exec=git-cola --prompt
  7 Icon=git-cola
  8 StartupNotify=true
  9 Terminal=false
 10 Type=Application
 11 Categories=Development;RevisionControl;
 12 X-KDE-SubstituteUID=false

I tried removing the line with the Chinese description and also fixed the Icon path (it wasn't displaying properly:

 1 [Desktop Entry]
  2 Name=Git Cola
  3 Comment=The highly caffeinated Git GUI
  4 TryExec=git-cola
  5 Exec=git-cola --prompt
  6 Icon=/usr/share/icons/hicolor/scalable/apps/git-cola.svg
  7 StartupNotify=true
  8 Terminal=false
  9 Type=Application
 10 Categories=Development;RevisionControl;
 11 X-KDE-SubstituteUID=false

The same error is still happening in the startup.

dpashkevich commented Apr 25, 2017

Here's the original contents of /usr/share/applications/git-cola.desktop:

 1 [Desktop Entry]
  2 Name=Git Cola
  3 Comment=The highly caffeinated Git GUI
  4 Comment[zh_TW]=高咖啡因含量的 Git 圖形介面
  5 TryExec=git-cola
  6 Exec=git-cola --prompt
  7 Icon=git-cola
  8 StartupNotify=true
  9 Terminal=false
 10 Type=Application
 11 Categories=Development;RevisionControl;
 12 X-KDE-SubstituteUID=false

I tried removing the line with the Chinese description and also fixed the Icon path (it wasn't displaying properly:

 1 [Desktop Entry]
  2 Name=Git Cola
  3 Comment=The highly caffeinated Git GUI
  4 TryExec=git-cola
  5 Exec=git-cola --prompt
  6 Icon=/usr/share/icons/hicolor/scalable/apps/git-cola.svg
  7 StartupNotify=true
  8 Terminal=false
  9 Type=Application
 10 Categories=Development;RevisionControl;
 11 X-KDE-SubstituteUID=false

The same error is still happening in the startup.

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 25, 2017

It looks like the error is only happening when git-cola is trying to display the repo selection prompt. If I run git-cola while inside a git repo, it runs just fine.

dpashkevich commented Apr 25, 2017

It looks like the error is only happening when git-cola is trying to display the repo selection prompt. If I run git-cola while inside a git repo, it runs just fine.

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 25, 2017

I built git cola off of master, the error is still happening

dpashkevich commented Apr 25, 2017

I built git cola off of master, the error is still happening

@Vdragon

This comment has been minimized.

Show comment
Hide comment
@Vdragon

Vdragon Apr 25, 2017

Contributor

I tried removing the line with the Chinese description and also fixed the Icon path (it wasn't displaying properly:

I added these both lines, they're both according to XDG spec. and shouldn't causing this issue
Also I'm using Unity and Ubuntu 16.04 as well without noticing the icon issue.

What is your locale settings? Try pasting your locale output from the terminal.

UPDATE: Somehow there's a mismatch in my memory as the Icon key isn't fixed by me

Contributor

Vdragon commented Apr 25, 2017

I tried removing the line with the Chinese description and also fixed the Icon path (it wasn't displaying properly:

I added these both lines, they're both according to XDG spec. and shouldn't causing this issue
Also I'm using Unity and Ubuntu 16.04 as well without noticing the icon issue.

What is your locale settings? Try pasting your locale output from the terminal.

UPDATE: Somehow there's a mismatch in my memory as the Icon key isn't fixed by me

@Vdragon Vdragon added the bug label Apr 25, 2017

@davvid

This comment has been minimized.

Show comment
Hide comment
@davvid

davvid Apr 29, 2017

Member

I don't think the Comment[zh_TW] field is involved here.

I think the Exec= and TryExec= lines should contain an absolute full path to /home/dmitry/src/git-cola/bin/git-cola

Please try that out.

...

If you're using a Menu or launcher icon via unity to launch git-cola it'll run the one in /usr/bin unless you explicitly edit it to run the bin/git-cola script from the cloned repo.

Even if you have your $PATH modified by .profile or .bashrc etc. to have a different directory before /usr/bin, it still won't work. The path has to be modified via .xsession (or maybe some other global method for unity). It's better to not do that and instead change the launcher to use an absolute path so that there's no ambiguity.

Let me know if that helps.

Member

davvid commented Apr 29, 2017

I don't think the Comment[zh_TW] field is involved here.

I think the Exec= and TryExec= lines should contain an absolute full path to /home/dmitry/src/git-cola/bin/git-cola

Please try that out.

...

If you're using a Menu or launcher icon via unity to launch git-cola it'll run the one in /usr/bin unless you explicitly edit it to run the bin/git-cola script from the cloned repo.

Even if you have your $PATH modified by .profile or .bashrc etc. to have a different directory before /usr/bin, it still won't work. The path has to be modified via .xsession (or maybe some other global method for unity). It's better to not do that and instead change the launcher to use an absolute path so that there's no ambiguity.

Let me know if that helps.

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 29, 2017

I installed the master version to /usr/bin via

sudo make prefix=/usr install

You can see 2.11 on the screenshot (launched from Unity launcher):
image

Thanks for investigating this by the way!

dpashkevich commented Apr 29, 2017

I installed the master version to /usr/bin via

sudo make prefix=/usr install

You can see 2.11 on the screenshot (launched from Unity launcher):
image

Thanks for investigating this by the way!

@davvid

This comment has been minimized.

Show comment
Hide comment
@davvid

davvid Apr 29, 2017

Member

I have a candidate solution I'll be pushing shortly. Please install the latest version once you see this issue close and let me know how it goes.

Member

davvid commented Apr 29, 2017

I have a candidate solution I'll be pushing shortly. Please install the latest version once you see this issue close and let me know how it goes.

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 29, 2017

dpashkevich commented Apr 29, 2017

@davvid davvid closed this in 26137f1 Apr 29, 2017

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 29, 2017

That didn't help unfortunately :(

$ git log --oneline
13eaa23e Merge branch 'git-path-none'
26137f1e models: avoid passing None to core.exists()

To make sure I was using the latest version, I ran the executable locally from the working directory. It works when I'm in the git repo, but when I did mv .git .git1, it throws that error again.

dpashkevich commented Apr 29, 2017

That didn't help unfortunately :(

$ git log --oneline
13eaa23e Merge branch 'git-path-none'
26137f1e models: avoid passing None to core.exists()

To make sure I was using the latest version, I ran the executable locally from the working directory. It works when I'm in the git repo, but when I did mv .git .git1, it throws that error again.

@davvid

This comment has been minimized.

Show comment
Hide comment
@davvid

davvid Apr 29, 2017

Member

Would you mind pasting the full backtrace from the latest install? It should have changed line numbers slightly, possibly helping to narrow down on where the None is slipping in.

Member

davvid commented Apr 29, 2017

Would you mind pasting the full backtrace from the latest install? It should have changed line numbers slightly, possibly helping to narrow down on where the None is slipping in.

@davvid davvid reopened this Apr 29, 2017

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 29, 2017

Sure!

Traceback (most recent call last):

  File "/home/dmitry/projects/git-cola/cola/cmds.py", line 1915, in do_cmd
    return cmd.do()

  File "/home/dmitry/projects/git-cola/cola/cmds.py", line 1314, in do
    self.model.update_status(update_index=True)

  File "/home/dmitry/projects/git-cola/cola/models/main.py", line 197, in update_status
    self._update_files(update_index=update_index)

  File "/home/dmitry/projects/git-cola/cola/models/main.py", line 209, in _update_files
    paths=self.filter_paths)

  File "/home/dmitry/projects/git-cola/cola/gitcmds.py", line 517, in worktree_state
    upstream_changed = diff_upstream(head)

  File "/home/dmitry/projects/git-cola/cola/gitcmds.py", line 593, in diff_upstream
    tracked = tracked_branch()

  File "/home/dmitry/projects/git-cola/cola/gitcmds.py", line 233, in tracked_branch
    branch = current_branch()

  File "/home/dmitry/projects/git-cola/cola/gitcmds.py", line 126, in current_branch
    key = core.stat(head).st_mtime

  File "/home/dmitry/projects/git-cola/cola/core.py", line 294, in wrapped
    return decorator(fn(action(*args, **kwargs)))

TypeError: coercing to Unicode: need string or buffer, NoneType found

dpashkevich commented Apr 29, 2017

Sure!

Traceback (most recent call last):

  File "/home/dmitry/projects/git-cola/cola/cmds.py", line 1915, in do_cmd
    return cmd.do()

  File "/home/dmitry/projects/git-cola/cola/cmds.py", line 1314, in do
    self.model.update_status(update_index=True)

  File "/home/dmitry/projects/git-cola/cola/models/main.py", line 197, in update_status
    self._update_files(update_index=update_index)

  File "/home/dmitry/projects/git-cola/cola/models/main.py", line 209, in _update_files
    paths=self.filter_paths)

  File "/home/dmitry/projects/git-cola/cola/gitcmds.py", line 517, in worktree_state
    upstream_changed = diff_upstream(head)

  File "/home/dmitry/projects/git-cola/cola/gitcmds.py", line 593, in diff_upstream
    tracked = tracked_branch()

  File "/home/dmitry/projects/git-cola/cola/gitcmds.py", line 233, in tracked_branch
    branch = current_branch()

  File "/home/dmitry/projects/git-cola/cola/gitcmds.py", line 126, in current_branch
    key = core.stat(head).st_mtime

  File "/home/dmitry/projects/git-cola/cola/core.py", line 294, in wrapped
    return decorator(fn(action(*args, **kwargs)))

TypeError: coercing to Unicode: need string or buffer, NoneType found
@davvid

This comment has been minimized.

Show comment
Hide comment
@davvid

davvid Apr 30, 2017

Member

Are you able to reproduce it without using the menu launcher, just using git-cola --prompt?

If so, can you run the same command with env GIT_COLA_TRACE=1 prepended to the command you ran to get the stacktrace above?

example: env GIT_COLA_TRACE=1 git-cola --prompt

It really should not be going down any of these code paths when displaying the startup dialog so I'm curious how it's getting that far.

For reference, when I run it I get this output when run from "/" (the lines without the $ prefix are printed on stdout):

$ env GIT_COLA_TRACE=1 git-cola --prompt
git -c diff.suppressBlankEmpty=false config -z --get-all cola.icontheme
git -c diff.suppressBlankEmpty=false config --null --file /home/david/.gitconfig --list

The stacktrace you shared shows that we made it past the earlier part, but now we're hitting other parts of the code that shouldn't run this early so I'm curious to see if there's something we're missing.

Is there maybe a directory, symlink, or file named .git in / or $HOME? I wonder if there's a particular filesystem or environment variable that's confusing things.

The stacktrace says that it's getting to the point where it's asking for the current branch, but if the startup dialog is being shown and it's not yet supposed to do that yet, so I'm hoping that the trace output can provide some more insight.

Let me know what you see when running in trace mode.

Member

davvid commented Apr 30, 2017

Are you able to reproduce it without using the menu launcher, just using git-cola --prompt?

If so, can you run the same command with env GIT_COLA_TRACE=1 prepended to the command you ran to get the stacktrace above?

example: env GIT_COLA_TRACE=1 git-cola --prompt

It really should not be going down any of these code paths when displaying the startup dialog so I'm curious how it's getting that far.

For reference, when I run it I get this output when run from "/" (the lines without the $ prefix are printed on stdout):

$ env GIT_COLA_TRACE=1 git-cola --prompt
git -c diff.suppressBlankEmpty=false config -z --get-all cola.icontheme
git -c diff.suppressBlankEmpty=false config --null --file /home/david/.gitconfig --list

The stacktrace you shared shows that we made it past the earlier part, but now we're hitting other parts of the code that shouldn't run this early so I'm curious to see if there's something we're missing.

Is there maybe a directory, symlink, or file named .git in / or $HOME? I wonder if there's a particular filesystem or environment variable that's confusing things.

The stacktrace says that it's getting to the point where it's asking for the current branch, but if the startup dialog is being shown and it's not yet supposed to do that yet, so I'm hoping that the trace output can provide some more insight.

Let me know what you see when running in trace mode.

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 30, 2017

Are you able to reproduce it without using the menu launcher, just using git-cola --prompt?

Yes, the same error is happening when I try to run git-cola from the command line when not in a git repo, with or without --prompt, just verified one more time.

Here's how far it makes it with tracing on, when run in my home directory:

$ env GIT_COLA_TRACE=1 git-cola --prompt
git -c diff.suppressBlankEmpty=false config -z --get-all cola.icontheme
git -c diff.suppressBlankEmpty=false config --null --file /etc/gitconfig --list
git -c diff.suppressBlankEmpty=false config --null --file /home/dmitry/.gitconfig --list
git -c diff.suppressBlankEmpty=false update-index --refresh
git -c diff.suppressBlankEmpty=false diff-index --cached -z HEAD --
git -c diff.suppressBlankEmpty=false diff-index --cached -z 4b825dc642cb6eb9a060e54bf8d69288fbee4904 --
git -c diff.suppressBlankEmpty=false diff-files -z --
git -c diff.suppressBlankEmpty=false ls-files --exclude-standard -z --others --

dpashkevich commented Apr 30, 2017

Are you able to reproduce it without using the menu launcher, just using git-cola --prompt?

Yes, the same error is happening when I try to run git-cola from the command line when not in a git repo, with or without --prompt, just verified one more time.

Here's how far it makes it with tracing on, when run in my home directory:

$ env GIT_COLA_TRACE=1 git-cola --prompt
git -c diff.suppressBlankEmpty=false config -z --get-all cola.icontheme
git -c diff.suppressBlankEmpty=false config --null --file /etc/gitconfig --list
git -c diff.suppressBlankEmpty=false config --null --file /home/dmitry/.gitconfig --list
git -c diff.suppressBlankEmpty=false update-index --refresh
git -c diff.suppressBlankEmpty=false diff-index --cached -z HEAD --
git -c diff.suppressBlankEmpty=false diff-index --cached -z 4b825dc642cb6eb9a060e54bf8d69288fbee4904 --
git -c diff.suppressBlankEmpty=false diff-files -z --
git -c diff.suppressBlankEmpty=false ls-files --exclude-standard -z --others --
@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 30, 2017

Bingo! I figured it out. I had this in my ~/.gitconfig:

#git-cola
[cola]
refreshonfocus = true

I recently set refreshonfocus to true because I noticed that git cola stopped automatically refreshing the status, so I had to manually hit Ctrl+R every time I switched to the app to stage/commit changes (do you know anything about it, btw?). I looked up this option somewhere in the docs. It must be trying to refresh without checking if we're already in a git repo.

dpashkevich commented Apr 30, 2017

Bingo! I figured it out. I had this in my ~/.gitconfig:

#git-cola
[cola]
refreshonfocus = true

I recently set refreshonfocus to true because I noticed that git cola stopped automatically refreshing the status, so I had to manually hit Ctrl+R every time I switched to the app to stage/commit changes (do you know anything about it, btw?). I looked up this option somewhere in the docs. It must be trying to refresh without checking if we're already in a git repo.

@davvid

This comment has been minimized.

Show comment
Hide comment
@davvid

davvid Apr 30, 2017

Member

Excellent, thanks, I should be able to reproduce it now. I'll get a fix in shortly.

Member

davvid commented Apr 30, 2017

Excellent, thanks, I should be able to reproduce it now. I'll get a fix in shortly.

@davvid davvid closed this in 32f9e78 Apr 30, 2017

@dpashkevich

This comment has been minimized.

Show comment
Hide comment
@dpashkevich

dpashkevich Apr 30, 2017

Your latest commit fixed it for me! Thanks for being so responsive, your tool is my favorite :)

dpashkevich commented Apr 30, 2017

Your latest commit fixed it for me! Thanks for being so responsive, your tool is my favorite :)

@davvid

This comment has been minimized.

Show comment
Hide comment
@davvid

davvid Apr 30, 2017

Member

Thanks a ton for your help, that was super helpful, and It works now! 😄

Member

davvid commented Apr 30, 2017

Thanks a ton for your help, that was super helpful, and It works now! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment