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

wierd issue i cant fix. when i type subuser list available #348

Open
asmatthew opened this issue May 1, 2019 · 9 comments
Open

wierd issue i cant fix. when i type subuser list available #348

asmatthew opened this issue May 1, 2019 · 9 comments

Comments

@asmatthew
Copy link

when i try to add a package
i get this:

subuser list available
Traceback (most recent call last):
File "/usr/local/bin/subuser", line 52, in
command(sys.argv[2:])
File "/usr/local/lib/python3.6/dist-packages/subuserlib/builtInCommands/list.py", line 64, in runCommand
reposToList = user.registry.repositories.keys()
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/registry.py", line 53, in repositories
self.__repositories = repositories.Repositories(self.user)
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/repositories.py", line 28, in init
self.reloadRepositoryLists()
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/repositories.py", line 50, in reloadRepositoryLists
repositoryStates = self._loadRepositoryStates()
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/repositories.py", line 91, in _loadRepositoryStates
if "repository-states.json" in gitFileStructure.lsFiles("./"):
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/fileStructure.py", line 41, in lsFiles
return self._lsFiles(subfolder)
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/gitRepository.py", line 213, in _lsFiles
return self.ls(subfolder,"blob")
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/fileStructure.py", line 29, in ls
return self._ls(subfolder,objectType=objectType)
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/gitRepository.py", line 193, in _ls
items = self.lsTree()
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/gitRepository.py", line 169, in lsTree
(returncode,output) = self.gitRepository.runCollectOutput(["ls-tree"]+args)
File "/usr/local/lib/python3.6/dist-packages/subuserlib/classes/gitRepository.py", line 91, in runCollectOutput
raise GitException(stderr)
subuserlib.classes.gitRepository.GitException: fatal: Not a valid object name master

in stead of pkgs

@timthelion
Copy link
Contributor

That is strange. I wonder how it happened. What this command is doing, is actually just listing the folders in the directories ~/.subuser/repositories/<repo-id> by doing git ls-tree. It would appear that one of those folders is not a proper git repo with the branch master. Did you add a new image from a new repository before it broke?

@asmatthew
Copy link
Author

asmatthew commented May 3, 2019

Nope. It was my first dl. it's strange bc I make an Ubuntu virtual machine and installed the dependencies and tried it again and I got the same issue. I must be doing something wrong. Any ideas?

@richard-delorenzi
Copy link

What is dl and bc? Sorry I don't understand “ab”s.

@timthelion
Copy link
Contributor

@richard-delorenzi DL stands for download

@jtyers
Copy link

jtyers commented May 13, 2021

