Commit graph

210 commits

Author SHA1 Message Date
Jason Karns
f880dc6d6f Remove support for legacy version file 2015-12-28 21:34:07 -05:00
Jason Karns
3c9674453f fix local --unset test 2015-12-28 21:33:50 -05:00
Mislav Marohnić
e554cd86c3 Strip leading : from RBENV_HOOK_PATH 2015-12-24 19:12:47 +01:00
Mislav Marohnić
f9d8b551dc Add test for detecting shell when rbenv init is called from script
References #730
2015-12-24 13:20:49 +01:00
Mislav Marohnić
1a0be6f0ad Improve git --version git revision lookup
It doesn't try to chdir into RBENV_ROOT anymore because that might be
a location of an unrelated rbenv install that might have a different
version than the current one that is installed e.g. via a package
manager such as Homebrew.

Now just tries the repo where the source files (`libexec/*`) are
located, and if that isn't a valid rbenv repo, bail out early.
2015-12-24 03:52:33 +01:00
Mislav Marohnić
6481cbb172 Merge branch 'version-hooks'
Closes #739
2015-12-23 17:42:44 +01:00
Mislav Marohnić
6e30032278 Simplify version-name, version-origin hook tests
No need for helper function that's gonna be used just once.
2015-12-23 17:39:14 +01:00
Mislav Marohnić
4fde4ecbaf Ensure RBENV_VERSION_ORIGIN is not inherited from environment
It's only supposed to be set from `version-origin` hooks, but not
inherited from environment in case it was set.
2015-12-23 17:26:53 +01:00
Mislav Marohnić
40c1d27445 Merge remote-tracking branch 'origin/master' into version-hooks 2015-12-23 17:22:43 +01:00
Jason Karns
c3a5f91ed0 create hook: version-origin
Expose a `version-origin` hook.

It is invoked *before* the traditional `rbenv-version-file` lookup. Because `version-origin` is traditionally run immediately after `version-name`, then any plugin hooks that alter `version-name` would have done so. Thus, running `version-origin` prior to printing the origin gives those plugins a chance to alter the `version-origin` to match.

If any of the hooks set `$RBENV_VERSION_ORIGIN`, then it is used as the return value. Otherwise, the existing logic continues to return "environment variable" or "filename" as appropriate.

This change, in conjunction with the `version-name` hook, makes a clean seam by which plugins can inject their own ruby version setting logic. Using this seam, as opposed to altering `$RBENV_COMMAND_PATH` from the `which` hook, means that the version name and origin are set more reliably and so `version`, `version-name`, `version-origin` and `which` all work as expected. Indeed, even PS1 works now.
2015-12-23 17:22:31 +01:00
Jason Karns
258e4413b1 create hook: version-name
Expose a `version-name` hook.

It is invoked *after* the traditional `RBENV_VERSION` lookup. Which means hook scripts can interrogate `$RBENV_VERSION_FILE` and/or `$RBENV_VERSION` (or use the executables).

The hooks are then run, giving plugins a chance to alter `RBENV_VERSION`. Once the hooks have run, we now have (in `$RBENV_VERSION`) the actual version we want to use (or it's empty which defaults to `system` per normal). Lastly, the same logic remains for checking if the version exists, or trimming the `ruby-` prefix.

Prime example: the ruby-bundler-ruby-version plugin can select a ruby by using the `ruby` directive from the `Gemfile` if a local `.ruby-version` doesn't exist.
2015-12-23 17:22:30 +01:00
Mislav Marohnić
ba072adcb9 Have rbenv local read version from parent directories as well
Fixes #807
2015-12-23 15:21:24 +01:00
Mislav Marohnić
ca25259900 Allow explicit target directory argument to rbenv-version-file
Can be used for `.ruby-version` file lookup in the ancestry of a
specific directory. In this mode of operation, global version files
aren't taken into consideration, and the command fails unless a local
version file was found.
2015-12-23 15:19:54 +01:00
Yamashita, Yuu
3031cb9750 Add workaround for test failure on Arch Linux (#480) 2015-12-20 12:29:30 +00:00
Daniel Hahler
03ece82197 Merge remote-tracking branch 'rbenv/master'
Using `git merge rbenv/master -s recursive -X rename-threshold=5%`.

Conflicts:
	README.md
	bin/python-local-exec
	libexec/pyenv
	libexec/pyenv-help
	test/--version.bats
2015-12-14 13:47:11 +01:00
Mislav Marohnić
90373d78b9 Add test for not including current directory in PATH search
Confirms #836
2015-12-14 11:59:01 +01:00
Chulki Lee
df4c16ecb4 update urls to rbenv 2015-12-07 11:03:07 -08:00
Yamashita, Yuu
8da3749648 Merge remote-tracking branch 'rbenv/master' into rbenv-20151121 2015-11-21 04:21:14 +00:00
Jason Karns
a3ff3adc39 create local .ruby-version file in test dir
This new test was creating an (intentionally invalid) .ruby-version file
in current working directory; typically the rbenv project dir.
Immediately after test runs, I had a leftover .ruby-version file.

The version-file tests create and cd into the RBENV_TEST_DIR as part of
setup(). I'm using the same directory for this test fix, but am only
using it for this particular test. None of the other exec tests seem to
need to be in a temp test dir, so no use putting it in setup().
2015-11-20 09:51:44 -05:00
Jason Karns
d7ca2aba2a add --help to subcommand completions
ensure subcommand exists, then include --help in its completion output
2015-11-19 12:05:19 -05:00
Mislav Marohnić
825de5d2e3 Fix argument handling in main rbenv command
- Explicitly asking for help with `-h` or `--help` exits with 0 status
  and displays help on stdout.

- Not providing any arguments to rbenv results in failure status and
  displays version and help on stderr.
2015-11-19 01:52:48 +01:00
Mislav Marohnić
8f87f43e22 Fix broken version-dependent test
Broken in dcca61c0bc
2015-11-14 12:21:16 +00:00
Mislav Marohnić
c30e096a54 Merge branch 'which-fixes' 2015-11-14 10:42:41 +00:00
Mislav Marohnić
3405c4d03c Fix error message when command is not found for "system" version
If `foo` didn't exist and `RBENV_VERSION=system rbenv which foo` was
called, the error message used to be misleading:

    rbenv: version `system' is not installed

Instead, have the error message simply say that the command was not found.

Fixes #770
2015-11-13 23:10:09 -05:00
Mislav Marohnić
09b18cf6f5 Add test for version-origin when version not found in rbenv-exec 2015-11-13 23:09:12 -05:00
Daniel Hahler
6296bf3f8b tests: fix path_without to handle /bin properly
I was seeing /bin being left.  This patch fixes it by anchoring the search
pattern with ':' on both sides.
2015-11-12 21:20:00 +01:00
Yamashita, Yuu
9163c46568 v20151105 2015-11-05 09:21:08 +00:00
Yamashita, Yuu
0daf04a71b v20151103 2015-11-03 13:31:28 +00:00
Mislav Marohnić
e80886e9be Add rbenv versions --skip-aliases option
Useful in combination with `--bare` to list just the unique version
numbers without the extra directory entries that are symlinks to other
version numbers in the same directory.
2015-10-27 21:05:10 +01:00
Mislav Marohnić
7026e529c7 Fix realpath fallback in rbenv hooks
The symlinks weren't correctly resolved if they were pointing to a
single path component, such as `ln -s foo bar`.
2015-10-27 21:05:10 +01:00
Mislav Marohnić
dcca61c0bc Improve rbenv --version git checkout discovery
When `rbenv --version` is called, this now happens:

1. It changes into the directory where `libexec/rbenv--version` resides
   and checks if it's a checkout of the rbenv repo (as opposed to
   Homebrew checkout or something else). Then it reads the git revision.

2. If that failed, change to `$RBENV_ROOT` directory and repeat step 1.
2015-10-25 16:54:38 +01:00
Mislav Marohnić
efb187f26f Merge pull request #663 from kevinburke/use-command
Use `command` to run rbenv rehash
2015-10-11 04:04:46 +02:00
Mislav Marohnić
8a0555f8ef Init RBENV_TEST_DIR properly and only once during test setup 2015-10-10 19:02:11 +02:00
Mislav Marohnić
55f692ba9c Merge commit 'refs/pull/562/head' of https://github.com/sstephenson/rbenv 2015-10-10 18:42:36 +02:00
Mislav Marohnić
3a265c1af9 Unset XDG_CONFIG_HOME and related variables during tests
If set by the user's environment, `git config --global` writes will go
to that destination instead of temporary $HOME. We definitely don't want
that.

Fixes #742
2015-10-10 18:39:23 +02:00
Yamashita, Yuu
19c02bf39c v20151006 2015-10-06 14:12:04 +00:00
Yamashita, Yuu
948d1f4ca7 Merge branch 'blueyed-pyenv-rehash-python-glub' (fixes #379, #404) 2015-09-22 15:28:15 +09:00
Yamashita, Yuu
438e828eb5 add tests for PYENV_FILE_ARG 2015-09-22 15:28:00 +09:00
Josh Friend
c452da8084 v20150913 2015-09-13 11:03:52 -04:00
Josh Friend
193e64b6b2 v20150901 2015-09-01 13:59:13 -04:00
Yamashita, Yuu
7f32e96c28 v20150719 2015-07-19 13:07:24 +09:00
Daniel Hahler
e3982fae38 Display version origin with non-installed versions
This is useful as an indicator where it is coming from.
2015-07-17 17:10:33 +02:00
Yamashita Yuu
114063495f pyenv-prefix should return proper prefix of system version (fixes #391) 2015-06-27 01:07:18 +09:00
Josh Friend
5cb9c9af2e v20150601 2015-06-01 21:48:44 -04:00
Yamashita Yuu
9aee57d965 Fix test for adding shims in fish 2015-05-27 00:54:19 +09:00
Yamashita Yuu
1b066598ce v20150524 2015-05-24 10:53:17 +09:00
Yamashita, Yuu
46ffb0c8df Merge pull request #290 from blueyed/version-handle-missing-better
Improve `pyenv version`, if there is one missing
2015-05-17 12:05:03 +09:00
Josh Friend
1d31529b46 v20150404 2015-05-04 08:25:25 -04:00
Daniel Hahler
10d5d9a24f tests: fix desc for "can add shims to PATH more than once"
This seems to have not been merged properly.

A similar issue is with the test for fish, which has been submitted as a
PR for rbenv: https://github.com/sstephenson/rbenv/pull/722.
2015-04-20 00:00:04 +02:00
Daniel Hahler
06c1959e78 Fix test for adding shims in fish
Commit e2173df4 (for issue #369) did not handle the fish test properly.

This renames it and fixes the assertion.
2015-04-19 23:53:19 +02:00
Kevin Burke
0cd078bae6 Merge branch 'master' into use-command 2015-03-31 18:57:44 -07:00
Yamashita Yuu
ab2aa6d13b v20150326 2015-03-26 23:13:55 +09:00
Yamashita Yuu
f48a5b11d7 Import recent changes from rbenv 4d72eefffc 2015-03-07 01:01:32 +09:00
Yamashita Yuu
efe461d2b4 v20150226 (#323) 2015-02-26 11:35:10 +09:00
Yamashita Yuu
9146f44db1 v20150204 2015-02-04 10:33:21 +09:00
Mislav Marohnić
6820704c91 Remove warning about extraneous "ruby-" prefix in .ruby-version
When we started to support reading `.ruby-version` files, we made a
commitment to not support fuzzy version matching. Treating "ruby-2.1.5"
as "2.1.5" is a sort of fuzzy matching, so we put in place a warning
telling you to remove the extraneous "ruby-" prefix popularly used by
other Ruby version managers to denote MRI. (Their logic is that MRI is
"ruby" and other rubies are not "ruby", apparently.)

However, people are often not able to remove the prefix in their
projects because they want to support other coworkers and tools that
sadly still require the prefix, like RubyMine.

So to restore sanity for a big portion of our users, the warning is gone.
2015-01-29 01:55:58 -08:00
Yamashita Yuu
8abefe1fcb v20150124 2015-01-24 00:45:03 +09:00
Daniel Hahler
e8433cfeb3 Use exitcode from pyenv-version-name in pyenv-version, do not halt 2014-12-11 20:37:03 +01:00
Daniel Hahler
7f88eabd0b Improve pyenv version, if there is one missing
Display the other available ones still.

Fixes https://github.com/yyuu/pyenv/issues/291
2014-12-11 18:49:38 +01:00
Yamashita Yuu
d320d74a07 v20141211 (fixes #288) 2014-12-11 22:39:38 +09:00
Yamashita Yuu
5ca423c9f3 Revert a fix for #101 to fix broken tests relating to PYENV_NATIVE_EXT 2014-12-01 20:34:12 +09:00
Yamashita Yuu
f0e852553a Import rbenv changes at 7e0e85bdda 2014-12-01 00:29:26 +09:00
Kevin Burke
c9a96c9f79 Use command to run rbenv rehash
In the event that `eval "$(rbenv init -)"` is called from a function named
rbenv (which I do to get rbenv to load lazily in my shell), evaluating the
phrase `rbenv rehash` will cause the outer function to run again (causing an
infinite loop).

This change makes it clear you want the command named rbenv and not a function
which may exist in the environment.
2014-11-28 21:16:14 -08:00
Makoto Sasaki
c0aff27842 v20141127 2014-11-27 14:58:31 +09:00
Yamashita Yuu
8761ae8f7c v20141118 2014-11-18 20:05:01 +09:00
Yamashita Yuu
6c2d234e55 Split test files 2014-11-13 21:56:14 -08:00
Yamashita Yuu
7220044b49 v20141106 2014-11-06 09:41:22 -08:00
Mislav Marohnić
632263568e Add rbenv's own rbenv.d directory to hook paths
This allows rbenv source code to ship with built-in hooks.
2014-10-19 14:35:36 +02:00
Mislav Marohnić
bf39d88d11 Add tests for rbenv PATH and RBENV_HOOK_PATH handling 2014-10-19 14:35:36 +02:00
Mislav Marohnić
07d675350f Merge pull request #636 from sstephenson/speedup-rehash
Speed up `rbenv rehash`
2014-10-16 12:29:51 +02:00
Daniel Hahler
de5c61cd59 Fix "version X is not installed" with multiple PYENV_VERSIONs
This was introduced when merging the rbenv upstream change
(https://github.com/sstephenson/rbenv/commit/6bb7f07d2d).
2014-10-16 02:51:07 +02:00
Mislav Marohnić
39cde6fc95 Merge pull request #528 from sstephenson/dylib
Speed up rbenv by dynamically loading compiled command
2014-10-15 18:19:54 +02:00
Mislav Marohnić
1381c2ca79 Simplify the shims registration implementation in rbenv-rehash
It doesn't need to be a bash array and we don't need a separate index of
shims registered. Simply keep everything in a space-separated string and
use that as an index as well.

This assumes that executable names *never* have spaces in them.
2014-10-15 05:46:18 +02:00
Mislav Marohnić
e2173df4aa Revert "Don't duplicate shims in PATH"
Too many of our users have a shell initialization set up that
inadvertently duplicates some or most of the entries in their PATH,
bringing the system paths again in front of rbenv's shims. If this was a
nested shell (a typical scenario when starting up tmux), `rbenv init`
would get eval'd again but this time, shims won't get added to the front
of the PATH and would only stay and the end of the path, effectively
rendering them useless.

I tried to argue that this is a user problem rather than rbenv's, but I
can't fix everybody shell init when they report bugs. Instead, let's
revert to simpler times in rbenv where we just roll along with the
duplication and don't ask any questions.

This reverts commit 03fa148e81.

Fixes #369
2014-10-15 01:43:24 +02:00
Yamashita Yuu
8e657374a1 Import recent changes from rbenv-versions 2014-10-15 00:46:11 +09:00
Yamashita, Yuu
77bd5bc6c9 Merge pull request #129 from blueyed/optimize-pyenv-which
Optimize pyenv-which: implement remove_from_path in Bash
2014-10-15 00:19:28 +09:00
Daniel Hahler
e82f943174 Merge rbenv's "Isolate rbenv-which tests …" (c69d9a11)
This is the remaining part of
c69d9a1128.

    commit c69d9a1128
    Author: Mislav Marohnić <mislav.marohnic@gmail.com>
    Date:   Mon Oct 13 12:39:47 2014 +0200

        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.
2014-10-13 21:20:57 +02:00
Daniel Hahler
bbf8cb4a95 Add test for PYENV_VERSION=3.4:2.7 2014-10-13 21:15:22 +02:00
Daniel Hahler
a1df551bcf Merge tests and remove_from_path from rbenv
This adds the missing parts from the upstream rbenv merge:
f4652fbbf0

- e4cbf04592
- 3ee395f9b5
2014-10-13 21:14:57 +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
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ć
a6e0785b84 Create configure script to generate a cross-platform Makefile
The previous Makefile only worked on OS X. The dynamically generated
Makefile (from `Makefile.in`) should now work on multiple platforms
(tested on OS X and Ubuntu).
2014-10-13 04:12:35 +02:00
Mislav Marohnić
3f74da0e73 Fail hard if RBENV_NATIVE_EXT is set but extensions failed to load 2014-10-13 04:12:35 +02:00
Mislav Marohnić
68b92a7f5d Test compiled native extensions on Travis CI 2014-10-13 04:12:35 +02:00
Mislav Marohnić
8bac958994 Stop using abs_dirname() in rbenv-init
It's slow and not necessary since we expect `$0` to already be expanded.

In tests this change forces us to deal with some relative paths, but
it's not a big deal. The `rbenv init -` output in the most common case
will be the same as before:

    source '/home/myuser/.rbenv/libexec/../completions/rbenv.bash'
2014-10-13 04:12:34 +02:00
Mislav Marohnić
284588f9b4 Fix hooks tests on OS X by expanding BATS_TMPDIR
With `realpath` extension, hooks tests on OS X will output
`/private/tmp` instead of `/tmp` because the latter is an actual symlink
to the former.

Avoid this mistmach in output assertions by expanding BATS_TMPDIR if
`realpath` extension is compiled.
2014-10-13 04:12:34 +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
Makoto Sasaki
77d9e34a49 v20141012 2014-10-12 21:48:56 +09:00
Makoto Sasaki
d38f00cd4a v20141011 2014-10-11 20:00:54 +09:00
Makoto Sasaki
ff995b6654 v20141008 2014-10-08 19:29:20 +09:00
Yamashita Yuu
ab9ee414ad v20140924 2014-09-24 13:57:53 +09:00
Yamashita Yuu
6509d318f4 v20140825 2014-08-25 10:21:26 +09:00
Yamashita Yuu
b8a7de8a3c v20140705 (fixes #204) 2014-07-06 00:35:50 +09:00
Yamashita Yuu
0468ffdd49 v20140628 2014-06-28 18:04:17 +09:00
Makoto Sasaki
21c0d930e9 v20140615 2014-06-15 05:37:34 +09:00
Yamashita Yuu
2b5ee0c425 v20140614 2014-06-14 14:38:13 +09:00
Yamashita Yuu
6efe6dafe7 Changed versioning scheme; 0.4.0-20140602 -> 20140602 2014-06-04 13:40:16 +09: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