Skip to content

1.0.0 #474

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

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open

1.0.0 #474

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
19c1fb5
Version bump to 1.0.0.
postmodern Oct 30, 2019
fbfc551
updated formatting and env descriptions
havenwood Jan 15, 2013
d51fcdc
Renamed chruby.md to chruby.1.md.
postmodern Jan 15, 2013
a88a1c4
Moved docs/chruby.1 into share/man/man1/
postmodern Jan 15, 2013
0600f2c
Added a basic man page task.
postmodern Jan 15, 2013
8087055
added -v, --version to OPTIONS
havenwood Feb 12, 2013
7ce877c
Added chruby-exec(1) manpage to See Also section.
havenwood Mar 31, 2013
8976d1a
initial commit
havenwood Mar 31, 2013
24a286c
initial commit
havenwood Mar 31, 2013
531884b
Added chruby-exec(1) duplicates of chruby(1) entries.
havenwood Mar 31, 2013
11704d0
Use kramdown-man (https://github.com/postmodern/kramdown-man).
postmodern May 7, 2013
fe6e55c
Correct spelling typo.
havenwood Jun 15, 2013
d4f157e
Correct spelling typo.
havenwood Jun 15, 2013
d527ff0
Combined `man` tasks.
postmodern Nov 22, 2019
8af032e
Renamed the `man` task to `update-man`.
postmodern Nov 22, 2019
8345e48
Markdown formatting.
postmodern Nov 22, 2019
3aa4c59
Use the Ruby directory basename to decide the GEM_HOME (#419)
eregon Nov 22, 2019
ae5e363
Extracted the chruby ruby matching logic into chruby_find().
postmodern Sep 21, 2020
9bd30f4
Added tests for chruby_find.
postmodern Sep 24, 2020
e19f454
Extract the RUBIES listing logic into chruby_list.
postmodern Sep 21, 2020
5c65a97
Added tests for chruby_list.
postmodern Sep 24, 2020
991d8b7
Renamed chruby_list to chruby_rubies.
postmodern Sep 24, 2020
475ea13
Moved initialization logic into chruby_init.
postmodern Sep 24, 2020
ba26ceb
Added the --reload option to re-initialize chruby.
postmodern Sep 24, 2020
bae35cb
Make the usage string more accurate.
postmodern Sep 24, 2020
5f680d4
Added more tests for `chruby` listing capaibilities and how it handle…
postmodern Sep 24, 2020
36ac8d5
Only output $RUBYOPT if it's set.
postmodern Sep 24, 2020
76d76f0
Test when chruby_use cannot find bin/ruby within the ruby.
postmodern Sep 24, 2020
2142980
Quote arguments.
postmodern Sep 24, 2020
d2afef6
Renamed test_rubies to original_rubies.
postmodern Sep 24, 2020
7a153d2
Move tearDown functions to the bottom.
postmodern Sep 24, 2020
eb72f22
Moved some chruby matching tests into the chruby_find tests.
postmodern Sep 24, 2020
0a2084f
Use assertEquals.
postmodern Sep 24, 2020
679481b
Use better test names.
postmodern Sep 24, 2020
eaacc71
Added a test for `chruby --version`.
postmodern Sep 24, 2020
ef2e00c
Added a test for `chruby --help`.
postmodern Sep 24, 2020
a7d7665
Ensure that chruby_init does not accidentally return 1.
postmodern Sep 24, 2020
0a84b23
Renamed RUBIES to CHRUBY_RUBIES.
postmodern Sep 24, 2020
500e218
Renamed RUBY_AUTO_VERSION to CHRUBY_AUTO_VERSION.
postmodern Sep 24, 2020
d384589
80 columns.
postmodern Sep 24, 2020
8c05944
Curly braces go on the following line.
postmodern Sep 24, 2020
5513d6d
Use local variables to indicate purpose of function arguments.
postmodern Sep 24, 2020
3538cea
Isolate user gems for rubies within ~/.gem/rubies/ to avoid polluting…
postmodern Sep 24, 2020
a9c8a8b
Replaced `chruby_rubies` with a simple for loop.
postmodern Sep 24, 2020
c8bd73d
Empty line after local variable definitions.
postmodern Sep 24, 2020
f6e616a
Renamed chruby_use to chruby_set.
postmodern Oct 7, 2020
7e693aa
Added chruby_gem_home() and chruby_gem_path() for generating $GEM_HOM…
postmodern Dec 27, 2020
0745073
Switch to loading user-installed rubies from `~/.local/share/rubies`.
postmodern Feb 27, 2021
97e83c7
Update documentation to reference the new `~/.local/share/rubies/` lo…
postmodern Feb 27, 2021
2379ef0
Fixed a failing test.
postmodern Sep 26, 2021
7f848f1
Update test_gem_home to use `~/.gem/rubies/$ruby_engine-$ruby_version`.
postmodern Sep 26, 2021
fe7d917
Fix tests that were failing due to zsh indexing arrays starting at 1.
postmodern Sep 26, 2021
06269a7
Revert back to using rubies from `~/.rubies`.
postmodern Jan 19, 2023
40b73e9
Add the `CHRUBY_DIRS` env variable for configuring the directories to…
postmodern Jan 19, 2023
355ad07
Use `echo -n`.
postmodern Jan 19, 2023
c87f4cf
Changed `chruby_find` to search `CHRUBY_DIRS` each time.
postmodern Jan 19, 2023
d504dcd
Update the mock ruby to 3.0.0.
postmodern Jan 19, 2023
4c994cb
Use `read -r` to avoid interpreting backslases.
postmodern Jan 19, 2023
52dae19
Always quote string arguments.
postmodern Jan 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
### 1.0.0

#### Upgrade Notes

* When updating from `chruby` < 1.0 to `chruby` >= 1.0, you will need to
re-install your gems because the gem directories will be different. It is also
recommended to clean old gem directories under `~/.gem` which will no longer
be used to save disk space. To remove them, you can use
`rm -rf ~/.gem/{ruby,jruby,rbx,truffleruby}/[0-9].[0-9].[0-9]`

#### chruby.sh

* Use the installed Ruby directory name for setting `GEM_HOME`. (@eregon)
This guarantees a unique `GEM_HOME` per installed Ruby, even if they have
the same `RUBY_VERSION`. This is important for native extensions, which
might compile differently based on build-time flags such as `--enable-shared`.
This also fixes the bug that the `GEM_HOME` for non-MRI Ruby implementations
was shared even for different releases.

### 0.3.9 / 2014-11-23

#### chruby.sh
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME=chruby
VERSION=0.3.9
VERSION=1.0.0
AUTHOR=postmodern
URL=https://github.com/$(AUTHOR)/$(NAME)

Expand All @@ -22,6 +22,15 @@ all:
pkg:
mkdir $(PKG_DIR)

share/man/man1/chruby.1: doc/man/chruby.1.md
kramdown-man <doc/man/chruby.1.md >share/man/man1/chruby.1

share/man/man1/chruby-exec.1: doc/man/chruby-exec.1.md
kramdown-man <doc/man/chruby-exec.1.md >share/man/man1/chruby-exec.1

update-man: share/man/man1/chruby.1 share/man/man1/chruby-exec.1
git commit -m "Updated the man pages" doc/man/chruby.1.md share/man/man1/chruby.1 doc/man/chruby-exec.1.md share/man/man1/chruby-exec.1

download: pkg
wget -O $(PKG) $(URL)/archive/v$(VERSION).tar.gz

Expand Down Expand Up @@ -80,4 +89,4 @@ uninstall:
rm -rf $(DESTDIR)$(PREFIX)/$(DOC_DIR)
rmdir $(DESTDIR)$(PREFIX)/$(SHARE_DIR)/chruby

.PHONY: build download sign verify clean check configure_tests test integration_tests gauntlet tag release rpm install uninstall all
.PHONY: build man download sign verify clean check configure_tests test integration_tests gauntlet tag release rpm install uninstall all
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Changes the current Ruby.
* Updates `$PATH`.
* Also adds RubyGems `bin/` directories to `$PATH`.
* Correctly sets `$GEM_HOME` and `$GEM_PATH`.
* Users: gems are installed into `~/.gem/$ruby/$version`.
* Root: gems are installed directly into `/path/to/$ruby/$gemdir`.
* Users: gems are installed into `~/.gem/$ruby_name` (e.g., `~/.gem/ruby-2.6.3` for `~/.rubies/ruby-2.6.3`).
* Root: gems are installed directly into `$ruby_install_dir/$gemdir` (the default).
* Additionally sets `$RUBY_ROOT`, `$RUBY_ENGINE`, `$RUBY_VERSION` and
`$GEM_ROOT`.
* Optionally sets `$RUBYOPT` if second argument is given.
Expand Down Expand Up @@ -218,13 +218,13 @@ If you have enabled auto-switching, simply create a `.ruby-version` file:
### RubyGems

Gems installed as a non-root user via `gem install` will be installed into
`~/.gem/$ruby/X.Y.Z`. By default, RubyGems will use the absolute path to the
currently selected ruby for the shebang of any binstubs it generates. In some
cases, this path may contain extra version information (e.g.
`~/.gem/$ruby_name`. By default, RubyGems will use the
absolute path to the currently selected ruby for the shebang of any binstubs it
generates. In some cases, this path may contain extra version information (e.g.
`ruby-2.0.0-p451`). To mitigate potential problems when removing rubies, you
can force RubyGems to generate binstubs with shebangs that will search for
ruby in your `$PATH` by using `gem install --env-shebang` (or the equivalent
short option `-E`). This parameter can also be added to your gemrc file.
short option `-E`). This parameter can also be added to your `.gemrc` file.

### Integration

Expand Down Expand Up @@ -269,7 +269,7 @@ Select a Ruby:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/hal/.gem/ruby/1.9.3
- /home/hal/.gem/ruby-1.9.3-p392
- /opt/rubies/ruby-1.9.3-p392/lib/ruby/gems/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
Expand Down Expand Up @@ -299,7 +299,7 @@ Run a command under a Ruby with `chruby-exec`:

Switch to an arbitrary Ruby on the fly:

$ chruby_use /path/to/ruby
$ chruby_set /path/to/ruby

## Uninstall

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/chruby_use.sh → benchmarks/chruby_set.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ for i in {1..3}; do

time (
for ((i=0; i<$n; i+=1)); do
chruby_use "$ruby_dir"
chruby_set "$ruby_dir"
done
)
done
76 changes: 76 additions & 0 deletions doc/man/chruby-exec.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# chruby-exec(1) -- Run a command with selected Ruby.

## SYNOPSIS

`chruby-exec` RUBY [RUBYOPTS] -- COMMAND

## ARGUMENTS

*RUBY*
Change current Ruby based on fuzzy matching of Ruby by name.

*RUBYOPTS*
Additional optional arguments to pass to Ruby.

*COMMAND*
Command to run under the selected Ruby.

## OPTIONS

`-h`, `--help`

`-v`, `--version`

## DESCRIPTION
Run a command with the selected Ruby version by correctly setting the appropriate environment variables.

[https://github.com/postmodern/chruby/blob/master/README.md](https://github.com/postmodern/chruby/blob/master/README.md)

## EXAMPLES

Run the command `gem update` under JRuby:
$ chruby-exec jruby -- gem update

## FILES

*/opt/rubies*
Primary default Ruby install location.

*~/.rubies/*
Secondary default Ruby install location.

*/etc/profile.d/chruby.sh*
Application environment settings for chruby.

*~/.gem/$ruby/$version*
Default gem install location.

## ENVIRONMENT

*PATH*
Updates the PATH environment variable to include Rubies and RubyGems bin/ directories.

*GEM_HOME*
Default repository location for gem installation.

*GEM_PATH*
A colon-separated list of gem repository directories.

*GEM_ROOT*

*RUBY_ROOT*

*RUBY_ENGINE*
Name of Ruby implementation.

*RUBY_VERSION*
Ruby version number.

*RUBYOPT*
Optionally set if additional Ruby options are given.

## AUTHOR
Postmodern [postmodern.mod3\@gmail.com](mailto:postmodern.mod3\@gmail.com).

## SEE ALSO
chruby(1), ruby(1), gem(1)
95 changes: 95 additions & 0 deletions doc/man/chruby.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# chruby(1) -- Changes the current Ruby.

## SYNOPSIS

`chruby` [OPTIONS | <RUBY|VERSION> [<RUBY_OPTS>] | system]

## ARGUMENTS

*RUBY|VERSION*
Change current Ruby based on fuzzy matching of Ruby by name.

*system*
Change current Ruby to system Ruby.

*RUBY_OPTS*
Additional optional arguments to pass to Ruby.

## OPTIONS

`-h`, `--help`

`-v`, `--version`

## DESCRIPTION
Changes the current Ruby version by correctly setting the appropriate environment variables.

[https://github.com/postmodern/chruby/blob/master/README.md](https://github.com/postmodern/chruby/blob/master/README.md)

## EXAMPLES

List available Rubies:
$ chruby
ruby-1.9.3-p362
jruby-1.7.2
rubinius-2.0.0-rc1

Select a Ruby:
$ chruby 1.9.3
$ chruby
* ruby-1.9.3-p362
jruby-1.7.2
rubinius-2.0.0-rc1

Switch to JRuby in 1.9 mode:
$ chruby jruby --1.9

Switch back to system Ruby:
$ chruby system

Switch to an arbitrary Ruby on the fly:
$ chruby_set /path/to/ruby

## FILES

*/opt/rubies*
Primary default Ruby install location.

*~/.rubies/*
Secondary default Ruby install location.

*/etc/profile.d/chruby.sh*
Application environment settings for chruby.

*~/.gem/$ruby/$version*
Default gem install location.

## ENVIRONMENT

*PATH*
Updates the PATH environment variable to include Rubies and RubyGems bin/ directories.

*GEM_HOME*
Default repository location for gem installation.

*GEM_PATH*
A colon-separated list of gem repository directories.

*GEM_ROOT*

*RUBY_ROOT*

*RUBY_ENGINE*
Name of Ruby implementation.

*RUBY_VERSION*
Ruby version number.

*RUBYOPT*
Optionally set if additional Ruby options are given.

## AUTHOR
Postmodern [postmodern.mod3\@gmail.com](mailto:postmodern.mod3\@gmail.com).

## SEE ALSO
chruby-exec(1), ruby(1), gem(1)
14 changes: 8 additions & 6 deletions share/chruby/auto.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
unset RUBY_AUTO_VERSION
unset CHRUBY_AUTO_VERSION

function chruby_auto() {
function chruby_auto()
{
local dir="$PWD/" version

until [[ -z "$dir" ]]; do
Expand All @@ -9,18 +10,19 @@ function chruby_auto() {
if { read -r version <"$dir/.ruby-version"; } 2>/dev/null || [[ -n "$version" ]]; then
version="${version%%[[:space:]]}"

if [[ "$version" == "$RUBY_AUTO_VERSION" ]]; then return
if [[ "$version" == "$CHRUBY_AUTO_VERSION" ]]; then
return
else
RUBY_AUTO_VERSION="$version"
CHRUBY_AUTO_VERSION="$version"
chruby "$version"
return $?
fi
fi
done

if [[ -n "$RUBY_AUTO_VERSION" ]]; then
if [[ -n "$CHRUBY_AUTO_VERSION" ]]; then
chruby_reset
unset RUBY_AUTO_VERSION
unset CHRUBY_AUTO_VERSION
fi
}

Expand Down
Loading