Commit graph

555 commits

Author SHA1 Message Date
Daniel Hahler
32030e2ed9 Fix shell version when invoked from a script
When invoked from a shell script, `$(rbenv init -)` did not get the
shell name correct.
It needs to look at the `args` value from `ps`.

Ref: https://github.com/yyuu/pyenv/issues/373
2015-12-24 13:21:22 +01:00
Mislav Marohnić
2c7960102c Simplify reference to realpath.dylib within rbenv-versions
The `../libexec` dance isn't necessary here. It was only necessary in
main `rbenv` command because that one might have been pointed to
directly via a symlink.
2015-12-24 03:54:32 +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ć
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
97f0499f43 add version-name/version-origin to hooks completion 2015-12-23 17:22:31 +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
b0f29d511a v20151222 2015-12-22 10:45:34 +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ć
dc23ef10b6 Merge pull request #836 from eagletmt/fix-path
Remove leading `:`
2015-12-12 15:22:36 +01:00
Kohei Suzuki
3c7a13d81f Remove leading : 2015-12-12 15:28:34 +09:00
Yamashita, Yuu
fab6a0fcd1 v20151210 2015-12-10 08:27:05 +00:00
Chulki Lee
df4c16ecb4 update urls to rbenv 2015-12-07 11:03:07 -08:00
Yamashita, Yuu
96bfa1532d Skip virtualenv aliases as well (yyuu/pyenv-virtualenv#126) 2015-12-02 09:52:33 +00:00
Yamashita, Yuu
465bd1f3e8 v20151124 2015-11-24 01:08:46 +00:00
Jason Karns
a1ef9efc80 use PWD var over pwd command 2015-11-23 09:13:31 -05:00
Jason Karns
87dd5fe2c0 indentation 2015-11-23 09:13:31 -05:00
Yamashita, Yuu
8da3749648 Merge remote-tracking branch 'rbenv/master' into rbenv-20151121 2015-11-21 04:21:14 +00:00
Mislav Marohnić
5fb9c84e14 Merge pull request #822 from jasonkarns/completion
Add --help and tab completion to rbenv-versions
2015-11-20 18:37:54 +01:00
Jason Karns
3ddedc021a Extract abort helper function
fail helper prints message to stderr and exits 1
(prefixes 'rbenv: ' if given a string arg)
2015-11-20 10:25:46 -05:00
Jason Karns
2dcb9d0611 completions for rbenv-init 2015-11-20 09:20:01 -05:00
Jason Karns
a6cb4b6317 consistent completions for rbenv-help 2015-11-20 09:15:06 -05:00
Jason Karns
2f917312f1 completions for rbenv-completions 2015-11-20 09:12:53 -05:00
Jason Karns
d1f8081d1c completions for rbenv-versions 2015-11-20 09:12:47 -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
Jason Karns
2c4dd63f77 handle --help for subcommands
If subcommand is provided (and exists) and its first arg is -h/--help,
go ahead and intercept the call; redirecting to rbenv-help <subcommand>

This means subcommands and plugins need not handle --help flag
themselves
2015-11-19 12:05:18 -05:00
Jason Karns
06e4f1b682 explicit --version flag
Without it, it falls back to `--version` being executed as a subcommand,
which works but isn't obvious
2015-11-19 11:14:59 -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ć
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
Jason Karns
8c3cab61c7 add completion block for rbenv-help 2015-11-13 15:06:29 -05:00
Yamashita, Yuu
12ad6f670b Merge pull request #471 from yyuu/activate-ng
List Anaconda-style virtual environments as a version in pyenv
2015-11-05 18:42:03 +09:00
Yamashita, Yuu
9163c46568 v20151105 2015-11-05 09:21:08 +00:00
Yamashita, Yuu
3937dc3618 list virtual environments created by anaconda/miniconda as a version in pyenv 2015-11-04 15:00:48 +00:00
Yamashita, Yuu
0daf04a71b v20151103 2015-11-03 13:31:28 +00:00
moe
f6c1e5220a Never use hardlinks. Never. 2015-10-28 21:35:39 +01: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ć
6e02b944f7 Use $BASH_SOURCE instead of $0
BASH_SOURCE might be more reliable.
2015-10-27 20:55:23 +01:00
Mislav Marohnić
6913fee89a If there is .bashrc but no .bash_profile, recommend the former
This is for Linux desktop platforms that have Terminal application
configured to start shells in interactive but not login mode. Creating a
`~/.bash_profile` would also cause `~/.profile` to not run, which might
be a problem on Ubuntu which ships with a default `~/.profile`.
2015-10-26 15:45:52 +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ć
0f44c57d08 Fix eval'ing multiline sh-* command output with bash 2015-10-12 01:33:17 +02: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ć
c101052a7f Fix eval'ing multiline sh-* command output with fish 2015-10-10 21:48:40 +02:00
Mislav Marohnić
51a1ee06e4 Merge commit '5c1094a' from #529
Closes #529
2015-10-10 19:17:18 +02:00
Mislav Marohnić
c43928a8e4 Merge pull request #731 from blueyed/init-no-basename-for-shell
rbenv-init: do not use basename for $shell
2015-10-10 18:33:52 +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
Josh Friend
c452da8084 v20150913 2015-09-13 11:03:52 -04:00
Mislav Marohnić
9e664b5d27 Suggest that rbenv should be loaded at end of shell rc file
Closes #725
2015-09-12 15:27:32 -07: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
Daniel Hahler
493f036928 shims: handle symlinked scripts, via new PYENV_FILE_ARG
`PYENV_FILE_ARG` is used here to make use of `abs_dirname` later in
`libexec/pyenv`.

Fixes https://github.com/yyuu/pyenv/issues/404
2015-07-08 18:59:22 +02:00
Daniel Hahler
af438abeae shims: look for python*
This is required for the shims to handle `#!/usr/bin/env python3` in a
shebang, just like `python` is handled currently: it will set
`PYENV_DIR` to the root of the invoked script, which is required for a
`.python-version` script to get picked up from there.

This was rejected for rbenv, where it does not make much sense
(https://github.com/sstephenson/rbenv/pull/735).

Ref: https://github.com/yyuu/pyenv/pull/368#issuecomment-102806837
2015-07-08 18:59:22 +02:00
Yamashita Yuu
114063495f pyenv-prefix should return proper prefix of system version (fixes #391) 2015-06-27 01:07:18 +09:00
Mislav Marohnić
43b28caa94 Fix discovering .ruby-version files in root directory
It's not that this is a preferred way to set a global version (one
should use `rbenv global <version>` instead), but this fixes the
function purely for correctness: all parent directories should be
scanned, even the root directory.

Fixes #745
2015-06-09 17:24:15 +02:00
Josh Friend
5cb9c9af2e v20150601 2015-06-01 21:48:44 -04:00
Yamashita Yuu
1b066598ce v20150524 2015-05-24 10:53:17 +09:00
Daniel Hahler
c754efc44b Merge pull request #378 from blueyed/version-file-read-without-type
pyenv-version-file-read: use sed instead of type/head/awk
2015-05-18 16:37:09 +02: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
Daniel Hahler
9156191168 pyenv-version-file-read: use sed/cut instead of type/head/awk
I was seeing the following occasionally in scripts:

> …/.pyenv/libexec/pyenv-version-file-read: line 12: type: write error: Broken pipe

This patch hopefully improves/fixes this, and it seems better anyway to
just use sed here.
2015-05-16 23:02:00 +02:00
Daniel Hahler
4ea7d0849b rbenv-init: do not use basename for $shell
This can be done using bash directly.
2015-05-10 16:17:35 +02:00
Josh Friend
1d31529b46 v20150404 2015-05-04 08:25:25 -04: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
derwolfe
e9aa6cf649 doc: make location to add code to more clear 2015-03-18 21:33:15 +01: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
7220044b49 v20141106 2014-11-06 09:41:22 -08:00
Daniel Hahler
a797bb6d88 Fix "pyenv: version 'system' is not installed" with pyenv which
This is a follow-up to de5c61c.
2014-11-06 17:57:17 +01: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ć
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ć
89d4e8a0e0 Speed up rehash process when there are many Ruby versions
On my system that has 25 versions under rbenv, this speeds up rehash
almost 3-fold:

- before: 391 ms
- after:  134 ms

This is achieved by removing duplicate names of executables before
registering them as shims. Since most Rubies will share a lot of the
same executable names ("ruby", "rake", "bundle", ...), this is a
considerable reduction in number of shims registered.
2014-10-15 05:46:18 +02:00
Mislav Marohnić
a8df5d587c Avoid changing directories during rehash process 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
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
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
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ć
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ć
3f74da0e73 Fail hard if RBENV_NATIVE_EXT is set but extensions failed to load 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ć
5287e2ebf4 Avoid slow abs_dirname() by loading realpath extension
This speeds up every `rbenv` invocation significantly.
2014-10-13 04:12:34 +02:00
Mislav Marohnić
16c7eb4135 Speed up realpath() with dynamically loaded C extension
On systems that support both C compiling and dynamic loading, we can
speed up `realpath()` (where most time in rbenv is spent) by replacing
it with a dynamically loaded bash builtin.

When `make -C src` is called in the project's root,
`libexec/rbenv-realpath.dylib` will be created. If it exists, rbenv will
attempt to load it as a builtin command. If it fails, execution will
fall back to the old `realpath()` shell function.
2014-10-13 04:12:34 +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
Daniel Hahler
9901c4b84d Use consistent quoting for versions=("$@") across bins 2014-09-11 12:59:40 +02:00
Daniel Hahler
b6aef96cea pyenv-version-file-write: do not use rm, but clobber the file
With e.g. /usr/local/bin/.python-version owned by some user, `pyenv
local foo` would fail, if the user has no permissions for
`/usr/local/bin`, but only the `.python-version` file.
2014-09-07 16:56:40 +02: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
6f761f8159 Remove exit 0 from initialization code of fish 2014-06-30 23:00:09 +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
Yamashita Yuu
d378b274d9 v20140602 2014-06-02 11:27:24 +09:00
Yamashita Yuu
033529915e v20140520 2014-05-20 12:28:04 +09:00
Yamashita Yuu
ef8c8b8ef2 v20140516 2014-05-16 21:07:19 +09:00
Yamashita Yuu
0c81002220 Prefer gawk over awk if both are available. 2014-05-01 13:09:55 +09:00
Adam Harvey
808527b5d0 Prefer gawk over awk if both are available. 2014-04-18 10:40:56 +10:00
Yamashita Yuu
3cde540ca0 v20140404 2014-04-04 13:16:27 +09:00
Yamashita Yuu
34065dddbb reads only the first word from file 2014-03-24 19:42:52 +09:00
Yamashita Yuu
ea9214bb2e ignores carriage returns 2014-03-24 18:15:40 +09:00
Vincent Robert
b025dfcf58 Add \r to IFS instead of removing it manually 2014-03-21 01:36:39 +01:00
Vincent Robert
f50cee2ac7 Simplify bash expression 2014-03-20 16:52:45 +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
Yamashita Yuu
0d51899e9b v0.4.0-20140317 2014-03-17 21:51:40 +09:00
Daniel Hahler
44c20af80e Optimize pyenv-which: implement remove_from_path in Bash
This greatly improves the performance of `pyenv virtualenvwrapper_lazy`,
which happens to call pyenv-which a lot.

For profiling I've initially used:

    % zmodload zsh/zprof
    % eval "$(pyenv init -)"
    % pyenv virtualenvwrapper_lazy

    Before:
    % zprof|grep -E '(pyenv|virtualenv)'
     1)    1         754,07   754,07   58,95%    751,50   751,50   58,75%  pyenv
    21)    1           2,57     2,57    0,20%      2,57     2,57    0,20%  virtualenvwrapper_setup_lazy_loader
     1)    1         754,07   754,07   58,95%    751,50   751,50   58,75%  pyenv
           1/1         2,57     2,57    0,20%      2,57     2,57             virtualenvwrapper_setup_lazy_loader [21]
           1/1         2,57     2,57    0,20%      2,57     2,57             pyenv [1]
    21)    1           2,57     2,57    0,20%      2,57     2,57    0,20%  virtualenvwrapper_setup_lazy_loader

    After:
    % zprof|grep -E '(pyenv|virtualenv)'
     1)    1         383,30   383,30   27,97%    380,88   380,88   27,79%  pyenv
    31)    1           2,42     2,42    0,18%      2,42     2,42    0,18%  virtualenvwrapper_setup_lazy_loader
     1)    1         383,30   383,30   27,97%    380,88   380,88   27,79%  pyenv
           1/1         2,42     2,42    0,18%      2,42     2,42             virtualenvwrapper_setup_lazy_loader [31]
           1/1         2,42     2,42    0,18%      2,42     2,42             pyenv [1]
    31)    1           2,42     2,42    0,18%      2,42     2,42    0,18%  virtualenvwrapper_setup_lazy_loader

