btskinner / grm

GitHub CLI classroom manager

Home Page:https://www.btskinner.io/grm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

initialize class problem

ozanj opened this issue · comments

encountering errors trying to accomplish "( 1 ) initialize class" in gitroom.

My organization is "Rucla-ed"

I successfully applied to make the organization part of GitHub education.

the contents of Rucla-ed_grm.json are as follows:

{
"github_login": "ozanj",
"github_token_file": "C:/Users/ozanj/Documents/github_token/token.txt",
"github_protocol": "SSH",
"organization_name": "Rucla-ed",
"roster_file": "C:/Users/ozanj/Documents/rclass2/_gitadmin/roster.csv",
"master_repo": "C:/Users/ozanj/Documents/rclass2",
"student_repo_dir": "C:/Users/ozanj/Documents/rclass2/_student_repositories"
}

I had been building the class on the repository "rclass2," which I initiated a week ago

I transferred this respository "rclass2" to the "Rucla-ed" organization [maybe the problem here?]

Here is some of the output/log I get from terminal when trying to "initialize class" within gitroom [and I get the same error if I first delete student folders within "rclass2/_student_repositories"]:


What would you like to do?

( 1 ) Initialize class
( 2 ) Add students to class
( 3 ) Add new administrator
( 4 ) Clone repositories
( 5 ) Update student remote repositories with local master
( 6 ) Pull down from remote student repositories
( 7 ) Push from local student repositories to remotes
( 8 ) Grade student assignments
( 9 ) << Exit Program >>

CHOICE: 1

Students to be added to Rucla-ed

Ozan Jaquette
Patricia Martin
Crystal Han


Should repos be private?

( 1 ) Yes
( 2 ) No

CHOICE: 1
You cannot demote yourself. Admins must be demoted by another admin.

ERROR:
Either:

(1) Remote already exists
(2) Your organization plan doesn't allow for private repos
and you must change the setting to public
or upgrade your plan through GitHub.

Team student_jaquette already exists!

Jaquette_Ozan's membership on team student_jaquette is now active.
student_jaquette now has access to repo student_jaquette
Unexpected remote arg: C:/Users/ozanj/Documents/rclass2/
rsync error: syntax or usage error (code 1) at main.c(1372) [sender=3.1.3]
Reinitialized existing Git repository in C:/Users/ozanj/Documents/rclass2/_student_repositories/student_jaquette/.git/
fatal: remote origin already exists.
On branch master

Initial commit

nothing to commit
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:Rucla-ed/student_jaquette.git'
Martin_Patricia is already an active member.

ERROR:
Either:

(1) Remote already exists
(2) Your organization plan doesn't allow for private repos
and you must change the setting to public
or upgrade your plan through GitHub.

Team student_martin already exists!

Martin_Patricia's membership on team student_martin is now active.
student_martin now has access to repo student_martin
Unexpected remote arg: C:/Users/ozanj/Documents/rclass2/
rsync error: syntax or usage error (code 1) at main.c(1372) [sender=3.1.3]
Reinitialized existing Git repository in C:/Users/ozanj/Documents/rclass2/_student_repositories/student_martin/.git/
fatal: remote origin already exists.
On branch master

Initial commit

nothing to commit
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:Rucla-ed/student_martin.git'
Han_Crystal is already an active member.

@ozanj, a few questions:

  • Do you see the student repos on the GitHub remote?

I transferred this respository "rclass2" to the "Rucla-ed" organization

  • When transferred (I assume you mean from you personal account to the org: from "ozanj/rclass2" --> "Rucla-ed/rclass2"), did you update the remote on your machine? What do you see when you are at the command line, in the repo and type:
git remote -v

Is the old location or the new one?

  • What do you get when you type this in the command line?
ssh -T git@github.com

You might check this link if you don't get a good result.

@btskinner ,

I do see student repos on the GitHub remote
https://github.com/Rucla-ed

yes, i changed personal account from "ozanj/rclass2" --> "Rucla-ed/rclass2"

I did not update remote on my local machine. when I type:

$ git remote -v
origin  https://github.com/ozanj/rclass2.git (fetch)
origin  https://github.com/ozanj/rclass2.git (push)

then I types this:

ozanj@jaquette01 MINGW64 ~/documents/rclass2 (master)
$ git remote set-url origin git@github.com:Rucla-ed/rclass2.git

