Shopify / cli

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

[Bug]: Ruby environment not found in creating app theme extension #1585

Closed imprintNext-Payal closed 1 year ago

imprintNext-Payal commented 1 year ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

Extension, Theme

Expected behavior

Shopify app should be previewed with respective theme extension

Actual behavior

after running "npm run dev " , it shows ruby environment not found

Verbose output

I am working on app theme extension and as per the shopify CLI documentation ,have  successfully created an app using CLI and opt for integrating theme into it. Installed required packages with  ruby3.0+devkit but while executing to review the app with "npm run dev" -I am having issue as ruby environment not found .

Reproduction steps

1.Create a shopify app using CLI (follow create an app of shopify .dev docs with php as template language) 2.run the app to preview 3.start creating theme app extension (.dev docs->online store->theme app extension) 4.execute npm run dev after creating theme

Operating System

windows 11

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

3.44.1

Shell

No response

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

v18.14.2

What language and version are you using in your application?

PHP 8.1.12

Arkham commented 1 year ago

Hi there, could you share the verbose output of the command? There is not enough information for me to debug this issue.

imprintNext-Payal commented 1 year ago

Hi there, could you share the verbose output of the command? There is not enough information for me to debug this issue.

Screenshot 2023-03-09 174201

after creating the theme app extension and executing "npm run dev"

Arkham commented 1 year ago

It seems that the ruby environment was not installed correctly. Can you try running ruby -v? In my machine it says this:

PS C:\Users\arkham\Desktop\cli> ruby -v
ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x64-mingw32]

If it doesn't show this for you, can you try reinstalling Ruby? From https://rubyinstaller.org/downloads/ I can see that Ruby+Devkit 3.2.1-1 (x64) is available. I would try with that one.

imprintNext-Payal commented 1 year ago

It seems that the ruby environment was not installed correctly. Can you try running ruby -v? In my machine it says this:

PS C:\Users\arkham\Desktop\cli> ruby -v
ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x64-mingw32]

If it doesn't show this for you, can you try reinstalling Ruby? From https://rubyinstaller.org/downloads/ I can see that Ruby+Devkit 3.2.1-1 (x64) is available. I would try with that one. Screenshot 2023-03-09 192455

ruby version is showing perfectly , still I am reinstalling it

Arkham commented 1 year ago

Thanks, it would also be useful to see the verbose output when you run npm run dev -- --verbose

m-dad commented 1 year ago

I had the same issue on windows 10. Installed the latest version of Ruby 3.1.3p185 and restarted windows. It fixed the error

Arkham commented 1 year ago

We've merged a lot of Ruby improvements in 3.45.0. Closing this now, feel free to open new issues if they arise.

felixmpaulus commented 1 year ago

Same issue here... Cant seem to get it to work. It's a node app, why is Ruby even relevant? Would appreciate any help! :)

$ ruby -v
ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]
$ which -a ruby
/usr/bin/ruby

Running OSX Ventura 13.4

$ git push heroku master                               
Enumerating objects: 1266, done.
Counting objects: 100% (1266/1266), done.
Delta compression using up to 10 threads
Compressing objects: 100% (1155/1155), done.
Writing objects: 100% (1254/1254), 29.25 MiB | 36.93 MiB/s, done.
Total 1254 (delta 719), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (719/719), completed with 7 local objects.
remote: Updated 118 paths from b0ebfc1
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Building on the Heroku-22 stack
remote: -----> Using buildpack: heroku/nodejs
remote: -----> Node.js app detected
remote:        
remote: -----> Creating runtime environment
remote:        
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        YARN_PRODUCTION=true
remote:        NODE_OPTIONS=--max_old_space_size=4096
remote:        NODE_VERBOSE=false
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        
remote: -----> Installing binaries
remote:        engines.node (package.json):  >=18.x
remote:        engines.npm (package.json):   >=9.6.7
remote:        
remote:        Resolving node version >=18.x...
remote:        Downloading and installing node 20.2.0...
remote:        Bootstrapping npm >=9.6.7 (replacing 9.6.6)...
remote:        npm 9.7.1 installed
remote:        
remote: -----> Restoring cache
remote:        Cached directories were not restored due to a change in version of node, npm, yarn or stack
remote:        Module installation may take longer for this build
remote:        
remote: -----> Installing dependencies
remote:        Installing node modules
remote:        
remote:        added 1115 packages, and audited 1118 packages in 17s
remote:        
remote:        150 packages are looking for funding
remote:          run `npm fund` for details
remote:        
remote:        found 0 vulnerabilities
remote:        
remote: -----> Build
remote:        Running build
remote:        
remote:        > bbb-ab-3@1.0.0 build
remote:        > shopify app build
remote:        
remote: ╭─ error ──────────────────────────────────────────────────────────────────────╮
remote: │                                                                              │
remote: │  Ruby environment not found                                                  │
remote: │                                                                              │
remote: │  Make sure you have Ruby installed on your system. Documentation. (          │
remote: │  https://www.ruby-lang.org/en/documentation/installation/ )                  │
remote: │                                                                              │
remote: ╰──────────────────────────────────────────────────────────────────────────────╯
remote: 
remote: 
remote: -----> Build failed
remote:        
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:        
remote:        Some possible problems:
remote:        
remote:        - Dangerous semver range (>) in engines.node
remote:          https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:        
remote:        Love,
remote:        Heroku
remote:        
remote:  !     Push rejected, failed to compile Node.js app.
remote: 
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: 7a526c144d29815013143397f82515550883b609
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version 7a526c144d29815013143397f82515550883b609
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote: 
remote: Verifying deploy...
remote: 
remote: !       Push rejected to better-bullets.
remote: 
To https://git.heroku.com/better-bullets.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/better-bullets.git'
LouiseEH commented 1 year ago

@felixmpaulus I have the exact same error - were you able to solve it?

felixmpaulus commented 1 year ago

Yes, it was caused by the /extensions directory (no idea why).

Try the following: A Remove/Rename the /extensions directory and push again

or

B add a .slugignore file to your root with /extensions as the content (heroku will then ignore your extensions folder without the need to remove/rename it.

Hope I could help.

LouiseEH commented 1 year ago

@felixmpaulus Thanks! I ended up installing a more recent version of Ruby which helped

jcodeover commented 10 months ago

@felixmpaulus I have exact same issue. I tried adding '.slugignore' which passed the build but then my extension folder and code is not deployed which is pointless. Any ideas?

jcodeover commented 10 months ago

I removed ruby from my local system and got the same error so it indicates node.js is reliant on ruby. Now I need to work out how I can have this as part of the stack on heroku.

emmanueluwa commented 8 months ago

according to the docs: https://shopify.dev/docs/themes/tools/cli/install

my issue was i needed to install, Ruby+Devkit 3.0, installed using RubyInstaller for Windows (select the MSYS2 component and the MSYS2 base installation option)

npm run dev worked for me after downloading it