Fixes https://github.com/yyuu/pyenv-virtualenvwrapper/issues/13
2014-03-13 19:21:32 +01:00
Yamashita Yuu
65ae0a3261 v0.4.0-20140311 2014-03-11 11:55:44 +09:00
Yamashita Yuu
e835d447ed v0.4.0-20140211 2014-02-11 12:11:38 +09:00
Yamashita Yuu
73d5ea7426 v0.4.0-20140123 2014-01-23 19:14:26 +09:00
Yamashita Yuu
9c82314570 Unset GREP_OPTIONS to avoid unexpected grep behavior (fixes #101) 2014-01-23 11:11:56 +09:00
Yamashita Yuu
314937d599 Set PYENV_BIN_PATH in PATH even if the version is system (fixes #98) 2014-01-15 16:41:06 +09:00
Yamashita Yuu
a7f5a19a24 v0.4.0-20140110.1 2014-01-10 15:04:16 +09:00
Yamashita Yuu
38eb9fe948 v0.4.0-20140110 2014-01-10 11:27:43 +09:00
kou1okada
5c1094adb9 Response enhancement for in the case of the working directory under the UNC path.
finding_local_version_file is extremely slow, when working directory is under the UNC path.
Because //host/.rbenv-version and //.rbenv-version do not exist, but testing them is so slow.
It's the reason to make a serious delay of the response, when the Ruby runs with a current working directory under the UNC path under Cygwin environment.

A response of before applying this patch.
//somehost/somedir $ time ruby -e "exit"

real    0m13.922s
user    0m0.168s
sys     0m0.287s

A response of after applying this patch.
//somehost/somedir $ time ruby -e "exit"

real    0m0.721s
user    0m0.153s
sys     0m0.319s
2014-01-09 15:31:29 +09:00
Yamashita Yuu
71a916faf2 simplicy the check for infinite loop 2014-01-08 10:54:11 +09:00
Yamashita Yuu
4c5ffc8d99 Avoid infinite loop in case where pwd returns relative path
The `pwd` may return relative path if the `$PWD` is badly declared
in bash/zsh (e.g. `PWD="." bash`). To avoid the infinite loop in
`find_local_version_file()`, stop finding the version file if the
target paths are same consecutively.
2014-01-03 08:35:39 +09:00
Yamashita Yuu
8dc4e8d6f8 Revert "Merge branch 'golang-workaround'"
This reverts commit 7edceff71c, reversing
changes made to 5dea3c9e63.
2014-01-03 07:39:52 +09: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
Yamashita Yuu
1587d8a03c Apply readlink to output from pwd may returns "." to get actual path 2014-01-03 05:07:21 +09:00
Yamashita Yuu
5dea3c9e63 Import changes from recent rbenv 2014-01-03 04:58:44 +09:00
Yamashita Yuu
3dd9332eee Fix broken tests 2014-01-03 04:33:30 +09:00
Yamashita Yuu
f538169992 Restore OLDIFS expectedly 2014-01-03 01:47:10 +09:00
Yamashita Yuu
d03f290b5d s/rbenv/pyenv/ 2014-01-02 22:49:23 +09:00
Yamashita Yuu
8ddf8760d5 Import recent changes from rbenv 0.4.0 2014-01-02 22:45:02 +09: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ć
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
Yamashita Yuu
5bff9c773a Reliably detect parent shell in pyenv init (fixes #93)
Imported changes from sstephenson/rbenv#453.
2013-12-26 13:48:43 +09:00
Yamashita Yuu
3d5156ed1d v0.4.0-20131217 2013-12-17 11:46:44 +09:00
Yamashita Yuu
fe07deb193 v0.4.0-20131216 2013-12-16 13:51:48 +09:00
Tanix
fd3dd225ba rewrite strip of PYENV_PREFIX_PATH in a single line 2013-12-12 23:05:31 +09:00
Tanix
140808e3d4 Fix pyenv-prefix to trim "/bin" in pyenv prefix system 2013-12-12 22:16:43 +09:00
Yamashita Yuu
5e20237f5b v0.4.0-20131116 2013-11-16 19:29:30 +09: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ć
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
Yamashita Yuu
a2ab3bc32c v0.4.0-20131023 2013-10-23 15:19:33 +09: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
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ć
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
Yamashita Yuu
6e749ef12f Import recent changes relating to fish from rbenv 2013-09-30 18:02:12 +09: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
Yamashita Yuu
5bfec84432 add fish shell support 2013-09-28 16:11:02 +02:00
Jeffrey 'jf' Lim
caa4a8e228 fix rehash when paths have spaces in them
fixes #450
2013-09-26 01:42:34 +02:00
Mislav Marohnić
bdcc2e1790 check if completion script is readable
fixes #444
2013-09-09 09:53:50 +02:00
Yamashita Yuu
683036298e fish doesn't have builtin command equivalent to bash's hash -r. 2013-08-15 22:56:57 +09:00
Yamashita Yuu
93b536863f Support fish shell 2013-08-15 22:56:53 +09:00
Yamashita Yuu
403f4eb7a7 Preserve original IFSs 2013-08-15 22:29:47 +09:00
Yamashita Yuu
ce66352f6d v0.4.0-20130726 2013-07-26 16:59:51 +09:00
Yamashita Yuu
1a6eb80bcd should not declare IFS in toplevel 2013-06-21 19:37:58 +09:00
Mislav Marohnić
db143bb654 rbenv exec: avoid mutating PATH
Enables shelling out from a ruby process started with rbenv to a ruby
process with a different RBENV_VERSION. Fixes #121

This removes the workaround created for #15 and solves `ruby -S` support
by setting RUBYPATH. PATH is never changed.

To illustrate how RUBYPATH changes in various configurations:

    PATH=~/bin:~/.rbenv/shims:/usr/bin:/bin
    RBENV_VERSION=1.8 ruby -S rake
    #=> executes ~/.rbenv/versions/1.8/bin/rake
    #=> RUBYPATH=~/bin:~/.rbenv/versions/1.8/bin:/usr/bin:/bin

    RBENV_VERSION=2.0 ruby -S rake
    #=> executes ~/.rbenv/versions/2.0/bin/rake
    #=> RUBYPATH=~/bin:~/.rbenv/versions/2.0/bin:/usr/bin:/bin

    RBENV_VERSION=system ruby -S rake
    #=> executes /usr/bin/rake
    #=> RUBYPATH=~/bin:/rbenv_shims_were_here:/usr/bin:/bin

    RBENV_VERSION=1.8 ruby -S rake
    #=> executes ~/.rbenv/versions/1.8/bin/rake
    #=> RUBYPATH=~/bin:~/.rbenv/versions/1.8/bin:/usr/bin:/bin
2013-06-20 20:41:22 +02:00
Yamashita Yuu
cc9c72747a v0.4.0-20130613 2013-06-13 20:52:10 +09:00
James FitzGibbon
81bb14e181 bail out early if readlink is not available
readlink comes from GNU coreutils.  On systems without it, rbenv used to
spin out of control when it didn't have readlink or greadlink available
because it would re-exec the frontend script over and over instead of the
worker script in libexec.

Fixes #389
2013-06-07 19:16:38 +02:00
Yamashita Yuu
319000b448 pyenv-prefix returns wrong prefix if system is given in the middle of arguments. 2013-06-04 17:35:23 +09:00
Yamashita Yuu
1b7d3b0502 move pyenv-sh-{push,pop} into plugins since they aren't from rbenv 2013-06-01 15:14:18 +09:00
Yamashita Yuu
c24207428c remove useless definition of PYENV_VERSION_PATH 2013-05-16 18:21:37 +09:00
Ian Yang
6ca591ab75 restore original IFS for hooks 2013-04-16 14:01:43 +02:00
Mislav Marohnić
ab197ef51e add tests for version commands 2013-04-08 23:16:35 +02:00
Alisdair Sullivan
497911d6c0 improve detection of completion support for commands
Enable JavasCript, Lua and Erlang scripts to provide completions
2013-04-01 16:39:51 +02:00
Mislav Marohnić
400fe31061 fix exec fails for invalid version 2013-04-01 03:01:37 +02:00
Mislav Marohnić
baf7656d2f fix iterating through paths that have spaces in them
Fixes #344, #196
2013-04-01 01:04:19 +02:00
Shohei Yamasaki
2bbf49b2f5 replace tab with spaces 2013-03-23 22:37:25 +09:00
Tim Pope
03fa148e81 Don't duplicate shims in PATH 2013-03-20 13:16:02 +01:00
Mislav Marohnić
ea3203dbab fix resolving symlinks in rbenv-hooks 2013-03-08 14:35:46 -05:00
Mislav Marohnić
bb6bccb782 tests galore 2013-03-07 15:07:32 -05:00
Mislav Marohnić
1fe59e41ea error message when rehash fails on non-writable directory
Fixes #238
2013-03-07 00:13:50 -05:00
YanhaoYang
13f36e0416 rbenv(): preserve multiline output of sh-* commands 2013-02-22 15:42:31 +01:00
Yamashita Yuu
dbb1fb5a06 release 0.2.0 2013-02-18 12:39:35 +09:00
Yamashita Yuu
ea7dc5f1e1 fix inverted result of checking version existence (refs #7) 2013-02-07 16:50:20 +09:00
Yamashita Yuu
167ff2a198 s/Ruby/Python/g; s/RBENV/PYENV/g 2013-02-06 16:05:29 +09:00