Same here, on a fresh system (#340 causes the first exception, which can be ignored):

$ rm -rf .subuser
$ subuser list available
Traceback (most recent call last):
  File "/usr/bin/subuser", line 52, in <module>
    command(sys.argv[2:])
  <snip>
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/gitRepository.py", line 70, in run
    raise GitException(stderr)
subuserlib.classes.gitRepository.GitException: hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>

Then, if I run list available a second time:

$ subuser list available
Traceback (most recent call last):
  File "/usr/bin/subuser", line 52, in <module>
    command(sys.argv[2:])
  File "/usr/lib/python3.9/site-packages/subuserlib/builtInCommands/list.py", line 64, in runCommand
    reposToList = user.registry.repositories.keys()
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/registry.py", line 53, in repositories
    self.__repositories = repositories.Repositories(self.user)
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/repositories.py", line 28, in __init__
    self.reloadRepositoryLists()
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/repositories.py", line 50, in reloadRepositoryLists
    repositoryStates = self._loadRepositoryStates()
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/repositories.py", line 91, in _loadRepositoryStates
    if "repository-states.json" in gitFileStructure.lsFiles("./"):
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/fileStructure.py", line 41, in lsFiles
    return self._lsFiles(subfolder)
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/gitRepository.py", line 213, in _lsFiles
    return self.ls(subfolder,"blob")
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/fileStructure.py", line 29, in ls
    return self._ls(subfolder,objectType=objectType)
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/gitRepository.py", line 193, in _ls
    items = self.lsTree()
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/gitRepository.py", line 169, in lsTree
    (returncode,output) = self.gitRepository.runCollectOutput(["ls-tree"]+args)
  File "/usr/lib/python3.9/site-packages/subuserlib/classes/gitRepository.py", line 91, in runCollectOutput
    raise GitException(stderr)
subuserlib.classes.gitRepository.GitException: fatal: Not a valid object name master

At this point, ~/.subuser/registry is created, and is a git repo with a master branch, but no commits against it.

subuser 0.6.2
Arch Linux, subuser installed via AUR

@jtyers
Copy link

jtyers commented May 13, 2021

The issue appears to be that the repo has no commits, and therefore master doesn't exist yet. git ls-tree master fails with the same error as above.

To fix, simply make a commit. For example:

cd ~/.subuser/registry
touch foo
git add foo && git commit -m 'initial commit'
git rm foo && git commit -m 'remove initial'

After that, subuser list available works for me.

@jtyers
Copy link

jtyers commented May 13, 2021

This really should be fixed - subuser failing to run on a fresh system will put many new users off.

@rowanthorpe
Copy link

I just hit this problem too and worked out what it is (and a workaround, and what the actual fix should be for whoever has the time to apply it). My system (and probably the others on this thread) has the git config value init.defaultBranch = main. Anyone not familiar with why this is the new default can see a good explanation here. This is represented for example in ~/.gitconfig or even in /etc/gitconfig as:

[init]
	defaultBranch = main

Subuser however makes a lot of hardcoded assumptions that the configured default is the previously expected master. Even when it was the de facto standard the hardcoding was not ideal because that has always been configurable for users anyway (so not a good assumption). The first time subuser list available is run git never checks out "master" (it tries to check out "main" and fails) .Then subuser hits the following error due to the locally missing "master" branch:

OSError: Running git in /home/rowan/.subuser/registry with args ['show-ref', '-s', 'master'] failed.

Because that leaves the ~/.subuser repo in a partially setup state, any subsequent runs of subuser list available give the following error:

subuserlib.classes.gitRepository.GitException: fatal: Not a valid object name master

Below I show a transcript of installing the development version with that default (and hitting those errors), and then doing the same with init.defaultBranch = master which works fine. So far it seems once subuser list available is run the first time (triggering the setup of the ~/.subuser repo) then the system/user default can be reverted to "main" without problem (subuser seems to keep working fine after that so it is probably just the initial setup that makes the hardcoded assumption). I then show a list of all files from the Debian package of subuser which include the hardcoded master. At least a few of those are correct though (for example some documentation-links to online pages throw a "404" error with the equivalent "main" URL) so the fix is not as easy as a simple s/\<master\>/main/g on all files (unfortunately).

~$ git clone https://github.com/subuser-security/subuser
Cloning into 'subuser'...
remote: Enumerating objects: 10314, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 10314 (delta 0), reused 1 (delta 0), pack-reused 10309
Receiving objects: 100% (10314/10314), 2.35 MiB | 909.00 KiB/s, done.
Resolving deltas: 100% (7064/7064), done.
~$ export PATH= "${HOME}/subuser/logic:/${HOME}/.subuser/bin:${PATH}"
~$ subuser list available
Initial commit.
Cloning repository default from https://github.com/subuser-security/subuser-default-repository.git
Cloning into '/home/rowan/.subuser/repositories/default'...
remote: Enumerating objects: 2690, done.
remote: Total 2690 (delta 0), reused 0 (delta 0), pack-reused 2690
Receiving objects: 100% (2690/2690), 338.99 KiB | 592.00 KiB/s, done.
Resolving deltas: 100% (1539/1539), done.

Traceback (most recent call last):
  File "/home/rowan/subuser/logic/subuser", line 60, in <module>
    command(sys.argv[2:])
  File "/home/rowan/subuser/subuserlib/builtInCommands/list.py", line 62, in runCommand
    reposToList = args[1:] if len(args) > 1 else user.registry.repositories.keys()
  File "/home/rowan/subuser/subuserlib/classes/user.py", line 72, in registry
    self.__registry.ensureGitRepoInitialized()
  File "/home/rowan/subuser/subuserlib/classes/registry.py", line 70, in ensureGitRepoInitialized
    self.commit("Initial commit.",_no_lock_needed = True)
  File "/home/rowan/subuser/subuserlib/classes/registry.py", line 129, in commit
    announcement["commit"] = self.gitRepository.getHashOfRef("master")
  File "/home/rowan/subuser/subuserlib/classes/gitRepository.py", line 126, in getHashOfRef
    raise OSError("Running git in "+self.path+" with args "+str(command)+" failed.")
OSError: Running git in /home/rowan/.subuser/registry with args ['show-ref', '-s', 'master'] failed.
~$ ## (and now if I run it again)
~$ subuser list available
fatal: Not a valid object name master
Traceback (most recent call last):
  File "/home/rowan/subuser/logic/subuser", line 60, in <module>
    command(sys.argv[2:])
  File "/home/rowan/subuser/subuserlib/builtInCommands/list.py", line 62, in runCommand
    reposToList = args[1:] if len(args) > 1 else user.registry.repositories.keys()
  File "/home/rowan/subuser/subuserlib/classes/registry.py", line 54, in repositories
    self.__repositories = repositories.Repositories(self.user)
  File "/home/rowan/subuser/subuserlib/classes/repositories.py", line 28, in __init__
    self.reloadRepositoryLists()
  File "/home/rowan/subuser/subuserlib/classes/repositories.py", line 50, in reloadRepositoryLists
    repositoryStates = self._loadRepositoryStates()
  File "/home/rowan/subuser/subuserlib/classes/repositories.py", line 91, in _loadRepositoryStates
    if "repository-states.json" in gitFileStructure.lsFiles("./"):
  File "/home/rowan/subuser/subuserlib/classes/fileStructure.py", line 41, in lsFiles
    return self._lsFiles(subfolder)
  File "/home/rowan/subuser/subuserlib/classes/gitRepository.py", line 216, in _lsFiles
    return self.ls(subfolder,"blob")
  File "/home/rowan/subuser/subuserlib/classes/fileStructure.py", line 29, in ls
    return self._ls(subfolder,objectType=objectType)
  File "/home/rowan/subuser/subuserlib/classes/gitRepository.py", line 196, in _ls
    items = self.lsTree()
  File "/home/rowan/subuser/subuserlib/classes/gitRepository.py", line 172, in lsTree
    (returncode,output) = self.gitRepository.runCollectOutput(["ls-tree"]+args)
  File "/home/rowan/subuser/subuserlib/classes/gitRepository.py", line 64, in runCollectOutput
    return self.__run(args,eatStderr=eatStderr,decode=decode)
  File "/home/rowan/subuser/subuserlib/classes/gitRepository.py", line 80, in __run
    raise GitException(stderr)
subuserlib.classes.gitRepository.GitException: fatal: Not a valid object name master
~$ rm -fr .subuser subuser
~$ mv -iv ~/.gitconfig{,.real}
~$ printf '[init]\n\tdefaultBranch = master\n' >~/.gitconfig
~$ git clone https://github.com/subuser-security/subuser
Cloning into 'subuser'...
remote: Enumerating objects: 10314, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 10314 (delta 0), reused 1 (delta 0), pack-reused 10309
Receiving objects: 100% (10314/10314), 2.35 MiB | 871.00 KiB/s, done.
Resolving deltas: 100% (7064/7064), done.
~$ subuser list available
Initial commit.
Cloning repository default from https://github.com/subuser-security/subuser-default-repository.git
Cloning into '/home/rowan/.subuser/repositories/default'...
remote: Enumerating objects: 2690, done.
remote: Total 2690 (delta 0), reused 0 (delta 0), pack-reused 2690
Receiving objects: 100% (2690/2690), 338.99 KiB | 568.00 KiB/s, done.
Resolving deltas: 100% (1539/1539), done.
arduino@default
arduino-base@default
blender@default
blender-base@default
briquolo@default
briquolo-base@default
docker-in-docker@default
docker-in-docker-base@default
emacs@default
emacs-base@default
git@default
git-base@default
icedove@default
icedove-base@default
iceweasel@default
iceweasel-base@default
iceweasel-java@default
iceweasel-java-base@default
iceweasel-webgl@default
iceweasel-webgl-base@default
ino@default
ino-base@default
irssi@default
irssi-base@default
keepassx@default
keepassx-base@default
kpcli@default
kpcli-base@default
libdebian@default
libhaskell-platform@default
libjava@default
libreoffice@default
libreoffice-base@default
libx11@default
liferea@default
liferea-base@default
lynx@default
lynx-base@default
offlineimap@default
offlineimap-base@default
orange-canvas@default
orange-canvas-base@default
pandoc@default
pandoc-base@default
phatch@default
phatch-base@default
pidgin@default
pidgin-base@default
qt4-designer@default
qt4-designer-base@default
rust@default
subuser-internal-xpra-client@default
subuser-internal-xpra-server@default
subversion@default
subversion-base@default
texttest@default
texttest-base@default
umlet@default
umlet-base@default
vim@default
vim-base@default
vlc@default
vlc-base@default
weka@default
weka-base@default
wesnoth@default
wesnoth-base@default
xpra@default
xpra-base@default
xterm@default
xterm-base@default
xtightvncviewer@default
xtightvncviewer-base@default
~$ rm -fr subuser .subuser
~$ sudo apt install subuser
----8<----
(snipped output, not important)
---->8----
~$ dpkg -L subuser | while IFS= read -r pathname; do [[ -f $pathname ]] || continue; grep -Hni '\<master\>' $pathname; done | sed -Ee 's/\t/  /g; s/^(.{200}).*$/\1/'
/usr/lib/python3/dist-packages/subuserlib/classes/gitRepository.py:187:    >>> fileStructure = gitRepository.getFileStructureAtCommit("master")
/usr/lib/python3/dist-packages/subuserlib/classes/gitRepository.py:209:    >>> fileStructure = gitRepository.getFileStructureAtCommit("master")
/usr/lib/python3/dist-packages/subuserlib/classes/gitRepository.py:222:    >>> fileStructure = gitRepository.getFileStructureAtCommit("master")
/usr/lib/python3/dist-packages/subuserlib/classes/gitRepository.py:232:    >>> fileStructure = gitRepository.getFileStructureAtCommit("master")
/usr/lib/python3/dist-packages/subuserlib/classes/gitRepository.py:251:    >>> fileStructure = gitRepository.getFileStructureAtCommit("master")
/usr/lib/python3/dist-packages/subuserlib/classes/gitRepository.py:268:    >>> fileStructure = gitRepository.getFileStructureAtCommit("master")
/usr/lib/python3/dist-packages/subuserlib/classes/gitRepository.py:281:    >>> fileStructure = gitRepository.getFileStructureAtCommit("master")
/usr/lib/python3/dist-packages/subuserlib/classes/registry.py:22:  def __init__(self,user,gitReadHash="master", ignoreVersionLocks=False, initialized = False):
/usr/lib/python3/dist-packages/subuserlib/classes/registry.py:123:      announcement["commit"] = self.gitRepository.getHashOfRef("master")
/usr/lib/python3/dist-packages/subuserlib/classes/repositories.py:61:          gitCommitHash = "master"
/usr/lib/python3/dist-packages/subuserlib/classes/repository.py:231:    master = "refs/remotes/origin/master"
/usr/lib/python3/dist-packages/subuserlib/classes/repository.py:232:    newCommitHash = self.gitRepository.getHashOfRef(master)
/usr/lib/python3/dist-packages/subuserlib/classes/repository.py:234:    if self.gitRepository.getFileStructureAtCommit(master).exists("./.subuser.json"):
/usr/lib/python3/dist-packages/subuserlib/classes/repository.py:235:      configFileContents = self.gitRepository.getFileStructureAtCommit(master).read("./.subuser.json")
/usr/lib/python3/dist-packages/subuserlib/repository.py:24:      repository = Repository(user,name=name,gitOriginURI=url,gitCommitHash="master")
/usr/lib/python3/dist-packages/subuserlib/resolve.py:136:  newTempRepo = Repository(user=user,name=user.registry.repositories.getNewUniqueTempRepoId(),gitOriginURI=uri,gitCommitHash="master",temporary
/usr/share/doc/subuser/html/_sources/developers/code-docs.rst.txt:9:The subuser source is stored in the `logic <https://github.com/subuser-security/subuser/tree/master/logic>`_ directory.
/usr/share/doc/subuser/html/_sources/developers/code-docs.rst.txt:11: * `logic/subuser <https://github.com/subuser-security/subuser/blob/master/logic/subuser>`_ - This is the main subuser executable.
/usr/share/doc/subuser/html/_sources/developers/code-docs.rst.txt:13: * `logic/subuserCommands <https://github.com/subuser-security/subuser/tree/master/logic/subuserCommands>`_ - This is where individ
/usr/share/doc/subuser/html/_sources/developers/code-docs.rst.txt:15: * `logic/subuserlib <https://github.com/subuser-security/subuser/tree/master/logic/subuserlib>`_ - The source files found in this 
/usr/share/doc/subuser/html/_sources/developers/code-docs.rst.txt:17: * `logic/subuserlib/classes <https://github.com/subuser-security/subuser/tree/master/logic/subuserlib/classes>`_ - This is where s
/usr/share/doc/subuser/html/_sources/developers/code-docs.rst.txt:22:When you run subuser, a ``subuser`` executable is called which immediately passes execution on to a subuser command. Any executable
/usr/share/doc/subuser/html/_sources/developers/common-tasks.rst.txt:7: 1. Set the permission's default value, description, and other attributes in the `permissions module <https://github.com/subuser-
/usr/share/doc/subuser/html/_sources/developers/common-tasks.rst.txt:9: 2. Tell subuser how to apply the permission in the `runtime class <https://github.com/subuser-security/subuser/blob/master/logic
/usr/share/doc/subuser/html/_sources/packaging.rst.txt:47:  $ git push origin master
/usr/share/doc/subuser/html/_sources/subuser-standard/repositories.rst.txt:48:   When reading ``.subuser.json`` subuser first reads the ``.subuser.json`` file found at ``master`` and subsiquently inte
/usr/share/doc/subuser/html/_sources/subuser-standard/repositories.rst.txt:57:   In this example, versions of subuser from ``0.7`` onward will use ``latest``. Between 0.6 and 0.7 the ``subuser-0.6`` b
/usr/share/doc/subuser/html/developers/code-docs.html:190:<p>The subuser source is stored in the <a class="reference external" href="https://github.com/subuser-security/subuser/tree/master/logic">logi
/usr/share/doc/subuser/html/developers/code-docs.html:193:<li><a class="reference external" href="https://github.com/subuser-security/subuser/blob/master/logic/subuser">logic/subuser</a> - This is the
/usr/share/doc/subuser/html/developers/code-docs.html:194:<li><a class="reference external" href="https://github.com/subuser-security/subuser/tree/master/logic/subuserCommands">logic/subuserCommands</
/usr/share/doc/subuser/html/developers/code-docs.html:195:<li><a class="reference external" href="https://github.com/subuser-security/subuser/tree/master/logic/subuserlib">logic/subuserlib</a> - The s
/usr/share/doc/subuser/html/developers/code-docs.html:196:<li><a class="reference external" href="https://github.com/subuser-security/subuser/tree/master/logic/subuserlib/classes">logic/subuserlib/cla
/usr/share/doc/subuser/html/developers/code-docs.html:202:<p>When you run subuser, a <code class="docutils literal notranslate"><span class="pre">subuser</span></code> executable is called which immed
/usr/share/doc/subuser/html/developers/common-tasks.html:192:<li>Set the permission’s default value, description, and other attributes in the <a class="reference external" href="https://github.com/sub
/usr/share/doc/subuser/html/developers/common-tasks.html:193:<li>Tell subuser how to apply the permission in the <a class="reference external" href="https://github.com/subuser-security/subuser/blob/ma
/usr/share/doc/subuser/html/packaging.html:213:$ git push origin master
/usr/share/doc/subuser/html/searchindex.js:1:Search.setIndex({docnames:["community","community-guidelines","developers/code-docs","developers/code-docs/config","developers/code-docs/docker","developer
/usr/share/doc/subuser/html/subuser-standard/repositories.html:227:When reading ``.subuser.json`` subuser first reads the ``.subuser.json`` file found at ``master`` and subsiquently interacts with the
/usr/share/doc/subuser/html/subuser-standard/repositories.html:236:In this example, versions of subuser from ``0.7`` onward will use ``latest``. Between 0.6 and 0.7 the ``subuser-0.6`` branch will be 
/usr/share/doc/subuser/html/_static/jquery.js:3998:      // the master Deferred
/usr/share/doc/subuser/html/_static/jquery.js:3999:      master = jQuery.Deferred(),
/usr/share/doc/subuser/html/_static/jquery.js:4007:            master.resolveWith( resolveContexts, resolveValues );
/usr/share/doc/subuser/html/_static/jquery.js:4014:      adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
/usr/share/doc/subuser/html/_static/jquery.js:4018:      if ( master.state() === "pending" ||
/usr/share/doc/subuser/html/_static/jquery.js:4021:        return master.then();
/usr/share/doc/subuser/html/_static/jquery.js:4027:      adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
/usr/share/doc/subuser/html/_static/jquery.js:4030:    return master.promise();

@p-himik
Copy link

p-himik commented Jun 12, 2023

Just happened on it as well, fixed by cd ~/.subuser/registry && git commit --allow-empty -m "Initial commit" (my default branch is master, so no issues there).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants