Shopify / cli

Build apps, themes, and hydrogen storefronts for Shopify
https://shopify.dev
MIT License
424 stars 126 forks source link

theme extensions deploy fails: incompatible architecture #150

Closed shaibt closed 1 year ago

shaibt commented 2 years ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

Extension

Expected behavior

Built a simple theme app extension scaffold using the shopify cli. Here is the single app block liquid file in the project (extensions/testing-tooling-ext/blocks/app-block.liquid)

    <span style="color: {{ block.settings.color }}">
    App blocks let you build powerful integrations with online store themes!
    </span>

    {% schema %}
      {
        "name": "Hello World",
        "target": "section",
        "settings": [
            { "label": "Color", "id": "color", "type": "color", "default": "#000000" }
        ]
      }
    {% endschema %}

Successful in creating app and connecting it to our app in the partners dashboard. Next step is to deploy but deploy fails.

Actual behavior

npm run deploy (and also npm run build) fail with this error:

    > shopify app build

    ✔ Dependencies installed
    theme_extensions | Building theme extensions...
    theme_extensions | Installing theme dependencies...
    theme_extensions | Installed theme dependencies!
    theme_extensions | bundler: failed to load command: theme-check (/Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/bin/theme-check)
    theme_extensions | /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.6-arm64-darwin/lib/nokogiri/extension.rb:30:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)

We are running Shopify CLI 3.1.0 installed using npm:

    > shopify "version"

    Current Shopify CLI version: 3.1.0

Also have on same machine "older" shopify CLI (I think installed through the VS Code liquid extension?)

    shopify-cli (global that includes theme-check) 2.20.0
    theme-check (installed with shopify-cli) 1.10.3

One line that stood out from full error log (see below full stack):

    /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.6-arm64-darwin/lib/nokogiri/extension.rb:7:
    in `require_relative': dlopen(/Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.6-arm64-darwin/lib/nokogiri/2.6/nokogiri.bundle, 0x0009): 
    tried: '/Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.6-arm64-darwin/lib/nokogiri/2.6/nokogiri.bundle' 

    (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h'))

    - /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.6-arm64-darwin/lib/nokogiri/2.6/nokogiri.bundle (LoadError)

Stack trace

    Command failed with exit code 1: bundle exec theme-check /Users/***/Developer/shai-test-app/extensions/testing-tooling-ext -C :theme_app_extension
        bundler: failed to load command: theme-check (/Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/bin/theme-check)
        /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri/extension.rb:30:in `require': cannot load such file -- nokogiri/nokogiri (LoadError)
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri/extension.rb:30:in `rescue in <top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri/extension.rb:4:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri.rb:10:in `require_relative'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri.rb:10:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/lib/theme_check/html_visitor.rb:2:in `require'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/lib/theme_check/html_visitor.rb:2:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/lib/theme_check.rb:45:in `require_relative'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/lib/theme_check.rb:45:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/exe/theme-check:4:in `require'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/exe/theme-check:4:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/bin/theme-check:23:in `load'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/bin/theme-check:23:in `<top (required)>'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:58:in `load'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:58:in `kernel_load'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:23:in `run'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli.rb:483:in `exec'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli.rb:31:in `dispatch'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli.rb:25:in `start'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/exe/bundle:48:in `block in <top (required)>'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/exe/bundle:36:in `<top (required)>'
            from /usr/local/bin/bundle:23:in `load'
            from /usr/local/bin/bundle:23:in `<main>'
        /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri/extension.rb:7:in `require_relative': dlopen(/Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri/2.6/nokogiri.bundle, 0x0009): tried: '/Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri/2.6/nokogiri.bundle' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64h')) - /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri/2.6/nokogiri.bundle (LoadError)
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri/extension.rb:7:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri.rb:10:in `require_relative'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/nokogiri-1.13.7-arm64-darwin/lib/nokogiri.rb:10:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/lib/theme_check/html_visitor.rb:2:in `require'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/lib/theme_check/html_visitor.rb:2:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/lib/theme_check.rb:45:in `require_relative'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/lib/theme_check.rb:45:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/exe/theme-check:4:in `require'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/gems/theme-check-1.10.3/exe/theme-check:4:in `<top (required)>'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/bin/theme-check:23:in `load'
            from /Users/***/Library/Caches/shopify-cli-nodejs/vendor/theme-check/1.10.3/ruby/2.6.0/bin/theme-check:23:in `<top (required)>'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:58:in `load'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:58:in `kernel_load'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli/exec.rb:23:in `run'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli.rb:483:in `exec'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli.rb:31:in `dispatch'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/cli.rb:25:in `start'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/exe/bundle:48:in `block in <top (required)>'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/lib/bundler/friendly_errors.rb:120:in `with_friendly_errors'
            from /Library/Ruby/Gems/2.6.0/gems/bundler-2.3.17/exe/bundle:36:in `<top (required)>'
            from /usr/local/bin/bundle:23:in `load'
            from /usr/local/bin/bundle:23:in `<main>'

Reproduction steps

  1. build simple theme app extension app
  2. run npm run deploy/build

Operating System

OSX Montery on i7 MacbOok Pro

Shopify CLI version (check your project's package.json if you're not sure)

3.1.0

Shell

bash

Node version (run node -v if you're not sure)

v14.19.3

What language and version are you using in your application?

Node

mirkocesaro commented 2 years ago

Hi @shaibt , the problem is Ruby on your machine. I have the same problem and after a while ( I also found your message on shopify community too) I fixed it in this way:

I installed rbenv:

brew install rbenv ruby-build

download ruby 3.1.2 env with it

rbenv install 3.1.2

set the environment downloaded:

rbenv global 3.1.2

copying the init command printed by this: rbenv init

and added to my profile. I am using zsh so:

cd ~
echo 'eval "$(rbenv init -)"' >> .zshrc

now If you try

ruby -v

you should find something like:

ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [x86_64-darwin21]

You're almost ready :)

If you try

npm run deploy you don't have the error anymore but there should be a missing gem

   Bundler version 2.3.7 is not supported

    What to try:
    To update to the latest version of Bundler, run gem install bundler

so:

gem install bundler

and now you are ready to build and deploy.

npm run deploy
...
Running validation…

Pushing your code to Shopify…

✅ Success! Deployed to Shopify.

  Summary:
    • theme-block is deployed to Shopify but not yet live
...

I hope this will work for you too

Cheers, Mirko

amcaplan commented 2 years ago

Hi @shaibt, thanks for opening up an issue!

We've seen that error before on CLI2 as well. It often relates to nokogiri being installed on 1 system architecture, then copied to another.

Can you please try this:

  1. Remove the installed versions of theme-check and nokogiri with rm -rf /Users/***/Library/Caches/shopify-cli-nodejs/vendor (replacing *** with your username)
  2. Try deploying again (which will reinstall those dependencies)
  3. Let us know what happens!
mirkocesaro commented 2 years ago

Hi @amcaplan, I can answer your question too. I had the same issue before and I completely removed my shopify-cli-nodejs under the Caches folder, but the deploy command reinstalled the same dependencies.

Also, as you can see from @shaibt stack trace, its Cache folder has Ruby 2.6.0 in the path.

I know that Shopify CLI 2.x requires Ruby 2.7 or higher, and macOS has 2.6.0 installed by default. Could Ruby 2.7.0 be a requirement for Shopify CLI 3?

amcaplan commented 2 years ago

Note that based on this issue it may be that this is a problem with MacOS system Ruby not identifying its platform in the way a normally installed Ruby would. So it may be best to install another version of Ruby (ideally a modern one) using chruby, rbenv, etc., then delete the directory I mentioned before (to clear nokogiri from your system and force reinstall) and see if that resolves the issue for you.

If this is something that plagues many users, we'll need to think about updating our install instructions to insist that system Ruby not be used. We could also detect the use of system Ruby and warn users in the CLI itself.

/cc @pepicrft

shaibt commented 2 years ago

Many thanks @mirkocesaro - I was able to build and deploy the extension. Only way I was able to solve this was to upgrade to newer Ruby version. Once that was done everything worked smoothly. The default ruby version installed (at least on my Mac) was 2.6 and had the platform ambiguity issue.

I think the solution @amcaplan suggested is worth while - but I'd check what default Ruby versions are shipped by default on which OSX versions. I am using Monterey but my Mac is at least 4 years old.

github-actions[bot] commented 1 year ago

This issue seems inactive. If it's still relevant, please add a comment saying so. Otherwise, take no action. → If there's no activity within a week, then a bot will automatically close this. Thanks for helping to improve Shopify's dev tooling and experience.

teknology commented 11 months ago

I have a similar issue.

Error coming frombundle exec theme-check /Users/Tek/Documents/Sites/Shopify/kit-status/extensions/kit-status-check -C :theme_app_extension`

Command failed with exit code 1: bundle exec theme-check /Users/Tek/Documents/Sites/Shopify/kit-status/extensions/kit-status-check -C :theme_app_extension bundler: failed to load command: theme-check (/usr/local/lib/ruby/gems/[ruby-version]/bin/theme-check) /usr/local/lib/ruby/gems/[ruby-version]/gems/theme-check-1.15.0/lib/theme_check/tags.rb:158:in `block in ': uninitialized constant Liquid::Render (NameError)

    (\s+(with|#{Liquid::Render::FOR})\s+(#{Liquid::QuotedFragment}+))?
                              ^^^^^

`