Skip to content

Add compiler detection of adjacent stdlib in dev folder#17071

Open
straight-shoota wants to merge 7 commits into
crystal-lang:masterfrom
straight-shoota:feat/development-compiler-crystal_path
Open

Add compiler detection of adjacent stdlib in dev folder#17071
straight-shoota wants to merge 7 commits into
crystal-lang:masterfrom
straight-shoota:feat/development-compiler-crystal_path

Conversation

@straight-shoota

Copy link
Copy Markdown
Member

Resolves #17041

Comment on lines +24 to +25
elsif dev_path = dev_path?
path_array = [DEFAULT_LIB_PATH, dev_path]

@ysbaddaden ysbaddaden Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced. This would be hardcoded into every compiler while this is a configuration issue, and it's already handled by CRYSTAL_CONFIG_PATH and CRYSTAL_PATH.

I think the makefiles should export CRYSTAL_CONFIG_PATH=$PWD/src:lib (when unset), and call sites should just configure CRYSTAL_PATH. Some helpers calling to crystal already do it.

@straight-shoota straight-shoota Jun 15, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRYSTAL_CONFIG_PATH is for configuring the stdlib source path for packaging. We could customize it for development builds to CRYSTAL_CONFIG_PATH=$$ORIGIN/../src, but then it wouldn't work when installed at /usr/share/crystal/src, for example. We'd need separate configuration for production builds.
You can either have a compiler build that picks up the local path, or one that is ready to be installed in a system path (or wherever).
Maybe, that's fine. But right now you can build a compiler, test it (with this patch, using .build/crystal), and then install it. The automatic discover just works.

Without automatic discovery, .build/crystal would not have any usable default configuration for CRYSTAL_PATH. The CRYSTAL_CONFIG_PATH value doesn't work because it's not in an install location yet.

Requiring explicit configuration is much more inconvenient compared to bin/crystal.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if anybody's using the install target to be honest. Distributions merely set CRYSTAL_CONFIG_PATH (e.g. alpine, debian, homebrew, ...).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does that matter? I don't think the usage makes much difference whether you run make install or install .build/crystal $out/bin/crystal 🤷

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if nobody is using the install target and instead configure CRYSTAL_CONFIG_PATH, then there's little point for the Makefile to keep using $$ORIGIN/../share/crystal/src by default.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are two independent dimensions: Using make install and relying on the default CRYSTAL_CONFIG_PATH are not directly related.
There are use cases involving either one or both of them.

@ysbaddaden

ysbaddaden commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Maybe it's acceptable, but I still strongly believe the call sites must specify CRYSTAL_PATH instead of relying on the executable to detect the stdlib to use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bin/crystal vs .build/crystal

2 participants