Git Product home page Git Product logo

Comments (18)

burke avatar burke commented on August 26, 2024 1

Yeah, I'm not really clear on how that would even be expected to work. It feels wrong for files to be included in that array in the first place, but I don't have enough context to deal with that upstream.

Anyway, I'll release a new bootsnap today that silently ignores this problem.

from bootsnap.

drewhamlett avatar drewhamlett commented on August 26, 2024 1

It works! Thanks so much

from bootsnap.

jules2689 avatar jules2689 commented on August 26, 2024

This is interesting, I'm not able to reproduce locally with ApplicationCable in Rails. Do you have an example app we can use? Failing that, can you post your Bootsnap.setup, Ruby Version, Rails Version, and OS version?

e.g.

require 'bootsnap'
Bootsnap.setup(
  cache_dir:            'tmp/cache', # Path to your cache
  development_mode:     true,
  load_path_cache:      true,        # Should we optimize the LOAD_PATH with a cache?
  autoload_paths_cache: true,        # Should we optimize ActiveSupport autoloads with cache?
  disable_trace:        true,       # Sets `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }`
  compile_cache_iseq:   true,        # Should compile Ruby code into ISeq cache?
  compile_cache_yaml:   true         # Should compile YAML into a cache?
)

Basically, I can see that we think it is a directory as we simply check for the / at the end here to save on system calls, then add it to the requireables instead of the dirs here, which causes the mtime check.

Can you think of any reason why bootsnap would load that file with a / suffix?

from bootsnap.

drewhamlett avatar drewhamlett commented on August 26, 2024

I turned off autoload_paths_cache: false and it booted with the action cable files in there. This was my original setup

require 'bootsnap'
Bootsnap.setup(
  cache_dir:            'tmp/cache', # Path to your cache
  development_mode:     true,
  load_path_cache:      true,        # Should we optimize the LOAD_PATH with a cache?
  autoload_paths_cache: true,        # Should we optimize ActiveSupport autoloads with cache?
  disable_trace:        true,       # Sets `RubyVM::InstructionSequence.compile_option = { trace_instruction: false }`
  compile_cache_iseq:   true,        # Should compile Ruby code into ISeq cache?
  compile_cache_yaml:   true         # Should compile YAML into a cache?
)

Rails 5.0.2
Ruby 2.4.0
OSX 10.12.3

I can't post a minimal example of the app unfortunately.

If I rename the files to something like LocationsChannelBlah and file name locations_channel_blah.rb everything works fine. It seems like the file ending in channel is causing a problem 🤔

LocationsChanel no extra n works fine. LocationsChannel doesn't

from bootsnap.

burke avatar burke commented on August 26, 2024

Can you open a console and run this? Sanitize the output if you need to, but I don't imagine it'll print much that you won't want to share.

cache = MessagePack.load(Snappy.inflate(File.read('tmp/cache/bootsnap-load-path-cache')))
keys = cache.keys.grep(/channels/)
keys.each { |k| m, e, d = cache[k]; puts [k, m, e.size, d].inspect }

from bootsnap.

burke avatar burke commented on August 26, 2024

It kind of looks like something is pushing a file as opposed to a directory onto ActiveSupport::Dependencies.autoload_paths. We could probably handle that better, but as far as I understand, that would never really lead to useful behaviour.

from bootsnap.

drewhamlett avatar drewhamlett commented on August 26, 2024

@burke this is what I get when I run the command. Thanks for your help

irb(main):004:0> keys.each { |k| m, e, d = cache[k]; puts [k, m, e.size, d].inspect }
["/Users/drew/ruby/project/app/channels", 1493218859, 5, ["application_cable"]]
=> ["/Users/drew/ruby/project/app/channels"]

This is the only thing I'm pushing onto autoload_paths

    config.autoload_paths << Rails.root.join('lib')
    config.autoload_paths << Rails.root.join('config', 'routes')

from bootsnap.

burke avatar burke commented on August 26, 2024

Weird. Could you modify <bootsnap>/lib/bootsnap/load_path_cache/path.rb and change the blank line on :40 to:

puts [path, cached_mtime, entries, dirs].inspect

and paste me the sanitized output from the last time it prints a line before the error?

from bootsnap.

drewhamlett avatar drewhamlett commented on August 26, 2024

["/Users/drew/ruby/project/app/channels/untappd_checkin_channel.rb", nil, nil, nil]

