Repository: Shopify/shopify-cli (Ruby)

Issue:
[Bug] Cannot Create New Rails Application
### Please confirm that you have:

- [X] Searched [existing issues](https://github.com/Shopify/shopify-cli/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.)
- [X] Reproduced the issue in [the latest CLI version](https://github.com/Shopify/shopify-cli/releases).

### What type of project are you working on?

app

### Expected behavior

`shopify app create rails` should create a new rails based application

### Actual behavior

The installation is bombing after the database selection

### Stack trace

```shell
/usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/environment.rb:14:in `ruby_version': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/services/app/create/rails_service.rb:113:in `check_ruby'
        from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/services/app/create/rails_service.rb:105:in `check_dependencies'
        from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/services/app/create/rails_service.rb:44:in `call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/services/base_service.rb:5:in `call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/commands/app/create/rails.rb:22:in `call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/command/sub_command.rb:16:in `call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/command.rb:27:in `call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/command.rb:27:in `call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/core/executor.rb:17:in `block (2 levels) in call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/executor.rb:37:in `block (2 levels) in with_logging'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-ui/lib/cli/ui/stdout_router.rb:169:in `with_id'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/executor.rb:36:in `block in with_logging'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-ui/lib/cli/ui.rb:176:in `log_output_to'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/executor.rb:35:in `with_logging'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/core/executor.rb:16:in `block in call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/executor.rb:45:in `block (2 levels) in with_traps'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/executor.rb:55:in `twrap'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/executor.rb:44:in `block in with_traps'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/executor.rb:55:in `twrap'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/executor.rb:43:in `with_traps'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/core/executor.rb:15:in `call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/core/entry_point.rb:24:in `block in call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/core/monorail.rb:26:in `log'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/lib/shopify_cli/core/entry_point.rb:23:in `call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/bin/shopify:50:in `block (2 levels) in <top (required)>'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb:75:in `handle_abort'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/vendor/deps/cli-kit/lib/cli/kit/error_handler.rb:21:in `call'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/bin/shopify:49:in `block in <top (required)>'
	from /usr/local/Cellar/shopify-cli/2.15.0/gems/shopify-cli-2.15.0/bin/shopify:59:in `<top (required)>'
	from /usr/local/bin/shopify:7:in `load'
	from /usr/local/bin/shopify:7:in `<main>'
```


### Reproduction steps

1. `shopify app create rails`
2. Login
3. Enter App Name
4. Select Public App
5. Select your organization
6. Select your database (verified with either SQLite default or PostgreSQL selection)

### Operating System

macOS, Monteray 12.3, Apple Silicon

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

2.15.0

### Shell

iTerm2 w/ ZSH

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

2.7.5 & 3.10

### What language and version are you using in your application?

Verified with Ruby 2.7.5 and 3.1.0


Discussion:
Hi! This is a bug on v2.15.0, it will be fixed in the next release. In the meanwhile, you can use the previous version (2.14.0). Sorry for the inconvenience.
Awesome thanks!



Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 11fd516b70..1abc1430fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@ From version 2.6.0, the sections in this file adhere to the [keep a changelog](h
 
 ### Fixed
 * [#1874](https://github.com/Shopify/shopify-cli/pull/1874): Make ngrok errors more robust and helpful
+* [#2172](https://github.com/Shopify/shopify-cli/pull/2172): Fix Ruby check for Rails app creation
 
 ## Version 2.15.0
 
diff --git a/lib/shopify_cli/services/app/create/rails_service.rb b/lib/shopify_cli/services/app/create/rails_service.rb
index d7fc1e6dd7..e8da15a563 100644
--- a/lib/shopify_cli/services/app/create/rails_service.rb
+++ b/lib/shopify_cli/services/app/create/rails_service.rb
@@ -108,7 +108,7 @@ def check_dependencies
           end
 
           def check_ruby
-            ruby_version = Environment.ruby_version(context)
+            ruby_version = Environment.ruby_version(context: context)
             return if ruby_version.satisfies?("~>2.5") || ruby_version.satisfies?("~>3.1.0")
             context.abort(context.message("core.app.create.rails.error.invalid_ruby_version"))
           end


Test patch:
diff --git a/test/shopify-cli/services/app/create/rails_service_test.rb b/test/shopify-cli/services/app/create/rails_service_test.rb
index b4dfac3848..c5b0838fcf 100644
--- a/test/shopify-cli/services/app/create/rails_service_test.rb
+++ b/test/shopify-cli/services/app/create/rails_service_test.rb
@@ -33,12 +33,12 @@ def setup
           end
 
           def test_will_abort_if_bad_ruby
-            Environment.expects(:ruby_version).returns(Semantic::Version.new("2.3.7"))
+            Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.3.7"))
             assert_raises ShopifyCLI::Abort do
               call_service
             end
 
-            Environment.expects(:ruby_version).returns(Semantic::Version.new("3.1.0"))
+            Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("3.1.0"))
             assert_raises ShopifyCLI::Abort do
               call_service
             end
@@ -50,7 +50,7 @@ def test_can_create_new_app_with_rails_7
             gem_path = create_gem_path_and_binaries
             ::Rails::Gem.stubs(:gem_home).returns(gem_path)
 
-            Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
+            Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
             ::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
             ::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
             expect_rails_version("7.0.1")
@@ -101,7 +101,7 @@ def test_can_create_new_app
             gem_path = create_gem_path_and_binaries
             ::Rails::Gem.stubs(:gem_home).returns(gem_path)
 
-            Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
+            Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
             ::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
             ::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
             expect_rails_version("6.1.4")
@@ -154,7 +154,7 @@ def test_can_create_new_app_with_db_flag
             gem_path = create_gem_path_and_binaries
             ::Rails::Gem.stubs(:gem_home).returns(gem_path)
 
-            Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
+            Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
             ::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
             ::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
             expect_rails_version("6.1.4")
@@ -203,7 +203,7 @@ def test_can_create_new_app_with_rails_opts_flag
             gem_path = create_gem_path_and_binaries
             ::Rails::Gem.stubs(:gem_home).returns(gem_path)
 
-            Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
+            Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
             ::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
             ::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
             expect_rails_version("6.1.4")
@@ -253,7 +253,7 @@ def test_create_fails_if_path_exists
             gem_path = create_gem_path_and_binaries
             ::Rails::Gem.stubs(:gem_home).returns(gem_path)
 
-            Environment.expects(:ruby_version).returns(Semantic::Version.new("2.5.0"))
+            Environment.expects(:ruby_version).with(context: @context).returns(Semantic::Version.new("2.5.0"))
             ::Rails::Gem.expects(:install).with(@context, "rails", nil).returns(true)
             ::Rails::Gem.expects(:install).with(@context, "bundler", "~>2.0").returns(true)
             Dir.stubs(:exist?).returns(true)