Comments (18)
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.
It works! Thanks so much
from bootsnap.
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.
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.
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.
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.
@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.
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.
["/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.
Ok, in that case, can you change that line to puts caller
?
path
is@path
, which is set atPath.new
. It's a file, not a dir, which shouldn't happen.entries_and_dirs
is only called fromCache#push_paths_locked
andCache#unshift_paths_locked
, which instantiatesPath
objects with the items being added to theautload_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.
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.
A stacktrace from anywhere in that code path should help. you could modify the same line as before to puts caller
from bootsnap.
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.
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.
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.
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.
Seems good. We could also remove the files from the *_paths
methods in Rails too since they returning files is not "expected".
from bootsnap.
Should be fixed by 0.2.11, please reopen if not.
from bootsnap.
Related Issues (20)
- YAML cache "bypasses" permitted_classes in some cases HOT 4
- ibf_dump_object_unsupported […] T_NONE (NotImplementedError) HOT 26
- bootsnap compile-cache-yaml folder contents file permissions issue HOT 4
- windows rails demo project error HOT 2
- sharing remote caching bootsnap cache dir across machines HOT 2
- Facing `compile_file': "\\xE2" on US-ASCII (Encoding::InvalidByteSequenceError) error when trying to run any rails command HOT 14
- Bootsnap causes server to hang in Ruby 3.2.1 HOT 6
- undefined method `driver_path=' for Selenium::WebDriver::Chrome:Module HOT 1
- Testsuite fails with ruby3.3.0dev HOT 6
- warning: method redefined; discarding old require HOT 2
- Bootsnap LoadError for Prism HOT 8
- `bin/bootsnap precompile` not compiling everything HOT 7
- 1.18.x extension build failed HOT 11
- 1.18.x: `compile_cache/iseq.rb:64:in 'fetch': Invalid argument - (Errno::EINVAL)` HOT 1
- EOFError: end of buffer reached HOT 9
- Shopify IP allowlist restricting access to non-sensitive resource? HOT 3
- I feel like everybody is doing `gem "bootsnap", require: false` so why not make bootsnap.rb do nothing? HOT 2
- `bootsnap -v` or `bootsnap --version` could return the version of bootsnap? HOT 1
- Exception raised when upgraded to ruby 3.3.1 and deployed to Heroku HOT 6
- bootsnap/setup cannot load msgpack HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bootsnap.