Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

[Bug]: NoMethodError: undefined method `shop' for nil:NilClass #2059

Closed
2 tasks done
owenmcateer opened this issue Feb 15, 2022 · 16 comments · Fixed by #2114
Closed
2 tasks done

[Bug]: NoMethodError: undefined method `shop' for nil:NilClass #2059

owenmcateer opened this issue Feb 15, 2022 · 16 comments · Fixed by #2114
Labels
area:theme type:bug Something isn't working

Comments

@owenmcateer
Copy link

Please confirm that you have:

  • Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • Reproduced the issue in the latest CLI version.

What type of project are you working on?

theme

Expected behavior

Expecting shopify theme serve to server the current theme.

Actual behavior

shopify theme serve
✗ An unexpected error occured.
	To submit an issue include the stack trace.
	To print the stack trace, add the environment variable SHOPIFY_CLI_STACKTRACE=1.

? Send an anonymized error report to Shopify? (You chose: Yes, send)

Stack trace

/Library/Ruby/Gems/2.6.0/gems/shopify-cli-2.11.2/lib/shopify_cli/theme/dev_server.rb:83:in `rescue in start'
/Library/Ruby/Gems/2.6.0/gems/shopify-cli-2.11.2/lib/shopify_cli/theme/dev_server.rb:29:in `start'
/Library/Ruby/Gems/2.6.0/gems/shopify-cli-2.11.2/lib/project_types/theme/commands/serve.rb:21:in `call'
/Library/Ruby/Gems/2.6.0/gems/shopify-cli-2.11.2/lib/shopify_cli/command/sub_command.rb:16:in `call'
/Library/Ruby/Gems/2.6.0/gems/shopify-cli-2.11.2/lib/shopify_cli/command.rb:27:in `call'

Reproduction steps

After install shopify-cli I ran:

  1. shopify login --store=MYSTORE
  2. shopify server

Operating System

universal.x86_64-darwin21

CLI version (run shopify version if you're not sure)

2.11.2

Shell

/bin/zsh

Ruby version (run ruby -v if you're not sure)

2.6.8p205

What language and version are you using in your application?

No response

@owenmcateer owenmcateer added the type:bug Something isn't working label Feb 15, 2022
@Dima34
Copy link

Dima34 commented Feb 17, 2022

Same problem

@kilgore5
Copy link
Contributor

Looking into this...

for the record the error message you're probably supposed to see is:

You are not authorized to edit themes on [ STORE ].
Make sure you are a user of that store, and allowed to edit themes.

@owenmcateer
Copy link
Author

I can confirm I have full access to edit the store and theme.

@Dima34
Copy link

Dima34 commented Feb 17, 2022

  • Tip from Themes Getting started docs. It helps me "
  • You can't use Shopify CLI with development stores if you only have Partner staff member access. If you want to use Shopify CLI to work on a development store, then you should be the store owner or create a staff account on the store.

If you're the store owner, then you need to log in to the store directly using the store URL at least once (for example, using {shop}.myshopify.com/admin) before you log in using Shopify CLI. Logging in to the Shopify admin directly connects the development store with your Shopify login.

  • "

kilgore5 pushed a commit to kilgore5/shopify-cli that referenced this issue Feb 18, 2022
- potentially addresses Shopify#2059, where user is logged in but they have no theme edit permissions (or otherwise aren't correctly authenticated)
- after updates in Shopify#2020, there is no theme object if there is a permissions error so we need to create a new generic one to get access to the shop name for the error message
- additionally I noticed that the other theme commands in this same case were raising 403 errors rather than showing a correct error message
@sc00
Copy link

sc00 commented Feb 21, 2022

Same issue. I'm the store owner and have logged into the CMS of the store.

/opt/homebrew/Cellar/shopify-cli/2.11.2/gems/shopify-cli-2.11.2/lib/shopify_cli/theme/dev_server.rb:83:in rescue in start': undefined method shop' for nil:NilClass (NoMethodError)

@sc00
Copy link

sc00 commented Feb 21, 2022

Creating a staff member with a different email address solved it for me.

@CHEWX
Copy link

CHEWX commented Feb 23, 2022

I have the same problem, but I create a staff member with a different email address as above, however this is a workaround, it's not solved!

@SebastianKut
Copy link

What worked for me was:

  1. Log out of your shopify account in the browser
  2. Log in to {shop}.myshopify.com/admin
  3. Then log in through shopify CLI "shopify login --store {shop}.myshopify.com/admin"

For some reason I had to repeat all the steps above couple of times

@vhtellez
Copy link

vhtellez commented Mar 5, 2022

What worked for me:

  1. Command "shopify logout"
  2. Command "shopify login --store=STORE"
  3. Command "shopify theme serve"

@p8ul
Copy link

p8ul commented Mar 8, 2022

For my case, I had to downgrade shopify-cli.

gem uninstall shopify-cli

gem install shopify-cli -v 2.7.4 

@kilgore5 kilgore5 mentioned this issue Mar 11, 2022
4 tasks
@karreiro karreiro linked a pull request Mar 11, 2022 that will close this issue
4 tasks
@karreiro
Copy link
Contributor

Resolved by #2114.

@karreiro
Copy link
Contributor

(If this issue gets re-opened, I will re-assign it to me @kilgore5. But, for now, it seems like you've solved it! 🎉)

@BryanCastro
Copy link

(If this issue gets re-opened, I will re-assign it to me @kilgore5. But, for now, it seems like you've solved it! 🎉)

Nope still broken, not resolved

@karreiro
Copy link
Contributor

Thanks for reporting it, @BryanCastro. Could you please share the stack trace you're facing and the Shopify CLI version?

@CrawlingMango
Copy link

CrawlingMango commented May 12, 2022

What worked for me:

  1. Command "shopify logout"
  2. Command "shopify login --store=STORE"
  3. Command "shopify theme serve"

worked for me, I tried to run "shopify login" without logging out my other shopify account

@Mihai-github
Copy link

Mihai-github commented Feb 1, 2023

Hi, in my case specifying the exact store I'm trying to login helped:
shopify login --store=yourstore.myshopify.com

For example, if you have already logged into your account and it is not working you can try this:

Command "shopify logout"
Command "shopify login --store=yourstore.myshopify.com"
Command "shopify theme serve"

@kilgore5 kilgore5 removed their assignment Feb 10, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
area:theme type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.