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

Can't download theme #182

Closed
stephanieluz opened this issue Mar 18, 2022 · 12 comments
Closed

Can't download theme #182

stephanieluz opened this issue Mar 18, 2022 · 12 comments
Labels
bug Something isn't working

Comments

@stephanieluz
Copy link
Collaborator

When I run plenti new site my-site --theme=git@github.com:plenti-themes/bigspring it throws:

022/03/18 17:20:07 errs.go:57: Can't clone theme repository: unable to find any valid known_hosts file, set SSH_KNOWN_HOSTS env variable
unable to find any valid known_hosts file, set SSH_KNOWN_HOSTS env variable (File: /home/runner/work/plenti/plenti/cmd/theme_add.go, Line: 75)
2022/03/18 17:20:07 errs.go:57: Can't get HEAD: reference not found
reference not found (File: /home/runner/work/plenti/plenti/cmd/theme_add.go, Line: 84)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x985965]

goroutine 1 [running]:
github.com/go-git/go-git/v5/plumbing.(*Reference).Hash(...)
	/home/runner/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/plumbing/reference.go:183
github.com/plentico/plenti/cmd.getCommitHash(0xc0001a9c80, 0x18, 0x7fff9711615f)
	/home/runner/work/plenti/plenti/cmd/theme_add.go:87 +0x125
github.com/plentico/plenti/cmd.glob..func6(0x2404c00, 0xc00007d6c0, 0x1, 0x2)
	/home/runner/work/plenti/plenti/cmd/site.go:103 +0x4b8
github.com/spf13/cobra.(*Command).execute(0x2404c00, 0xc00007d6a0, 0x2, 0x2, 0x2404c00, 0xc00007d6a0)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x2404700, 0xc000000180, 0x200000003, 0xc000000180)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/runner/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/plentico/plenti/cmd.Execute()
	/home/runner/work/plenti/plenti/cmd/root.go:58 +0x31
main.main()
	/home/runner/work/plenti/plenti/main.go:7 +0x25

I thought it might be because I didn't have an SSH key uploaded to GitHub, but the problem still persists even after adding it.

Possibly related to src-d/go-git#454

@sanati
Copy link

sanati commented Mar 19, 2022

I had the same error.
I tried another way:

  1. plenti new site YOUR_SITE_NAME
  2. cd YOUR_SITE_NAME
  3. plenti theme add https://github.com/plenti-themes/bigspring
  4. plenti theme enable bigsprings
  5. Please, copy files/directories from bigsprings to the main dir of YOUR_SITE_NAME (overwriting)
  6. plenti build
  7. plenti serve

Thats it!

@dougwinsby
Copy link

I ran into a similar problem as OP when creating a theme-based site (from linux vm using windows vmware):

errs.go:57: Can't clone theme repository: error creating SSH agent:
"Error connecting to SSH_AUTH_SOCK: dial unix /run/user/1000/keyring/ssh: connect: permission denied"

I'm running ubuntu 22.04. Github is configured with a ssh key created on that VM, and I tested it with:

ssh -T git@github.com

I tried the workaround provided by @sanati, but I do not understand no. 5 (copy files/directories). I thought the idea of Plenti templates is so you can run the template with no changes and only override what you need to. Are there certain files I should be copying?

If I copy all files/directories from the template, why create a new site at all. Why not simply clone the theme and make it your own site (without a "theme" enabled)?

Any help would be greatly appreciated.

@jimafisk
Copy link
Member

I thought the idea of Plenti templates is so you can run the template with no changes and only override what you need to

That's correct @dougwinsby, you should only have to copy the files you want to override. The only required file in your base project should be a plenti.json sitewide configuration file (you may need to copy route overrides and other info from the theme's plenti.json to your project's plenti.json).

Sounds like there might be a bug here. I'll do some testing to see if I can recreate the issue to figure out what's going on.

@jimafisk jimafisk added the bug Something isn't working label May 16, 2022
@jimafisk
Copy link
Member

Trying to run plenti new site my-site --theme=git@github.com:plenti-themes/bigspring threw:

ssh: handshake failed: knownhosts: key mismatch
2022/05/17 12:51:29 errs.go:57: Can't clone theme repository: ssh: handshake failed: knownhosts: key mismatch
ssh: handshake failed: knownhosts: key mismatch (File: /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/theme_add.go, Line: 75)
2022/05/17 12:51:29 errs.go:57: Can't get HEAD: reference not found
reference not found (File: /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/theme_add.go, Line: 84)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xd1bf25]

goroutine 1 [running]:
github.com/go-git/go-git/v5/plumbing.(*Reference).Hash(...)
	/home/jimafisk/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/plumbing/reference.go:183
github.com/plentico/plenti/cmd.getCommitHash(0xc000203860, 0x18, 0x7ffe91d1cf40)
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/theme_add.go:87 +0x125
github.com/plentico/plenti/cmd.glob..func6(0x25ce2c0, 0xc0000396e0, 0x1, 0x2)
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/site.go:103 +0x4b8
github.com/spf13/cobra.(*Command).execute(0x25ce2c0, 0xc0000396c0, 0x2, 0x2, 0x25ce2c0, 0xc0000396c0)
	/home/jimafisk/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x25cddc0, 0xc000000180, 0x200000003, 0xc000000180)
	/home/jimafisk/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/jimafisk/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/plentico/plenti/cmd.Execute()
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/root.go:58 +0x31
main.main()
	/home/jimafisk/Projects/jantcu/plentico/plenti/main.go:7 +0x25

Then mv ~/.ssh/known_hosts ~/.ssh/known_hosts_OFF and plenti new site my-site --theme=git@github.com:plenti-themes/bigspring threw:

unable to find any valid known_hosts file, set SSH_KNOWN_HOSTS env variable
2022/05/17 13:07:31 errs.go:57: Can't clone theme repository: unable to find any valid known_hosts file, set SSH_KNOWN_HOSTS env variable
unable to find any valid known_hosts file, set SSH_KNOWN_HOSTS env variable (File: /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/theme_add.go, Line: 75)
2022/05/17 13:07:31 errs.go:57: Can't get HEAD: reference not found
reference not found (File: /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/theme_add.go, Line: 84)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xd1bf25]

goroutine 1 [running]:
github.com/go-git/go-git/v5/plumbing.(*Reference).Hash(...)
	/home/jimafisk/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/plumbing/reference.go:183
github.com/plentico/plenti/cmd.getCommitHash(0xc00007ff50, 0x18, 0x7ffd1ac84f40)
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/theme_add.go:87 +0x125
github.com/plentico/plenti/cmd.glob..func6(0x25ce2c0, 0xc0000396e0, 0x1, 0x2)
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/site.go:103 +0x4b8
github.com/spf13/cobra.(*Command).execute(0x25ce2c0, 0xc0000396c0, 0x2, 0x2, 0x25ce2c0, 0xc0000396c0)
	/home/jimafisk/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x25cddc0, 0xc000000180, 0x200000003, 0xc000000180)
	/home/jimafisk/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/jimafisk/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/plentico/plenti/cmd.Execute()
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/root.go:58 +0x31
main.main()
	/home/jimafisk/Projects/jantcu/plentico/plenti/main.go:7 +0x25

Then touch ~/.ssh/known_hosts and plenti new site my-site --theme=git@github.com:plenti-themes/bigspring threw:

ssh: handshake failed: knownhosts: key is unknown
2022/05/17 13:08:46 errs.go:57: Can't clone theme repository: ssh: handshake failed: knownhosts: key is unknown
ssh: handshake failed: knownhosts: key is unknown (File: /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/theme_add.go, Line: 75)
2022/05/17 13:08:46 errs.go:57: Can't get HEAD: reference not found
reference not found (File: /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/theme_add.go, Line: 84)
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0xd1bf25]

goroutine 1 [running]:
github.com/go-git/go-git/v5/plumbing.(*Reference).Hash(...)
	/home/jimafisk/go/pkg/mod/github.com/go-git/go-git/v5@v5.2.0/plumbing/reference.go:183
github.com/plentico/plenti/cmd.getCommitHash(0xc00009cb40, 0x18, 0x7ffd3da10f40)
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/theme_add.go:87 +0x125
github.com/plentico/plenti/cmd.glob..func6(0x25ce2c0, 0xc0000396e0, 0x1, 0x2)
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/site.go:103 +0x4b8
github.com/spf13/cobra.(*Command).execute(0x25ce2c0, 0xc0000396c0, 0x2, 0x2, 0x25ce2c0, 0xc0000396c0)
	/home/jimafisk/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:856 +0x2c2
github.com/spf13/cobra.(*Command).ExecuteC(0x25cddc0, 0xc000000180, 0x200000003, 0xc000000180)
	/home/jimafisk/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
	/home/jimafisk/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
github.com/plentico/plenti/cmd.Execute()
	/home/jimafisk/Projects/jantcu/plentico/plenti/cmd/root.go:58 +0x31
main.main()
	/home/jimafisk/Projects/jantcu/plentico/plenti/main.go:7 +0x25

