Comments (35)
also consider using http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x264.html instead to avoid cd
overwrite conflicts.
from chruby.
I assume you'd do something like PROMPT_COMMAND="chruby_auto; $PROMPT_COMMAND"
? Other than the fact the command runs on every new prompt (meaning chruby_auto
would have to return quickly if no action is needed), are there any other drawbacks?
from chruby.
I think yes, to speed up you can do:
export last_chruby_pwd=""
chruby_auto_prompt(){
[[ "$last_chruby_pwd" == "$PWD" ]] || {
chruby_auto
last_chruby_pwd="$PWD"
}
}
from chruby.
👍
from chruby.
Now using precmd_functions
and PROMPT_COMMAND
. This has the added benefit of automatically detecting new .ruby-version
files after git pull
or user creation.
from chruby.
Can't wait for it!
from chruby.
Coming in 0.3.0. But first I need to release 0.2.5, with a brand new setup.sh
and installation instructions that don't rely on @github's deprecated Downloads. Also still have to write extensive tests for auto-switching.
from chruby.
just added rvm/rvm#1388 - works great
from chruby.
Just commented on one of the tests.
from chruby.
Copy/pasting my comment so no one missing it.
To avoid ascending each directory in search of a .ruby-version (I assume this would degrade performance) after every command, I decided to require the user cd into the project root.
Thoughts?
from chruby.
descending directories should not have any impact on performance, unix/linux does cache filesystem calls, so first call to a new directory might be slightly slower (like double disk seek time) but otherwise it's fast - tested it with RVM - you do not see the difference
from chruby.
Alright, I will add an ascending search for .ruby-version
, if RUBY_VERSIONED_DIR
isn't already set.
from chruby.
OK, I think I covered all the edge-cases. Please review.
from chruby.
Hmm, @github didn't auto-link to commit bf69302. Link to source and tests.
from chruby.
"${dir%/*}"
👍
That said; I couldn't figure out how this protects from infinitely looping once /
is reached.
from chruby.
assertNull
in shell ;)
from chruby.
Realized that the current implementation will not allow overriding the .ruby-version
with an explicit call to chruby
. Is this acceptable behaviour?
from chruby.
I do not thinks so, it's quite important to allow switching to something else, especially to try other rubies with your project
from chruby.
Next question, if a user explicitly selects a Ruby, should entering a project with a .ruby-version
file override the already selected Ruby. Trying to avoid a chicken & egg problem between chruby
and chruby_auto
.
from chruby.
I would want entering the directory to set it to the version in .ruby-version
regardless of what I've previously chosen.
from chruby.
Ah, my mistake. Due to the if [[ "$version_file" == "$RUBY_VERSION_FILE" ]]; then return
check, we allow the user to override .ruby-version
while within the project. I will sleep on this and then merge into the 0.3.0 branch, if there's no other comments.
from chruby.
I think .ruby-version
is not the best name for this. It's a file specific only to chruby, and the contents are its name for your ruby (rather than some version specification that gets mapped to your ruby). In the future, it might have more info and thus be even less human-readable and generic.
I'd like to suggest .chruby
or .chruby-version
, similar to .rvm
and .rbenv
. I can put together a pull request if folks think this is a good idea and prefer one.
(And since this is the first time I've popped up on the project; thanks for making chruby, I switched a few days ago and have been really enjoying it.)
from chruby.
Isn't .ruby-version
supported by both rvm and rbenv?
from chruby.
.ruby-version
is supported by rvm and rbfu, there is a ticket for rbenv rbenv/rbenv#199 / rbenv/rbenv#201
from chruby.
I do agree that the name .ruby-version
implies a specific version (which is tedious) compared to fuzzy matching against a canonical Ruby name (name-version
). Adding a chruby specific dot-file would increase dot-file proliferation and promote factionalism amongst Rubyists; adding tool specific dot-files to repos is the developer equivalent of flying your colors.
from chruby.
I was totally unaware that was a shared standard, that's wonderful. I retract my suggestion. :)
from chruby.
I'm with @mpapis on ability to override version specified in .ruby-version with call to chruby. That's not uncommon use-case.
from chruby.
What should ruby -v
be after the following scenario?
- cd into a directory with a
.ruby-version
file, thus$(ruby -v) -eq "rubinius-2.0.0-rc1"
. - direct call
chruby ruby-1.9.3
w/ fuzzy match;$(ruby -v) -eq "ruby-1.9.3-p327"
cd tests
-- what shouldruby -v
be now?
from chruby.
@wilmoore I think it should be still what user picked in second step ruby-1.9.3-p327
- it should be reset only when user leaves context of current project / .ruby-version
from chruby.
it should be reset only when user leaves context of current project / .ruby-version
In the above scenario, when the user did cd tests
, she moved from the root of the project to a descendant directory (still part of the project). That being the case, what takes precedent.
from chruby.
Here's an example of the current behaviour:
[hal@tank ronin]$ pwd /vault/1/code/ronin [hal@tank ronin]$ cat ronin/.ruby-version 1.9 [hal@tank ronin]$ cd ronin [hal@tank ronin]$ chruby jruby-1.7.0 rubinius-2.0.0-rc1 * ruby-1.9.3-p327 [hal@tank ronin]$ cd lib [hal@tank lib]$ chruby jruby-1.7.0 rubinius-2.0.0-rc1 * ruby-1.9.3-p327 [hal@tank lib]$ chruby rubinius [hal@tank lib]$ chruby jruby-1.7.0 * rubinius-2.0.0-rc1 ruby-1.9.3-p327 [hal@tank lib]$ cd ronin/ui/cli/ [hal@tank cli]$ chruby jruby-1.7.0 * rubinius-2.0.0-rc1 ruby-1.9.3-p327 [hal@tank cli]$ cd ../../../../ [hal@tank ronin]$ pwd /vault/1/code/ronin/ronin [hal@tank ronin]$ chruby jruby-1.7.0 * rubinius-2.0.0-rc1 ruby-1.9.3-p327 [hal@tank ronin]$ cd .. [hal@tank ronin]$ chruby jruby-1.7.0 rubinius-2.0.0-rc1 ruby-1.9.3-p327
from chruby.
Appears to work as requested.
from chruby.
Without further ado, merging this into 0.3.0 branch.
from chruby.
Merged. Any pre-release comments/commits should be directed towards the 0.3.0 branch.
from chruby.
This has been released in 0.3.0.
from chruby.
Related Issues (20)
- auto.fish changes to system ruby when no .ruby-version is present HOT 11
- Stub the test ruby instead of downloading a live-ruby HOT 2
- Add separate integration tests HOT 1
- Use precmd_functions instead of preexec_functions HOT 5
- Add safe local bin directory to PATH HOT 4
- Filter out rubies that lack a bin/ruby file
- chruby reports exit status 0 under Bash, but still throws a Ruby exception when switching to mruby HOT 1
- `setup.sh` script is broken on WSL2 Ubuntu 20.04 HOT 1
- Integrate with vscode HOT 2
- Won't able to remove chruby from MacOS Shell HOT 5
- Cannot install latest ruby through chruby on Mac M2 Apple Chip HOT 1
- "chruby: unknown Ruby: ruby-3.1.2" was shown everytime launch terminal HOT 4
- Wrong $PATH in Nova Editor process
- Is there a deterministic way of checking whether bundle exec is necessary? HOT 5
- Release 0.4.0
- Chruby puts a missing directory on the PATH HOT 2
- Rename `share/chruby/dev.sh` to `share/chruby/testing.sh` (or other) HOT 7
- chruby not available system-wide HOT 1
- Unable to install on macOS 12.6.7 HOT 2
- yaourt alternative needed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chruby.