-
-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow CRYSTAL env var to determine compiler #415
Allow CRYSTAL env var to determine compiler #415
Conversation
Although it is not used. But that's the pattern followed in config.cr for now.
Avoid requiring crystal to be available in path. This can allow wrapper scripts on shards and have a cleaner override of the CRYSTAL_VERSION to use to resolve dependencies.
Can't we just figure out the directory |
I think that prepending current shards and crystal location to the path when invoking scripts from shards is acceptable. |
I just realized, the symlink approach could have another advantage: it removes the need that |
Good point. I usually have directories like Should shards create & prepend the directory to the path only when needed? Identifying if the resolution to shards and crystal leads to the same executable that is running and to the Those |
I think it's fine to start simple and make it smart afterwards. That is I'd be totally fine if any
I don't actually have that anywhere right now. It's just common to see from packages of other things, especially languages. I know for certain that Archlinux, Debian and Fedora/RHEL families of distributions install |
Ok, will take the route of lazily setup only once the first postinstall is hit for now. Something that might not work is if |
Well yes, aliases only exist in the current shell anyhow afaik, it won't even properly work to put them into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small things, looks good!
They do work in subshells when configured via shellrc. My two cents: I don't like where this is going. It adds even more build tool features to shards. Shards shouldn't be a build tool. It's a dependency manager. There are lots of build tools out there and most of them are better than shards for this job. |
@straight-shoota how would you solve that the environment used is preserved along the way? Even if we assume that crystal is in the path, how we ensure the same shards is called in the postinstall? |
Co-authored-by: Jonne Haß <me@jhass.eu>
Co-authored-by: Jonne Haß <me@jhass.eu>
Plus if CRYSTAL env var is used to choose the crystal compiler to grab the version for the resolution, how we can ensure that that binary is used as the compiler all along? |
I'd let that be the responsibility of a real build tool. |
So you would remove |
I don't think having a To me the noise is coming from the relationship with the With the risk of turning this conversation away from the topic of this PR, maybe we could extend the postinstall:
target: foo I may even suggest that the If this message receive at least one thumbs up, I'll open a RFC so we could discuss the feature there 🙂 |
I will give the 👍 because I mention something like that in #415 (comment)
Yet, that will not solve the issue that if a makefile is used either shards or crystal might be called there. |
It seems that whatever solution we try to achieve here will lead to half-way implementation. Although #406 seems legit at first, shards is already bound to crystal binary in reality since post_install steps might call crystal compiler. It was a nice excercise though :-) For now it seems that the best things is to close this PR and maybe #406. |
I didn't get what the outstanding issue with this approach is. Also let's not get the aim for a perfect solution to be in the way of useful iteration (that theme seems to expose in a couple of other places as well...). Once we find it, we still can move towards the perfect solution, improving status quo is not useless in the meantime. |
Part of the line of thought was #406 proposed another way to determine which crystal version is wanted. Choosing the binary push the story of how to honor that choice within the postinstall steps. If the postinstall where more declarative, not requiring to explicitly call crystal in a shell script there will be no need to set the PATH since shards could do that per target directly. But users might still prefer to use make or other build tools and call crystal. Maybe in the future we can have a standardize an env var like CC to choose the crystal compiler, that would remove the need for changing the PATH with temporal directories. It will also allow compilers named crystal-x.y to be used. Shards could set a fallback to that env var. Part of my motivations here was to pave the road for a self-containted .tar.gz where the crystal and shards binary there will call each other. This will be better handle by wrapper scripts of crystal and shards that will prepend the ./bin location relative to the wrapper scripts to PATH. |
Fixes #406
Shards will read CRYSTAL env var, fallback to
crystal
, to determine which crystal compiler to use.This also enables that a compiler+shards package can force to use the compiler of that same packaging if wanted.
Something that is not handled is how the
executables
+postinstall
can deal with this override.A dependency is forced to use in the
postinstall
a${CRYSTAL:-"crystal"}
instead ofcrystal
which is not great.Another alternative is to encourage
shards build
instead ofcrystal build
that way shards will be invoked again and can choose the appropiate crystal compiler since the environment is preserved.But we actually have the same problem, the
postinstall
assumes thatshards
is on the path. So what? we should have a${SHARDS:-"shards"}
? Not great.I think that the scenario of having executable helpers in the bin directory that are compiled by dependencies on postinstall should be more declarative. That would be a way to solve it I think.