Then doing:

  • git clone git@github.com:plenti-themes/compendium.git
  • When prompted with Are you sure you want to continue connecting (yes/no/[fingerprint])? I said yes
  • That returned Warning: Permanently added 'github.com,140.82.112.4' (ECDSA) to the list of known hosts. and added the entry into ~/.ssh/known_hosts
  • Finally plenti new site my-site --theme=git@github.com:plenti-themes/bigspring worked ✔️

So ultimately you just need your ~/.ssh/known_hosts in working order. Unfortunately as it stands currently, Plenti will not help you do that. If you have not previously added an "ECDSA key fingerprint" for the host (by manually cloning the repo), it won't let you clone via the Plenti theme commands. This needs to be corrected, because the whole point is to allow users to not have to think about the Git mechanics that are happening in the background.

@jimafisk
Copy link
Member

If I clear the contents of ~/.ssh/known_hosts I can still get this working per go-git/go-git#411 (comment):

  1. ssh-keyscan github.com >> ~/.ssh/known_hosts
  2. plenti new site my-site --theme=git@github.com:plenti-themes/bigspring

Does something like that work for you @stephanieluz?

@dougwinsby
Copy link

Thank you @jimafisk for researching this. I haven't used ssh keys with github under linux before (I'm a Windows guy), so this is new to me.

Unfortunately, I was unable to get things working using your suggestions. I keep getting the permission denied error:

connect: permission denied 2022/05/17 13:17:04 errs.go:57: Can't clone theme repository: error creating SSH agent: "Error connecting to SSH_AUTH_SOCK: dial unix /run/user/1000/keyring/ssh: connect: permission denied" error creating SSH agent: "Error connecting to SSH_AUTH_SOCK: dial unix /run/user/1000/keyring/ssh: connect: permission denied" (File: /home/runner/work/plenti/plenti/cmd/theme_add.go, Line: 75) 2022/05/17 13:17:04 errs.go:57: Can't get HEAD: reference not found reference not found (File: /home/runner/work/plenti/plenti/cmd/theme_add.go, Line: 84) panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x18 pc=0x986565]

I'm sure it's a problem on my end, but I was able to clone manually and ssh -T git@github.com returns successfully.

Conceptually, I'm struggling with the usefulness of including a theme, though. While I'd like bug fixes from an embedded theme, I wouldn't want an external change to break my site. I think I will just clone a theme as a starting point, and take it from there.

(BTW, I really like this project... thank you for your work on it.)

@stephanieluz
Copy link
Collaborator Author

Unfortunately still getting the error too. I checked and the ~/.ssh/known_hosts file exists on my system. I also tried setting these permissions:

  • chmod 755 ~/.ssh
  • chmod 644 ~/.ssh/known_hosts

But it still returns Can't clone theme repository: unable to find any valid known_hosts file, set SSH_KNOWN_HOSTS env variable

@jimafisk
Copy link
Member

Thanks for testing @dougwinsby and @stephanieluz. I'm thinking that running the git clone over SSH is more trouble than it's worth. Since the theme repos are public, we should be able to use HTTPS without having to enter usernames / passwords.

Does something like this work instead:

plenti new site my-site --theme=https://github.com/plenti-themes/bigspring.git

@dougwinsby
Copy link

Yes! --theme=https://github.com/plenti-themes/bigspring.git worked perfectly. Thank you.

@stephanieluz
Copy link
Collaborator Author

Woo that worked!

@jimafisk
Copy link
Member

Ok great! I'll update the documentation to reflect this, I think it'll be easier for almost everyone.

@dougwinsby to answer your questions:

Conceptually, I'm struggling with the usefulness of including a theme, though.

The main advantage is to give the theme creator the ability to push out changes in a centralized way. If 100 people clone a theme and edit it directly, the theme creator would have to work with them individually to accommodate a bug fix, but with themes they can push it once and everyone can get the benefit. You don't need a theme though, you could always watch the original repository yourself and manually pull in any changes you want, or go your own way completely.

The Plenti API still changes from time to time since we're not at a stable 1.0 release yet, so themes can help you avoid having to pay attention to our changelog. Alternatively if we update the API and it breaks your site, you can always lock the version of Plenti you're using in CI to an older version so your site continues to build successfully (all versions of Plenti are available on our dockerhub).

While I'd like bug fixes from an embedded theme, I wouldn't want an external change to break my site.

Themes should only update when you manually pull the changes into your project (i.e. plenti theme update THEME). You can always lock a theme at a specific commit if breaking changes are introduced in the future.

I think I will just clone a theme as a starting point, and take it from there.

This is a perfectly valid approach. Every theme is simply a Plenti website and every Plenti website can be used as a theme. If you don't want upstream changes, simply using another Plenti site as a starting point is the approach with the least overhead.

@jimafisk
Copy link
Member

Docs are updated: plentico/plenti.co@3b08719

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants