简体   繁体   中英

How do I avoid bootsnap and railties to cause this error?

----UPDATE

I have cloned the repo in an other directory and went throw the all process again, this time though I noticed that the issue comes out only after using:

bundle install --deployment --without development test

if I simply use bundle install I can rails c with no problems.

why is this happenign? is importnat to use the flags? I did just because in the guide on how to deploy Rails app

----UPDATE

I am trying to deploy a ruby app on Ubuntu. I have run once the same repo correctly by rails c in the wrong location. Then I did all the same steps in teh right location ( var/www/app/code ) but when I run rails c I run in this problems:

user@cardano-db-sync:/var/www/swan/code$ rails c                                                                                                      
Traceback (most recent call last):                                                                                                                                                           
        80: from bin/rails:9:in `<main>'                                                                                                                                                     
        79: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
        78: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
        77: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
        76: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
        75: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'                  
        74: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/commands.rb:18:in `<main>'                                
        73: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/command.rb:50:in `invoke'                                                             
        72: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/command/base.rb:69:in `perform'                                                        
        71: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
        72: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/command/base.rb:69:in `perform'                                                         [0/1955]
        71: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'                                                                                   
        70: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'                                                                  
        69: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'                                                                                 
        68: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/commands/console/console_command.rb:101:in `perform'                                            
        67: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/command/actions.rb:15:in `require_application_and_environment!'                                 
        66: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/command/actions.rb:28:in `require_environment!'                                                 
        65: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/application.rb:360:in `require_environment!'                                                    
        64: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `require'                                                  
        63: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:299:in `load_dependency'                                          
        62: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `block in require'                                         
        61: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'                                                                      
        60: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'                                     
        59: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'                   
        58: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'                                      
        57: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'          
        56: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'                                     
        55: from /var/www/swan/code/config/environment.rb:5:in `<main>'                       
        54: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/application.rb:384:in `initialize!'                                                             
        53: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:60:in `run_initializers'                                                       
        52: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'                                                                                             
        51: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'                                                                                             
        50: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'                                                                      
        49: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:347:in `call'    
        48: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:347:in `each'    
        47: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'                                                             
        46: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:415:in `each_strongly_connected_component_from'                                                                 
        45: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:415:in `call'    
        44: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:50:in `tsort_each_child'                                                       
        43: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:50:in `each'                                                                   
        42: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:421:in `block in each_strongly_connected_component_from'                                                        
        41: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'                                                                 
        40: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'                                             
        39: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'                                                  
        38: from /home/user/.rvm/rubies/ruby-2.6.1/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'                                                                                    
        37: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:61:in `block in run_initializers'                                              
        36: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:32:in `run'                                                                    
        35: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/initializable.rb:32:in `instance_exec'                                                          
        34: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/engine.rb:570:in `block in <class:Engine>'                                                      
        33: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/engine.rb:570:in `each'                                                                         
        32: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/engine.rb:571:in `block (2 levels) in <class:Engine>'                                           
        31: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `require'                                                  
        30: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:299:in `load_dependency'                                          
        29: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `block in require'                                         
        28: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'                                                                      
        27: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'                                     
        26: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'                   
        25: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'                                      
        24: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'          
        23: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'                                     
        22: from /var/www/swan/code/config/environments/development.rb:1:in `<main>'          
        21: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/railtie.rb:234:in `configure'                                                                   
        20: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/railties-6.1.3.1/lib/rails/railtie.rb:234:in `instance_eval'                                                               
        19: from /var/www/swan/code/config/environments/development.rb:51:in `block in <main>'                                                                                               
        18: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `require'                                                  
        17: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:299:in `load_dependency'                                          
        16: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `block in require'                                         
        15: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'                                                                      
        14: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'                                     
        13: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'                   
        12: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'                                      
        11: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'          
        10: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
         9: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/evented_file_update_checker.rb:6:in `<main>'                                      
         8: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `require'                                                  
         7: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:299:in `load_dependency'     
         6: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.3.1/lib/active_support/dependencies.rb:332:in `block in require'                      
         5: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.4.2/lib/zeitwerk/kernel.rb:34:in `require'                                
         4: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require'                           
         3: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
         2: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register'
         1: from /var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- listen (LoadError)

I have bundle install used many gem install.. but still can'f figure out what is wrong.. also I am using rvm use 2.6.1 so I don;t understand why ruby/2.6.0 appears in there.

Anyway here is my gemfile:

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby '2.6.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.1.3'
# Use postgresql as the database for Active Record
gem 'pg', '>= 0.18', '< 2.0'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
# gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', require: false

gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f'

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
gem 'rack-cors'

gem 'jsonapi-serializer'

gem 'jwt'

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'seed_dump'
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'pry'
end

group :development do
  gem 'listen', '~> 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'rails-erd'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Your error is in the last line;

/var/www/swan/code/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- listen (LoadError)

bundle install --deployment --without development test command install only production and general gems. Does not install the development or test gems. Rails read environment variables RAILS_ENV for the setting environment. RAILS_ENV variable if not set rails default accept development. And bundler try to load all gems + development group gems. But bundle install --deployment --without development test command only install production and general gems. So listen gem is not installed because listen gem in development group. RAILS_ENV=production bin/rails c command not throw error because not try to load development gems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM