Commit Graph

14 Commits

Author SHA1 Message Date
Jean Boussier 404745f804 Open with O_NOATIME
Should avoid some needless disk access on Linux.

Also cleanup the extconf.rb
2024-01-30 10:49:58 +01:00
Jean Boussier b6f0b3fc94 Require ruby 2.6+ 2022-11-09 09:42:30 +09:00
Jean Boussier 9e1a126f4f Drop Ruby 2.4 support 2022-06-01 10:37:37 +02:00
Jean Boussier 88b8cd4464 Drop Ruby 2.3 support.
Ref: https://github.com/Shopify/bootsnap/pull/402
Ref: https://bugs.ruby-lang.org/issues/10222
Ref: 5754f15975
Ref: b6d3927e16

Up to Ruby 2.3, `require` would resolve symlinks, but `require_relative` wouldn't:

```ruby
require 'fileutils'
FileUtils.mkdir_p("realpath")
File.write("realpath/a.rb", "p :a_loaded")
File.symlink("realpath", "symlink") rescue nil

$LOAD_PATH.unshift(File.realpath(__dir__) + "/symlink")
require "a.rb" # load symlink/a.rb in 2.3 and older, load realpath/a.rb on 2.4 and newer
require_relative "realpath/a.rb" # noop on 2.4+
```

This would easily cause double loading issue when `require` and `require_relative`
were mixed, but was fixed in 2.4 (https://bugs.ruby-lang.org/issues/10222).

The problem is that `Bootsnap` kinda negated this fix, because `realpath()`
wouldn't be applied to absolute paths:

```ruby
require 'fileutils'
FileUtils.mkdir_p("realpath")
File.write("realpath/a.rb", "p :a_loaded")
File.symlink("realpath", "symlink") rescue nil

$LOAD_PATH.unshift(File.realpath(__dir__) + "/symlink")
require File.expand_path("symlink/a.rb") # load symlink/a.rb in 3.0 and older, load realpath/a.rb on 3.1 and newer
require_relative "realpath/a.rb" # noop on 3.1+
```

And for performance reasons, Bootsnap tried really hard not to call `realpath`,
as it's a syscall, instead it used `expand_path`, which is entirely in use
space and doesn't reach to the file system. So if you had a `symlink` in
`$LOAD_PATH`, `bootcsnap` would perpetuate this bug, which led to the
addition of https://github.com/Shopify/bootsnap/pull/136.

This was ultimately fixed in Ruby 3.1 (https://bugs.ruby-lang.org/issues/17885),
now `realpath` is applied even on absolute paths.

While `realpath` is indeed expensive, I think the performance impact is ok if
we only call it for `$LOAD_PATH` members, rather than for all requirable files.
So if you have X gems, it's going to be more or less X `realpath` calls.

It would stay a problem if a gem actually contained symlinks and used
`require_relative`, but it's quite the stretch, and with 3.1 now
handling it, it's not worth keeping such workaround.

See: https://github.com/Shopify/bootsnap/pull/402
2022-02-07 15:35:10 +01:00
Jean Boussier 487d46cfcc Appease rubocop 2022-01-31 10:48:34 +01:00
Jean Boussier 647969fff5 Code style and CI improvements 2022-01-28 15:21:40 +01:00
Jean Boussier b277e75e85 Cleanup the rubocop config
Go back to rubocop 0.80 for Ruby 2.3 support.
Stop depending on the company style guide, as it needs a newer
rubocop.
2022-01-13 10:05:10 +01:00
Gannon McGibbon 32f2fcc5a2 Generate Rubocop TODO 2022-01-12 16:26:18 -05:00
Gannon McGibbon 9013935813 Use rubocop-shopify 2022-01-12 16:17:47 -05:00
Jean Boussier 2d45c5e230 Deprecate ActiveSupport::Dependencies integration 2021-02-01 10:11:02 +01:00
Pradeep Agrawal de968f059b
Update .rubocop.yml 2020-05-20 18:49:32 +05:30
alebruck b720530584 Update minimum ruby version and fix rubocop 2019-10-12 17:23:16 +02:00
Burke Libbey 86b8b28552
add and appease rubocop 2017-10-06 13:31:34 -04:00
Burke Libbey 47539a1c07
Initial public release 2017-03-31 11:38:33 -04:00