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

shopify app create rails w/ Rails 7 fails #1813

Closed
jbourassa opened this issue Dec 1, 2021 · 3 comments · Fixed by #1998
Closed

shopify app create rails w/ Rails 7 fails #1813

jbourassa opened this issue Dec 1, 2021 · 3 comments · Fixed by #1998

Comments

@jbourassa
Copy link
Contributor

jbourassa commented Dec 1, 2021

Issue summary

I tried creating a new Rails app and ran into a few issues. Turns out I had Rails 7 installed, thus

  1. The app was created in a --skip-spring, instead of using the name provided. Based on my quick experimentation, this behaviour changed in Rails 7 Fix: Fix rails new command for Rails 7 #1812
  2. bundle install failed because rails new picked up Rails 7 alpha, and the shopify_app gem does not support Rails 7. Not sure what the best fix would be here, either make shopify_app Rails 7 ready, or hardcode a Rails version in the CLI that we know works.

Expected behavior

The Rails app is created and it all just works.

Actual behavior

Bundle install fails:

✓ Adding shopify_app gem…
┏━━ Running bundle install… ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┃ Fetching gem metadata from https://rubygems.org/............
┃ Resolving dependencies...
┃ Bundler could not find compatible versions for gem "rails":
┃   In snapshot (Gemfile.lock):
┃     rails (= 7.0.0.alpha2)
┃
┃   In Gemfile:
┃     rails (~> 7.0.0.alpha2)
┃
┃     shopify_app (>= 17.0.3) was resolved to 17.1.1, which depends on
┃       rails (< 6.1, > 5.2.1)
┃
┃ Running `bundle update` will rebuild your snapshot from scratch, using only
┃ the gems in your Gemfile, which may resolve the conflict.
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ (2.26s)
✗ System call failed: ~/.gem/ruby/3.0.2/bin/bundle install

Steps to reproduce the problem

  1. Install Rails 7 (today, that's gem install rails --alpha)
  2. shopify app create rails
@jacobburde
Copy link

I'm running into the same problem. Is there a workaround?

@jbourassa
Copy link
Contributor Author

jbourassa commented Jan 31, 2022

I'm running into the same problem. Is there a workaround?

You might be able to edit Shopify CLI's code to specify Rails version, e.g. Rails 6.1.

  1. gem install rails -v '6.1.4.4'
  2. Edit either lib/shopify_cli/services/app/create/rails_service.rb or lib/project_types/rails/commands/create.rb (not sure which file is actually used). Instead of having it run rails new, force a specific rails version: rails _6.1.4.4_ new. Note that the underscores are required.

@jacobburde
Copy link

I'm running into the same problem. Is there a workaround?

You might be able to edit Shopify CLI's code to specify Rails version, e.g. Rails 6.1.

1. `gem install rails -v '6.1.4.4'`

2. Edit either [`lib/shopify_cli/services/app/create/rails_service.rb`](https://github.com/Shopify/shopify-cli/blob/8a280492c44d458c44fde3883f16ecfd494afdc4/lib/shopify_cli/services/app/create/rails_service.rb#L161) or [`lib/project_types/rails/commands/create.rb`](https://github.com/Shopify/shopify-cli/blob/8a280492c44d458c44fde3883f16ecfd494afdc4/lib/project_types/rails/commands/create.rb#L158) (not sure which file is actually used). Instead of having it run `rails new`, force a specific rails version: `rails _6.1.4.4_ new`. Note that the underscores are required.

Thanks for the help! This resolved the initial issue but I ran into this later on in the install.
┏━━ Running webpacker:install…
┃ rails aborted!
┃ Don't know how to build task 'webpacker:install' (See the list of available tasks with rails --tasks)

┃ (See full trace by running task with --trace)

┏━━ Error
┃ ✗ System call failed: rails webpacker:install
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

I think it has to do with ruby 3.0.3. After switching to ruby 2.7.5 the command shopify app create rails worked without issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants