Commit graph

424 commits

Author SHA1 Message Date
Mislav Marohnić
e851250da6 Speed up obtaining exec/which/whence completions
Delegate to `rbenv-shims` instead of `rbenv shims` and therefore skip
going through the main `rbenv` executable again that would set up a lot
of the environment that was already set.
2014-10-15 01:24:45 +02:00
Mislav Marohnić
c69d9a1128 Isolate rbenv-which tests from any .ruby-version file on the system
Having a `.ruby-version` file in any of the parent directories of the
local clone of rbenv could cause the test suite to fail because it
wasn't expecting a local version to be set.

Fixes #533
2014-10-13 12:39:47 +02:00
Mislav Marohnić
f4652fbbf0 Merge branch 'speedup-which'
Closes #560
2014-10-13 12:30:34 +02:00
Mislav Marohnić
3ee395f9b5 Clean up PATH sanitization in rbenv-which 2014-10-13 12:27:19 +02:00
Daniel Hahler
e4cbf04592 Improve performance of rbenv-which when RBENV_VERSION=system
This implements removing of the shims path element via bash
substitution, instead of jumping around in all the `$PATH` elements.
2014-10-13 12:26:43 +02:00
Mislav Marohnić
6bb7f07d2d Avoid rbenv-exec calling out to rbenv-version-name twice
Running any shim (and thus `rbenv-exec`) would always execute
`rbenv-version-name` twice: once in `rbenv-exec` and another time in
`rbenv-which`, even though RBENV_VERSION variable would have already
been populated at this point.

Now RBENV_VERSION is respected within `rbenv-which`.
2014-10-13 12:26:43 +02:00
Mislav Marohnić
51bd975820 Merge branch 'blank-versions'
Fixes #626
2014-10-13 11:51:46 +02:00
Mislav Marohnić
9bcef4b875 Add tests for non-directory types under RBENV_ROOT/versions/ 2014-10-13 04:02:46 +02:00
Mislav Marohnić
f237a11f4f Have versions emit a warning when no Ruby version was found 2014-10-13 04:02:04 +02:00
Mislav Marohnić
13a474c4e9 Get rid of explicit exit in fish branch of rbenv-init
Allows for code to be added to the end of the script which will not
mysteriously fail to run for fish shell.
2014-06-03 00:39:34 +07:00
Mislav Marohnić
fe0b2436b8 Merge pull request #581 from LawnGnome/solaris-gawk
Prefer gawk over awk if both are available.

Fixes rbenv-help on Solaris 11.1
2014-04-19 15:29:31 +02:00
Adam Harvey
808527b5d0 Prefer gawk over awk if both are available. 2014-04-18 10:40:56 +10:00
Mislav Marohnić
f71e22768c Merge pull request #567 from genezys/patch-1
Remove carriage return characters in version file

Fixes #566
2014-03-21 17:22:03 +01:00
Vincent Robert
b025dfcf58 Add \r to IFS instead of removing it manually 2014-03-21 01:36:39 +01:00
Vincent Robert
f205ec8359 Move carriage return test to version-file-read 2014-03-21 01:32:29 +01:00
Vincent Robert
f50cee2ac7 Simplify bash expression 2014-03-20 16:52:45 +01:00
Vincent Robert
3be9773c4f Add test for carriage return in ruby-version file 2014-03-20 16:27:13 +01:00
Vincent Robert
2fd3b18d39 Remove carriage return characters in version file
When created on Windows, .rbenv-version or .ruby-version files may have CR characters that will prevent rbenv from correctly parsing the Ruby version. Discard those characters when reading the file.
2014-03-20 11:30:27 +01:00
Mislav Marohnić
14bc162ca6 Merge branch 'openbsd'
Closes #524
2014-01-02 22:44:19 +01:00
Mislav Marohnić
1a6bada94c Fix detecting parent shell on OpenBSD and Cygwin
It seems that "comm" header can't be relied on cross-platform, but that
"ucomm" is more portable. I have no idea whether it's the right value to
use here, but it seems to be doing the job.

Also strip trailing whitespace because OpenBSD 5.4 `ps` output is padded
with spaces for some reason.

Fixes #489
2014-01-02 22:36:03 +01:00
Mislav Marohnić
eda535a942 Fix detecting completions support on OpenBSD
The non-extended regex pattern didn't work on OpenBSD so this switches
grep to extended pattern mode that seems to work consistenty on all
systems.
2014-01-02 22:33:54 +01:00
Mislav Marohnić
1e1c9cb0dc Fix emulating the scenario where system Ruby is missing on OpenBSD
On other systems, we expected to find system Ruby in `/usr/bin`, but in
OpenBSD 5.4 it will be found in `/usr/local/bin`.

This replaces the limited USRBIN_ALT hack with a more generic
`path_without` function that will ensure that the given executable is
not present in the resulting PATH even if it's found in multiple
system paths.
2014-01-02 22:30:21 +01:00
Mislav Marohnić
3dc0005032 Fix test suite running on OpenBSD
The error was "bash: no such file or directory" and it was due to bash
being located in `/usr/local/bin` on OpenBSD 5.4 instead of `/bin` like
on other systems.

Fixed by keeping `/usr/local/bin` in PATH during the test run.
2014-01-02 22:17:38 +01:00
Mislav Marohnić
6d0bf9b39f Merge pull request #521 from wmoxam/master
Fix rbenv on OpenBSD

Fixes #519
2014-01-01 15:31:08 -08:00
wmoxam
2f5d9a6f90 Fixes rbenv on OpenBSD and any other systems that don't support head -c 2013-12-31 01:44:36 -05:00
Mislav Marohnić
783618b89c Force TAP output from Bats on CI
In Travis CI environment, Bats thinks it's outputting to an interactive
terminal, so it switches to "pretty" format and ANSI escape codes which
don't look well in the final output.
2013-12-25 18:14:10 +01:00
Jeffrey 'jf' Lim
4f2f6f8575 Fix test suite when no system Ruby exists
Some tests assumed that the `ruby` executable will be found in system PATH.

Fixes #512, closes #514
2013-12-25 18:14:10 +01:00
Mislav Marohnić
59aca30267 Merge pull request #491 from peterhoeg/master
ignore cache directory used by ruby-build
2013-12-17 10:15:09 -08:00
Sam Stephenson
605e691bff Merge pull request #504 from jonathandean/master
Remove Neckbeard reference in favor of Advanced
2013-12-14 13:57:54 -08:00
Jonathan Dean
09ec276a85 Change 'Advanced Configuration' reference to 'How rbenv hooks into your shell' 2013-12-14 16:38:25 -05:00
Jonathan Dean
590b19a1b1 Remove Neckbeard reference in favor of Advanced 2013-12-13 14:06:44 -05:00
Mislav Marohnić
be5e1a4ded Improve rbenv init instructions for fish
Fish user config file `~/.config/fish/config.fish` loads for every
instance of fish shell, not just interactive ones. Since it's
unnecessary and dangerous to eval `rbenv init -` output in
non-interactive shells, wrap the invocation in a conditional that checks
if the current shell is interactive.

Fixes #501
2013-12-06 16:45:22 +01:00
Peter Hoeg
8650de0c0c ignore cache directory used by ruby-build 2013-11-25 11:59:23 +08:00
Mislav Marohnić
95a039aaaa Revert "rbenv exec: avoid mutating PATH"
It was supposed to fix shelling out to Ruby but it in fact broke another
kind of shelling out to Ruby: invoking the `ruby` binary directly with
the `-S` flag.

Fixes #480

This reverts commit db143bb654.
2013-11-03 12:18:28 +02:00
Mislav Marohnić
f1fdb9bbc8 Avoid invoking hash -r in fish
It doesn't exist as a builtin, and it doesn't seem there is a way to
detect support for a shell builtin that is portable. So, just detect
fish and don't the rehash command at all.

Fixes #478
2013-10-31 20:18:14 +02:00
Mislav Marohnić
44e76bea23 Merge pull request #372 from sstephenson/exec-next
Change `exec` semantics to allow using rbenv from a ruby process
2013-10-29 18:53:33 -07:00
Mislav Marohnić
a898e2a534 Merge branch 'no-process-substitution' 2013-10-30 02:50:31 +01:00
Mislav Marohnić
681435e0b4 Simplify version-file-read to avoid process substitution
Process substitution seems to be causing problems with some versions of
bash on specific systems.

Fixes #401
2013-10-30 02:33:49 +01:00
Mislav Marohnić
d2eace00c9 Add more tests for version-file-read 2013-10-30 02:33:23 +01:00
Mislav Marohnić
3300587c6b strip initial - from the name of shell process
Avoids the case where shell detection would result in
`basename "-bash"` invocation, triggering the error:

    basename: illegal option -- b

fixes #462
2013-10-07 14:19:37 +02:00
Mislav Marohnić
878bd87328 reliably detect parent shell in rbenv init
`$SHELL` variable is a terrible way of detecting the current shell
because it's not even supposed to reflect the current shell; it's meant
for keeping the value of the default shell for programs to start.

If an explicit `<shell>` argument wasn't passed to `rbenv init`, it
tries to detect the shell by getting the name of its parent process. If
this fails, it falls back on the value of `$SHELL` as before.

Furthermore, `rbenv init` will set the RBENV_SHELL variable in the
current shell to the value of the detected shell so that `sh-shell` and
`sh-rehash` commands don't have to repeat the detection.
2013-10-07 03:24:45 +02:00
Gunes
ff23666d56 typo: remove "v" (version prefix) 2013-10-03 22:18:43 +02:00
Mislav Marohnić
f4fade3d26 better error message for rbenv prefix system
Have `rbenv prefix` handle the case where system Ruby is not installed,
i.e. `rbenv which ruby` doesn't find ruby in PATH.

Fixes #362
2013-10-03 21:42:52 +02:00
Mislav Marohnić
16c3e0ddac tweak installation instructions
Provide an `rbenv install` example and explanation lower down, so that
both folk that are following git install and Homebrew install will
finish at the same section and learn how to use ruby-build.

Also remove step 6 of manual install process: `rbenv rehash`. It's
unnecessary at that point, even if they already did `rbenv install`
(which rehashes automatically).

Fixes #455, closes #456
2013-10-03 20:52:13 +02:00
Mislav Marohnić
0d216c2d82 remove rbenv install example; clarify manual compile
It can be confusing if people mistake the example as instructions to
install ruby-build with.
2013-10-03 20:17:10 +02:00
Mislav Marohnić
a1fb5b1153 better Ubuntu Desktop installation instructions
Don't suggest that they add to their `.profile` anymore because:

1. They would have to restart the desktop session for their change to be
   reflected, or source the file manually;
2. An error in `.profile` may prevent logging in;
3. The `rbenv()` shell function and shell completions won't be available
   in Terminal since it doesn't start bash in login mode by default.

Therefore, suggest that they use `.bashrc` instead. This will be
immediately reflected in a new Terminal tab. If bash is started in login
mode somehow, the default `.profile` is set up to source `.bashrc` anyway.

Also, don't suggest restarting the shell environment with
`exec $SHELL -l`, since we don't know what was the original mode that
their shell was started in. (OS X Terminal.app will be login mode,
Ubuntu Terminal has non-login mode by default.) Mode can be checked with:

* bash: `shopt -q login_shell`
* zsh: `[[ $options[login] = "on" ]]`

But since this is gnarly, let's just avoid it altogether and go the
easy route.

Closes #305, fixes #373, reverts #286
2013-10-03 20:07:22 +02:00
Mislav Marohnić
e97326845c Ubuntu fix: don't use . in place of source
If `rbenv init -` outputs `.` in place of `source` and that gets eval'd
by the desktop manager via `~/.profile`, it chokes and prevents the user
from logging in.

Fixes #457
2013-10-03 16:12:24 +02:00
Mislav Marohnić
71a6d791c2 Merge branch 'shell-fixes' 2013-09-28 16:15:13 +02:00
Mislav Marohnić
5ae2cac088 fix rbenv() function in ksh and dash
ksh syntax becomes:

    function rbenv {
      typeset command

`typeset` only declares a local variable if there's an explicit
`function` declaration; otherwise the variable leaks.

Other shells use this syntax:

    rbenv() {
      local command

This is for dash compatibility, which supports neither `function` nor
`typeset`.

references #205, fixes #408
2013-09-28 16:12:53 +02:00
Mislav Marohnić
31fab8cdae cleanup in fish
Use process subtitution syntax:

    . (rbenv init -|psub)

instead of:

    eval (rbenv init -)

because the latter doesn't work well with newlines.
2013-09-28 16:12:43 +02:00