rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

Error Deploying 5.0.0 Without sprockets-jets Gem #681

Closed djolereject closed 11 months ago

djolereject commented 11 months ago

Checklist

My Environment

Software Version
Operating System MacOS
Jets 5.0.0
Ruby 3.2.0

Expected Behaviour

When I run jets deploy, it should deploy without any issues.

Current Behavior

I get error right after bundling of gems is done. Here is the backtrace:

jets deploy backtrace Tidying project: removing ignored files to reduce package size. => rsync -a --links /tmp/jets/scraper/stage/code/vendor/gems/ruby/3.2.0/ /tmp/jets/scraper/stage/opt/ruby/gems/3.2.0/ => Replacing compiled gems with AWS Lambda Linux compiled versions: /tmp/jets/scraper/stage/opt Checking project for compiled gems... /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/turbine/configuration.rb:96:in `method_missing': undefined method `assets' for #, @generators=#, @middleware=#, @javascript_path="javascript", @api=#false, :authorization_type=>"NONE", :authorizers=>#"Auth"}>, :auto_replace=>nil, :binary_media_types=>["multipart/form-data"], :cors=>false, :endpoint_policy=>nil, :endpoint_type=>"EDGE", :vpc_endpoint_ids=>nil}>, @api_mode=nil, @app=#nil}>, @build=#[]}>, @cfn=##"one_lambda_for_all_controllers", :resource_tags=>{}, :routes=>"one_apigw_method_for_all_routes"}>}>, @controllers=#nil}>, @deploy=##false, :batch_size=>10}>}>, @domain=#"", :endpoint_type=>"REGIONAL", :route53=>true}>, @environment=#, @events=##true, :table_namespace_separator=>"_"}>, :s3=>#true, :notification_configuration=>{:topic_configurations=>[{:events=>["s3:ObjectCreated:*"], :topic_arn=>"!Ref SnsTopic"}]}}>}>, @s3_event=#, @filter_parameters=[], @function=#{:size=>512}, :memory_size=>1536, :timeout=>30}>, @gems=#false, :disable=>false, :source=>"https://api.serverlessgems.com/api/v1"}>, @pro=#false}>, @helpers=#nil}>, @helpers_paths=["/Users/djole/work/pugbite/scraping/scraper/app/helpers"], @inflections=#{}}>, @lambda=#[]}>, @logger=#, @formatter=#, @logdev=#>, @binmode=false, @mon_data=#, @mon_data_owner_object_id=9460>>, @logging=#false}>, @mode="html", @prewarm=#true, :public_ratio=>3, :rate=>"30 minutes"}>, @routes=#true}>, @default_iam_policy=[{:Action=>["logs:*"], :Effect=>"Allow", :Resource=>"arn:aws:logs:eu-central-1:228342851134:log-group:/aws/lambda/scraper-dev-*"}, {:Action=>["s3:Get*", "s3:List*", "s3:HeadBucket"], :Effect=>"Allow", :Resource=>"arn:aws:s3:::scraper-dev-s3bucket-5im0n0e7mf0b*"}, {:Action=>["cloudformation:DescribeStacks", "cloudformation:DescribeStackResources"], :Effect=>"Allow", :Resource=>"arn:aws:cloudformation:eu-central-1:228342851134:stack/scraper-dev*"}], @managed_policy_definitions=[], @managed_iam_policy=["AWSLambda_FullAccess"], @encoding=#, @allow_concurrency=nil, @consider_all_requests_local=true, @filter_redirect=[], @hosts=[".localhost", #, #], @host_authorization={}, @public_file_server=#true, :index_name=>"index"}>, @force_ssl=false, @ssl_options={}, @session_store=:cookie_store, @time_zone="UTC", @beginning_of_week=:monday, @log_level=:debug, @cache_store=:null_store, @turbines_order=[:all], @relative_url_root=nil, @reload_classes_only_on_change=true, @file_watcher=ActiveSupport::FileUpdateChecker, @exceptions_app=nil, @autoflush_log=true, @log_formatter=#, @eager_load=false, @secret_key_base=nil, @api_only=false, @debug_exception_response_format=nil, @x=#, @enable_dependency_loading=false, @read_encrypted_secrets=false, @content_security_policy=nil, @content_security_policy_report_only=false, @content_security_policy_nonce_generator=nil, @content_security_policy_nonce_directives=nil, @require_master_key=false, @loaded_config_version=nil, @credentials=##, :key_path=>#}>, @disable_sandbox=false, @add_autoload_paths_to_load_path=true, @permissions_policy=nil, @rake_eager_load=false, @server_timing=true, @paths=#, @root={"app"=>#, @glob="{*,*/concerns}", @exclude=["assets", "javascript"], @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/assets"=>#, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/controllers"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/channels"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/helpers"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/models"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/mailers"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=true, @autoload=false, @load_path=false>, "app/views"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/functions"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/shared"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/shared/extensions"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/shared/functions"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "app/shared/resources"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=true>, "lib/assets"=>#, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib/tasks"=>#, @glob="**/*.rake", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/environments"=>#, @glob="development.rb", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/initializers"=>#, @glob="**/*.rb", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/locales"=>#, @glob="**/*.{rb,yml}", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/routes.rb"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/routes"=>#, @glob="**/*.rb", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db/migrate"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "db/seeds.rb"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "vendor"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=true>, "vendor/assets"=>#, @glob="*", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/database"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/secrets"=>#, @glob="secrets.yml{,.enc}", @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "config/environment"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "lib/templates"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "log"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public/javascripts"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "public/stylesheets"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>, "tmp"=>#, @glob=nil, @exclude=nil, @autoload_once=false, @eager_load=false, @autoload=false, @load_path=false>}>, @autoload_paths=[], @eager_load_paths=["/Users/djole/work/pugbite/scraping/scraper/app/controllers", "/Users/djole/work/pugbite/scraping/scraper/app/helpers", "/Users/djole/work/pugbite/scraping/scraper/app/jobs", "/Users/djole/work/pugbite/scraping/scraper/app/models", "/Users/djole/work/pugbite/scraping/scraper/app/services"], @autoload_once_paths=[], @webpacker=#, @session_options={:key=>"_main_session", :cookie_only=>true}> (NoMethodError) Did you mean? asset_host from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/builders/code_builder.rb:149:in `s3_base_url' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/builders/code_builder.rb:139:in `write_s3_base_url' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/builders/code_builder.rb:134:in `store_s3_base_url' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/builders/code_builder.rb:96:in `code_finish' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/builders/code_builder.rb:41:in `block in build' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/builders/code_builder.rb:37:in `chdir' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/builders/code_builder.rb:37:in `build' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/commands/deploy/deploy_command.rb:29:in `perform' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/command.rb:28:in `run' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/command/base.rb:101:in `perform' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/command.rb:48:in `invoke' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/commands.rb:17:in `' from :38:in `require' from :38:in `require' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/core_ext/kernel.rb:11:in `require' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/cli.rb:16:in `' from :38:in `require' from :38:in `require' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/lib/jets/core_ext/kernel.rb:11:in `require' from /Users/djole/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/jets-5.0.0/exe/jets:5:in `' from /Users/djole/.rbenv/versions/3.2.0/bin/jets:25:in `load' from /Users/djole/.rbenv/versions/3.2.0/bin/jets:25:in `
'

