Skip to content
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

Add -d, --dir option to install to <prefix>/<definition> instead of <prefix> #2447

Merged
merged 3 commits into from
Sep 23, 2024

Conversation

eregon
Copy link
Member

@eregon eregon commented Sep 23, 2024

  • Similar to ruby-install's -r, --rubies-dir flag.

So this enables for example:

$ ruby-build -d truffleruby+graalvm-24.1.0 ~/.rubies
...
==> Installed truffleruby+graalvm-24.1.0 to /home/eregon/.rubies/truffleruby+graalvm-24.1.0

Which I find quite convenient compared to having to copy-paste the definition names after the rubies directory.

Copy link
Member

@mislav mislav left a comment

Choose a reason for hiding this comment

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

Thanks for this!!

@@ -8,6 +8,7 @@
# --definitions List all local definitions, including outdated ones
# --version Show version of ruby-build
#
# -d, --dir Install the Ruby in <prefix>/<definition> instead of <prefix>
Copy link
Member

Choose a reason for hiding this comment

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

My nitpick is that maybe this flag should receive a value instead of being a boolean flag.

When I see an invocation like this:

ruby-build 3.2.1 --dir ~/.rubies

it would seem to me like the --dir flag is passed a value of ~/.rubies, but that's not how this is implemented right now. This would likely work: ruby-build --dir 3.2.1 ~/.rubies, and so would this: ruby-build 3.2.1 ~/.rubies --dir, but I do not think these invocations should work because they look "wrong" and I believe that they should error out. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried to fit the existing usage ruby-build [-kpv] <definition> <prefix>.
If the prefix becomes optional it feels like opening Pandora's box, so that's why I preferred an option without a value. Also it seems currently ruby-build doesn't have any option taking an argument, and I would like to avoid having to add that.

I think all 3 variants you showed are fine to use.
I used --dir in the example because it works and looks cool, but ruby-build --dir 3.2.1 ~/.rubies is just as fine.

I'm happy to update the PR's description if that helps.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually I should update the usage line to ruby-build [-kpvd] and then the documented way to use this is ruby-build -d definition prefix.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the usage line and the PR descriptions to use ruby-build -d.
The fact -d in the middle works is then like an easter egg.

@mislav
Copy link
Member

mislav commented Sep 23, 2024

BTW, what do you think about this potential feature being lumped in with all the others, while we're going in this direction:

ruby-build truffleruby+graalvm -d ~/.rubies
#=> (installs the latest "truffleruby+graalvm" version)

@eregon
Copy link
Member Author

eregon commented Sep 23, 2024

BTW, what do you think about this potential feature being lumped in with all the others, while we're going in this direction:

It seems nice to have but that feels out of scope and I don't really have time to look into that. I don't really need it either.
There is also the question for CRuby if e.g. ruby-build 3.3 $PREFIX should work, etc.

…prefix>

* Similar to ruby-install's -r, --rubies-dir flag.
Copy link
Member

@mislav mislav left a comment

Choose a reason for hiding this comment

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

Thank you!

I've added a man page entry and a test.

@mislav mislav merged commit 2d00d40 into rbenv:master Sep 23, 2024
4 checks passed
@eregon
Copy link
Member Author

eregon commented Sep 23, 2024

Thank you!

@eregon eregon deleted the dir-option branch September 23, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants