Skip to content

Commit d1af97b

Browse files
Crystal::Config.path= (#16613)
When running compiler specs, we want them to pick up the standard library at the source location that goes alongside it. Specs often run with `bin/crystal spec` where the wrapper already assigns `CRYSTAL_PATH` appropriately. But when executing a spec binary independently, this environment variable is missing. We used to explicitly set the `CRYSTAL_PATH` env var, but we want to remove `ENV` mutations (cf. #16449). For the actual value, `Crystal::PATH` could also be an option instead of `"#{__DIR__}/../src"`. The result is equivalent, but maybe it's a bit more clear that we're baking the compiler's path. `Crystal::PATH` includes `./lib` though, which we don't really need here. It probably doesn't do any harm, but it shouldn't be there. So we could consider removing it, but then I'm not sure it's worth it over `"#{__DIR__}/../src"`.
1 parent 8afd5be commit d1af97b

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

spec/spec_helper.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{% raise("Please use `make test` or `bin/crystal` when running specs, or set the i_know_what_im_doing flag if you know what you're doing") unless env("CRYSTAL_HAS_WRAPPER") || flag?("i_know_what_im_doing") %}
22

3-
ENV["CRYSTAL_PATH"] = "#{__DIR__}/../src"
3+
Crystal::Config.path = "#{__DIR__}/../src"
44

55
require "spec"
66

src/compiler/crystal/config.cr

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ require "./codegen/target"
22

33
module Crystal
44
module Config
5-
def self.path
6-
{{env("CRYSTAL_CONFIG_PATH") || ""}}
7-
end
5+
class_property path : String = {{env("CRYSTAL_CONFIG_PATH") || ""}}
86

97
def self.version
108
{{ read_file("#{__DIR__}/../../VERSION").chomp }}

0 commit comments

Comments
 (0)