ozanj@jaquette01 MINGW64 ~/documents/rclass2 (master)
$ git remote -v
origin  git@github.com:Rucla-ed/rclass2.git (fetch)
origin  git@github.com:Rucla-ed/rclass2.git (push)

after doing this, i tried to "initialize class" on gitroom but got same error as before.

thought maybe I would have to update the .json file cuz of changes to remote you recommended but .json file only pointed to folders on my local machine.

and this is what I get for ssh -T:

ozanj@jaquette01 MINGW64 ~/documents/rclass2 (master)
$ ssh -T git@github.com
Hi ozanj! You've successfully authenticated, but GitHub does not provide shell access.

I think the problem may be that an internal command, rsync, doesn't handle colons well. This means that my earlier advice to use full paths may not work (since it borks when it sees C:/Users...). Can you switch to relative paths and see if it works. You'll probably need run gitroom in the same directory you set it up, so just set it up in the top-level repo.

Let me know if that works.

still not working

this is output I got on git bash after trying to initialize

------------------------------------------------
How would you like to enter GitRoom information?
------------------------------------------------

( 1 ) Manually
( 2 ) From JSON file
( 3 ) << Exit Program >>

CHOICE: 2
Please give path to GitRoom JSON file:
data                  problem_sets          README.md             _config.yml           _student_repositories
lectures              rclass2.Rproj         resources             _gitadmin             _working
Please give path to GitRoom JSON file: _gitadmin/Rucla-ed_grm.json
Traceback (most recent call last):
  File "C:/Users/ozanj/AppData/Local/Programs/Python/Python38/Scripts/gitroom", line 4, in <module>
    __import__('pkg_resources').run_script('grm==0.4.0', 'gitroom')
  File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 666, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources\__init__.py", line 1462, in run_script
    exec(code, namespace, namespace)
  File "c:\users\ozanj\appdata\local\programs\python\python38\lib\site-packages\grm-0.4.0-py3.8.egg\EGG-INFO\scripts\gitroom", line 4, in <module>
    grm.main()
  File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.0-py3.8.egg\grm\__init__.py", line 112, in main
    __menu(connect_code)
  File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.0-py3.8.egg\grm\__init__.py", line 20, in __menu
    connect_code = gr.getGitRoomObjs(cc)
  File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.0-py3.8.egg\grm\gr.py", line 161, in getGitRoomObjs
    connect_code = self._readGitRoomInfo(grjson)
  File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.0-py3.8.egg\grm\gr.py", line 129, in _readGitRoomInfo
    connect_code = self._initGitRoom(github_login = info['github_login'],
  File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.0-py3.8.egg\grm\gr.py", line 66, in _initGitRoom
    self.rgo.setAPICreds(ghid = github_login,
  File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.0-py3.8.egg\grm\api.py", line 205, in setAPICreds
    admin.token_file, admin._Admin__token = self.setToken(**kwargs)
  File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.0-py3.8.egg\grm\api.py", line 182, in setToken
    with open(tfp) as f:
FileNotFoundError: [Errno 2] No such file or directory: '/c/Users/ozanj/Documents/github_token/token.txt'

But I think this file path is correct. see below:

ozanj@jaquette01 MINGW64 ~/Documents/rclass2 (master)
$ cat "/c/Users/ozanj/Documents/github_token/token.txt"
[hidden]

Okay...I guess try to go back to relative paths for now and try to see if you can get it to read from the correct directory when copying. I've got to think more about this.

I tried doing from relative paths again.
[note that this is path to top-line directory:
C:\Users\ozanj\Documents\rclass2]

this time I tried relative paths from C:\Users\ozanj\Documents

below is .json file consistent w/ starting at "Documents" folder

{
"github_login": "ozanj",
"github_token_file": "github_token/token.txt",
"github_protocol": "SSH",
"organization_name": "Rucla-ed",
"roster_file": "rclass2/_gitadmin/roster.csv",
"master_repo": "rclass2",
"student_repo_dir": "rclass2/_student_repositories"
}

but I got the same weird result as before, where gitroom started copying every single file/folder from "documents" into the student_jaquette repository

Okay. I've added some code that may fix your issue. I don't have a windows machine so I can't test. Clone the repo to your machine, and do the following:

$   > cd grm
grm > git checkout dev
grm > python setup.py install

(You may need to run python3 instead of python depending on how your machine is set up). When you run gitroom, you should have version 0.4.1. Set up the class again using the absolute paths with C: (so basically like you had it at first). Let me know if that works.

think we are getting closer. still not there yet. see error below at bottom of pasted terminal output.

I tried to fix this myself by changing the contents of loc.py

basically this seemed to be the problematic line of code:

if _platform == "Windows":

I changed this line to:

if platform.system() == "Windows":

and also added this line to top of loc.py

import platform

but another error appeared and quickly got out of my paygrade:

File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.1-py3.8.egg\grm\loc.py", line 119, in masterToStudent
sr_drive = re.sub(r'^(.+):(.*)$', r'\1', self.student_repo)
AttributeError: 'LocalGit' object has no attribute 'student_repo'

here is code for original error before I tried to change loc.py


What would you like to do?

( 1 ) Initialize class
( 2 ) Add students to class
( 3 ) Add new administrator
( 4 ) Clone repositories
( 5 ) Update student remote repositories with local master
( 6 ) Pull down from remote student repositories
( 7 ) Push from local student repositories to remotes
( 8 ) Grade student assignments
( 9 ) << Exit Program >>

CHOICE: 1

Students to be added to Rucla-ed

Ozan Jaquette
Patricia Martin
Crystal Han


Should repos be private?

( 1 ) Yes
( 2 ) No

CHOICE: 1
You cannot demote yourself. Admins must be demoted by another admin.

ERROR:
Either:

(1) Remote already exists
(2) Your organization plan doesn't allow for private repos
and you must change the setting to public
or upgrade your plan through GitHub.

Team student_jaquette already exists!

Jaquette_Ozan's membership on team student_jaquette is now active.
Traceback (most recent call last):
File "C:/Users/ozanj/AppData/Local/Programs/Python/Python38/Scripts/gitroom", line 4, in
import('pkg_resources').run_script('grm==0.4.1', 'gitroom')
File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources_init_.py", line 666, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\pkg_resources_init_.py", line 1462, in run_script
exec(code, namespace, namespace)
File "c:\users\ozanj\appdata\local\programs\python\python38\lib\site-packages\grm-0.4.1-py3.8.egg\EGG-INFO\scripts\gitroom", line 4, in
grm.main()
File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.1-py3.8.egg\grm_init_.py", line 112, in main
_menu(connect_code)
File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.1-py3.8.egg\grm_init
.py", line 51, in __menu
gr.buildGR(from_scratch = True)
File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.1-py3.8.egg\grm\gr.py", line 278, in buildGR
self.lgo.masterToStudent(student_repo = rn)
File "C:\Users\ozanj\AppData\Local\Programs\Python\Python38\lib\site-packages\grm-0.4.1-py3.8.egg\grm\loc.py", line 114, in masterToStudent
if _platform == "Windows":
NameError: name '_platform' is not defined

Ah, typo on my part. Try downloading from dev again (v0.4.2).

Finally got a Windows machine with Git Bash. Download from dev again, which should be v0.4.6 now.

probably an error on my part now. i'm just copying all text from git bash terminal

Version: 0.4.6
Author: Benjamin Skinner
Documentation: https://btskinner.io/grm
REPO: https://github.com/btskinner/grm
LICENSE: MIT


How would you like to enter GitRoom information?

( 1 ) Manually
( 2 ) From JSON file
( 3 ) << Exit Program >>

CHOICE: 2
Please give path to GitRoom JSON file: C:/Users/ozanj/Documents/rclass2/_gitadmin/Rucla-ed_grm.json

Getting information from organization remote...


What would you like to do?

( 1 ) Initialize class
( 2 ) Add students to class
( 3 ) Add new administrator
( 4 ) Clone repositories
( 5 ) Update student remote repositories with local master
( 6 ) Pull down from remote student repositories
( 7 ) Push from local student repositories to remotes
( 8 ) Grade student assignments
( 9 ) << Exit Program >>

CHOICE: 1

Students to be added to Rucla-ed

Ozan Jaquette
Patricia Martin
Crystal Han


Should repos be private?

( 1 ) Yes
( 2 ) No

CHOICE: 1
You cannot demote yourself. Admins must be demoted by another admin.

ERROR:
Either:

(1) Remote already exists
(2) Your organization plan doesn't allow for private repos
and you must change the setting to public
or upgrade your plan through GitHub.

Team student_jaquette already exists!

Jaquette_Ozan's membership on team student_jaquette is now active.
rsync: change_dir "/c/Users/ozanj/Documents/rclass2" failed: No such file or directory (2)
rsync: change_dir#3 "/c/Users/ozanj/Documents/rclass2" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(720) [Receiver=3.1.3]
Reinitialized existing Git repository in C:/Users/ozanj/Documents/rclass2/_student_repositories/student_jaquette/.git/
fatal: remote origin already exists.
On branch master

Initial commit

nothing to commit
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:Rucla-ed/student_jaquette.git'
Martin_Patricia is already an active member.

ERROR:
Either:

(1) Remote already exists
(2) Your organization plan doesn't allow for private repos
and you must change the setting to public
or upgrade your plan through GitHub.

Team student_martin already exists!

Martin_Patricia's membership on team student_martin is now active.
rsync: change_dir "/c/Users/ozanj/Documents/rclass2" failed: No such file or directory (2)
rsync: change_dir#3 "/c/Users/ozanj/Documents/rclass2" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(720) [Receiver=3.1.3]
Reinitialized existing Git repository in C:/Users/ozanj/Documents/rclass2/_student_repositories/student_martin/.git/
fatal: remote origin already exists.
On branch master

Initial commit

nothing to commit
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:Rucla-ed/student_martin.git'
Han_Crystal is already an active member.

ERROR:
Either:

(1) Remote already exists
(2) Your organization plan doesn't allow for private repos
and you must change the setting to public
or upgrade your plan through GitHub.

Team student_han already exists!

Han_Crystal's membership on team student_han is now active.
rsync: change_dir "/c/Users/ozanj/Documents/rclass2" failed: No such file or directory (2)
rsync: change_dir#3 "/c/Users/ozanj/Documents/rclass2" failed: No such file or directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(720) [Receiver=3.1.3]
Reinitialized existing Git repository in C:/Users/ozanj/Documents/rclass2/_student_repositories/student_han/.git/
fatal: remote origin already exists.
On branch master

Initial commit

nothing to commit
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:Rucla-ed/student_han.git'

Go back to using absolute paths with C: with double backslashes. Here's my json file for the test class:

{
    "github_login": "btskinner",
    "github_token_file": "C:\\Users\\benski\\.github_token",
    "github_protocol": "SSH",
    "organization_name": "benskiorg",
    "roster_file": "C:\\Users\\benski\\courses\\course123\\_admin\\roster.csv",
    "master_repo": "C:\\Users\\benski\\courses\\course123",
    "student_repo_dir": "C:\\Users\\benski\\courses\\course123\\_student_repos"
}

It might help to fully delete the student_ repos and start from scratch.

I changed the .json file and delted the student_ repos on my local machine
[note: those student repos don't exist as remote repositories in the organization. i deleted those the other day.]

get similar errors. maybe this has to do w/ the rsync problem of dealing w/ "C:"? see below:

Martin_Patricia is already an active member.

ERROR:
Either:

(1) Remote already exists
(2) Your organization plan doesn't allow for private repos
and you must change the setting to public
or upgrade your plan through GitHub.

Team student_martin already exists!

Martin_Patricia's membership on team student_martin is now active.
rsync: change_dir "/c\Users\ozanj\Documents\rclass2" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
Initialized empty Git repository in C:/Users/ozanj/Documents/rclass2/_student_repositories/student_martin/.git/
On branch master

Initial commit

nothing to commit
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:Rucla-ed/student_martin.git'

What does your json file look like now?

Also, when you type rsync --version in git bash, what do you get?

{
"github_login": "ozanj",
"github_token_file": "C:\Users\ozanj\Documents\github_token\token.txt",
"github_protocol": "SSH",
"organization_name": "Rucla-ed",
"roster_file": "C:\Users\ozanj\Documents\rclass2\_gitadmin\roster.csv",
"master_repo": "C:\Users\ozanj\Documents\rclass2",
"student_repo_dir": "C:\Users\ozanj\Documents\rclass2\_student_repositories"
}

ozanj@jaquette01 MINGW64 ~/documents/rclass2 (master)
$ rsync --version
rsync version 3.1.3 protocol version 31
Copyright (C) 1996-2018 by Andrew Tridgell, Wayne Davison, and others.
Web site: http://rsync.samba.org/
Capabilities:
64-bit files, 64-bit inums, 32-bit timestamps, 64-bit long ints,
socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
append, ACLs, no xattrs, iconv, symtimes, prealloc

Replace all your backslashes with double backslashes like mine. So

{
"github_login": "ozanj",
"github_token_file": "C:\\Users\\ozanj\\Documents\\github_token\\token.txt",
"github_protocol": "SSH",
"organization_name": "Rucla-ed",
"roster_file": "C:\\Users\\ozanj\\Documents\\rclass2\\_gitadmin\\roster.csv",
"master_repo": "C:\\Users\\ozanj\\Documents\\rclass2",
"student_repo_dir": "C:\\Users\\ozanj\\Documents\\rclass2\\_student_repositories"
}

weird. they were double back slashes but when copied to issues text they showed up as single. anyways, i replaced contents of my .json w/ yours

$ cat _gitadmin/Rucla-ed_grm.json
{
        "github_login": "ozanj",
        "github_token_file": "C:\\Users\\ozanj\\Documents\\github_token\\token.txt",
        "github_protocol": "SSH",
        "organization_name": "Rucla-ed",
        "roster_file": "C:\\Users\\ozanj\\Documents\\rclass2\\_gitadmin\\roster.csv",
        "master_repo": "C:\\Users\\ozanj\\Documents\\rclass2",
        "student_repo_dir": "C:\\Users\\ozanj\\Documents\\rclass2\\_student_repositories"
}

still get the same kind of error

error: failed to push some refs to 'git@github.com:Rucla-ed/student_martin.git'
Han_Crystal is already an active member.

ERROR:
Either:

(1) Remote already exists
(2) Your organization plan doesn't allow for private repos
and you must change the setting to public
or upgrade your plan through GitHub.

Team student_han already exists!

Han_Crystal's membership on team student_han is now active.
rsync: change_dir "/c\Users\ozanj\Documents\rclass2" failed: No such file or directory (2)

You have put the code in back ticks to show as code / shell output (click edit button above to see).

At this point, I don't know. It works on my Windows machine with Git Bash now. My guess is that your paths aren't quite right or you have a fundamentally different set up. Let me think on it more.

thanks Ben. I agree this is something on my end. pls don't spend more than 5 minutes thinking about it.

I'll try to devote some time over the next few days. and then when I can't figure it out, I'll pull in Crystal because she can figure out literally anything. appreciate all your help and work on this brother.

Great! Let me know.

@cyouh95
@btskinner

spent an hour working on this tonight. [e.g., tried creating a new repository called edrclass2, cloned contents of rclass2 into edrclass2, moved edrclass2 into the Rucla-ed org, tried initializing class in gitroom. same error as before.

so played around w/ trying to get gitroom working with the rclass2 repository. played w/ format of filepaths in .json file. but I think the problem is still that the rsync function is not like "C:" in this line of the json file

"master_repo": "C:\Users\ozanj\Documents\rclass2",

below is output from most recent failure on git bash

note this line in particular:

rsync: change_dir "/c\Users\ozanj\Documents\rclass2" failed: No such file or directory (2)




Should repos be private?

( 1 ) Yes
( 2 ) No

CHOICE: 1
You cannot demote yourself. Admins must be demoted by another admin.

ERROR:
Either:

(1) Remote already exists
(2) Your organization plan doesn't allow for private repos
and you must change the setting to public
or upgrade your plan through GitHub.

Successfully created team: student_jaquette
Jaquette_Ozan's membership on team student_jaquette is now active.
rsync: change_dir "/c\Users\ozanj\Documents\rclass2" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
Initialized empty Git repository in C:/Users/ozanj/Documents/rclass2/_student_repositories/student_jaquette/.git/
On branch master

Initial commit

nothing to commit
error: src refspec master does not match any.
error: failed to push some refs to 'git@github.com:Rucla-ed/student_jaquette.git'

Maybe we can give relative paths another try? Was this error about token.txt the only issue from the first attempt?

What happens if you only change master_repo and student_repo_dir in the JSON file to relative path, and keep the rest (e.g., github_token_file) as absolute?

Seems to be fixed with dev v0.4.10as long as person uses relative paths formaster_repoandstudent_repo_dir`. Needs more robust solution, but leaving for now.