["/Users/drew/ruby/project/app/channels/untappd_checkin_channel.rb", nil, nil, nil]
Exiting
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/path.rb:63:in `mtime': Not a directory @ rb_file_s_mtime - /Users/drew/ruby/project/app/channels/untappd_checkin_channel.rb/ (Errno::ENOTDIR)

from bootsnap.

burke avatar burke commented on August 26, 2024

Ok, in that case, can you change that line to puts caller?

  • path is @path, which is set at Path.new. It's a file, not a dir, which shouldn't happen.
  • entries_and_dirs is only called from Cache#push_paths_locked and Cache#unshift_paths_locked, which instantiates Path objects with the items being added to the autload_paths array.

In this case, it appears that ""/Users/drew/ruby/project/app/channels/untappd_checkin_channel.rb" is a member of autoload_paths. A stack trace should help figure out where that's happening.

from bootsnap.

drewhamlett avatar drewhamlett commented on August 26, 2024

Yea something is messed up.

Woof::Application.config.eager_load_paths

["/Users/drew/ruby/woof/app/assets", "/Users/drew/ruby/woof/app/callbacks", "/Users/drew/ruby/woof/app/channels", "/Users/drew/ruby/woof/app/controllers", "/Users/drew/ruby/woof/app/controllers/concerns", "/Users/drew/ruby/woof/app/errors", "/Users/drew/ruby/woof/app/forms", "/Users/drew/ruby/woof/app/helpers", "/Users/drew/ruby/woof/app/javascripts", "/Users/drew/ruby/woof/app/jobs", "/Users/drew/ruby/woof/app/mailers", "/Users/drew/ruby/woof/app/models", "/Users/drew/ruby/woof/app/models/concerns", "/Users/drew/ruby/woof/app/policies", "/Users/drew/ruby/woof/app/serializers", "/Users/drew/ruby/woof/app/services", "/Users/drew/ruby/woof/app/stripe_handlers", "/Users/drew/ruby/woof/app/use_cases", "/Users/drew/ruby/woof/app/channels/digital_boards_channel.rb", "/Users/drew/ruby/woof/app/channels/locations_channel.rb", "/Users/drew/ruby/woof/app/channels/untappd_checkin_channel.rb"]

I have no idea how those files are being added to eager_load_paths

from bootsnap.

burke avatar burke commented on August 26, 2024

A stacktrace from anywhere in that code path should help. you could modify the same line as before to puts caller

from bootsnap.

drewhamlett avatar drewhamlett commented on August 26, 2024

Oh sorry meant to post that.

/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/cache.rb:135:in `block (2 levels) in unshift_paths_locked'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/cache.rb:133:in `each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/cache.rb:133:in `block in unshift_paths_locked'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/store.rb:44:in `transaction'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/cache.rb:132:in `unshift_paths_locked'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/cache.rb:90:in `block in unshift_paths'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/cache.rb:90:in `synchronize'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/cache.rb:90:in `unshift_paths'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/change_observer.rb:27:in `block in register'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/engine.rb:566:in `block in <class:Engine>'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `instance_exec'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:30:in `run'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:228:in `block in tsort_each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:431:in `each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `tsort_each_child'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `call'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `tsort_each_child'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `call'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `tsort_each_child'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `call'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `tsort_each_child'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `call'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:44:in `tsort_each_child'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `call'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:415:in `each_strongly_connected_component_from'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:349:in `block in each_strongly_connected_component'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `call'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:347:in `each_strongly_connected_component'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:226:in `tsort_each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/2.4.0/tsort.rb:205:in `tsort_each'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/initializable.rb:54:in `run_initializers'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/application.rb:352:in `initialize!'
/Users/drew/ruby/woof/config/environment.rb:5:in `<main>'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
/Users/drew/ruby/woof/config.ru:3:in `block in <main>'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `instance_eval'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:55:in `initialize'
/Users/drew/ruby/woof/config.ru:6:in `new'
/Users/drew/ruby/woof/config.ru:6:in `<main>'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:49:in `eval'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:49:in `new_from_string'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/builder.rb:40:in `parse_file'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/server.rb:318:in `build_app_and_options_from_config'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/server.rb:218:in `app'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/commands/server.rb:59:in `app'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rack-2.0.1/lib/rack/server.rb:353:in `wrapped_app'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/commands/server.rb:124:in `log_to_stdout'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/commands/server.rb:77:in `start'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:90:in `block in server'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `tap'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:85:in `server'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/railties-5.0.2/lib/rails/commands.rb:18:in `<main>'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `block in require'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:259:in `load_dependency'
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0.2/lib/active_support/dependencies.rb:293:in `require'
bin/rails:4:in `<main>'
Exiting
/Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/path.rb:64:in `mtime': Not a directory @ rb_file_s_mtime - /Users/drew/ruby/woof/app/channels/untappd_checkin_channel.rb/ (Errno::ENOTDIR)
	from /Users/drew/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bootsnap-0.2.10/lib/bootsnap/load_path_cache/path.rb:64:in `block in latest_mtime'

from bootsnap.

zspoelstra avatar zspoelstra commented on August 26, 2024

Seems this might be on purpose: https://github.com/rails/rails/pull/23505/files#diff-fe18f3d1547d462665ccd5f7e540aa90R42. I can't say either way if this is right or wrong but they glob **/*_channel.rb there

from bootsnap.

burke avatar burke commented on August 26, 2024

Ok, the error is coming from:

https://github.com/rails/rails/blob/v5.0.2/railties/lib/rails/engine.rb#L682-L684

    def _all_autoload_paths #:nodoc:
      @_all_autoload_paths ||= (config.autoload_paths + config.eager_load_paths + config.autoload_once_paths).uniq
    end

It would be useful to know what those three elements are, if you could modify railties in place.

from bootsnap.

burke avatar burke commented on August 26, 2024

Oh, just saw @zspoelstra's comment. That's... bizarre.

So I guess I'll make bootsnap just ignore paths that are single files? I wonder if @rafaelfranca has an opinion on this.

from bootsnap.

rafaelfranca avatar rafaelfranca commented on August 26, 2024

Seems good. We could also remove the files from the *_paths methods in Rails too since they returning files is not "expected".

from bootsnap.

burke avatar burke commented on August 26, 2024

Should be fixed by 0.2.11, please reopen if not.

from bootsnap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.