I have no idea what could cause this. I upgraded with jets-upgrade go and it looks like it works locally but deployment is always crashing.

Thanks!

tongueroo commented 11 months ago

Interesting. The assets config is provided a part of sprockets-jets engine. The jets-upgrade tool should have added that to your Gemfile.

https://github.com/rubyonjets/jets-upgrade/blob/afb78c598cb850094be61de70c08cee7ab3678f8/lib/jets_upgrade/rewrite/gemfile.rb#L15

Can you double check the Gemfile. Wondering if that is it right now. Hopefully that's it. If not, will have to dig into it further.

Thinking might add sprockets-jets as a gemspec requirement. Or change the way this is handled. 🤔

Also, can you try on the same system with a new jets project. jets new demo. Would like to see if it’s app or system specific. To be clear, interested in the bug either way.

djolereject commented 11 months ago

I'll get back to you with the answer if adding sprockets-jets to Gemfile resolvs an issue, but here is the Gemfile of fresh project:

source "https://rubygems.org"

gem "jets", "~> 5.0.0"

# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"
gem "sprockets-jets"
gem "importmap-jets"
gem "zeitwerk", ">= 2.6.12"

# development and test groups are not bundled as part of the deployment
group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'rack'
  gem 'puma'
end

group :test do
  gem 'rspec'
end
djolereject commented 11 months ago

Yeah, it's working now. Thanks!

tongueroo commented 11 months ago

Great to hear.

Wondering if should make some changes to allow it to work without sprockets-jets. Will have to let it simmer on the brain. 🤔 Closing this out.

tongueroo commented 11 months ago

In #686 made sprockets-jets optional